Skip to content

Commit 6b1d1d4

Browse files
committed
Go: Add integration test for incorrect version format logic
1 parent 6ea9982 commit 6b1d1d4

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"location": {
3+
"file": "go.mod"
4+
},
5+
"markdownMessage": "As of Go 1.21, toolchain versions [must use the 1.N.P syntax](https://go.dev/doc/toolchain#version).\n\n`1.21` in `go.mod` does not match this syntax and there is no additional `toolchain` directive, which may cause some `go` commands to fail.",
6+
"severity": "warning",
7+
"source": {
8+
"extractorName": "go",
9+
"id": "go/autobuilder/invalid-go-toolchain-version",
10+
"name": "Invalid Go toolchain version"
11+
},
12+
"visibility": {
13+
"cliSummaryTable": true,
14+
"statusPage": true,
15+
"telemetry": true
16+
}
17+
}
18+
{
19+
"markdownMessage": "A single `go.mod` file was found.\n\n`go.mod`",
20+
"severity": "note",
21+
"source": {
22+
"extractorName": "go",
23+
"id": "go/autobuilder/single-root-go-mod-found",
24+
"name": "A single `go.mod` file was found in the root"
25+
},
26+
"visibility": {
27+
"cliSummaryTable": false,
28+
"statusPage": false,
29+
"telemetry": true
30+
}
31+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
go 1.21
2+
3+
module test
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package main
2+
3+
func main() {}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import os
2+
import subprocess
3+
4+
from create_database_utils import *
5+
from diagnostics_test_utils import *
6+
7+
# Set up a GOPATH relative to this test's root directory;
8+
# we set os.environ instead of using extra_env because we
9+
# need it to be set for the call to "go clean -modcache" later
10+
goPath = os.path.join(os.path.abspath(os.getcwd()), ".go")
11+
os.environ['GOPATH'] = goPath
12+
run_codeql_database_create([], lang="go", source="src")
13+
14+
check_diagnostics()
15+
16+
# Clean up the temporary GOPATH to prevent Bazel failures next
17+
# time the tests are run; see https://github.com/golang/go/issues/27161
18+
subprocess.call(["go", "clean", "-modcache"])

0 commit comments

Comments
 (0)