Skip to content

Commit 3649af3

Browse files
committed
Go: Add test for go/autobuilder/invalid-go-toolchain-version diagnostic
1 parent 4177c38 commit 3649af3

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-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://tip.golang.org/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": "`1.21` is not a valid 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 example
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package main
2+
3+
func main() {
4+
5+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
os.environ['LGTM_INDEX_IMPORT_PATH'] = "test"
13+
run_codeql_database_create([], lang="go", source="src")
14+
15+
check_diagnostics()
16+
17+
# Clean up the temporary GOPATH to prevent Bazel failures next
18+
# time the tests are run; see https://github.com/golang/go/issues/27161
19+
subprocess.call(["go", "clean", "-modcache"])

0 commit comments

Comments
 (0)