diff --git a/go/integration-tests-lib/go_integration_test.py b/go/integration-tests-lib/go_integration_test.py index 8e4cf6c102c1..2c26f513ba11 100644 --- a/go/integration-tests-lib/go_integration_test.py +++ b/go/integration-tests-lib/go_integration_test.py @@ -1,15 +1,22 @@ import os from create_database_utils import * from diagnostics_test_utils import * +from resolve_environment_utils import * -def go_integration_test(source = "src", db = "db", runFunction = runSuccessfully): +def go_integration_test(toolchain=None, source = "src", db = "db", runFunction = runSuccessfully): # Set up a GOPATH relative to this test's root directory; # we set os.environ instead of using extra_env because we # need it to be set for the call to "go clean -modcache" later goPath = os.path.join(os.path.abspath(os.getcwd()), ".go") os.environ['GOPATH'] = goPath + extra_env = None + + if toolchain != None: + extra_env = { 'GOTOOLCHAIN': toolchain } + try: + run_codeql_resolve_build_environment(lang="go", source=source, extra_env=extra_env) run_codeql_database_create([], lang="go", source=source, db=db, runFunction=runFunction) check_diagnostics() diff --git a/go/ql/integration-tests/all-platforms/go/bazel-sample-1/build-environment.expected b/go/ql/integration-tests/all-platforms/go/bazel-sample-1/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/bazel-sample-1/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/bazel-sample-2/build-environment.expected b/go/ql/integration-tests/all-platforms/go/bazel-sample-2/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/bazel-sample-2/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/diagnostics/build-constraints-exclude-all-go-files/build-environment.expected b/go/ql/integration-tests/all-platforms/go/diagnostics/build-constraints-exclude-all-go-files/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/diagnostics/build-constraints-exclude-all-go-files/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/diagnostics/go-files-found-not-processed/build-environment.expected b/go/ql/integration-tests/all-platforms/go/diagnostics/go-files-found-not-processed/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/diagnostics/go-files-found-not-processed/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/diagnostics/invalid-toolchain-version/build-environment.expected b/go/ql/integration-tests/all-platforms/go/diagnostics/invalid-toolchain-version/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/diagnostics/invalid-toolchain-version/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/diagnostics/newer-go-version-needed/build-environment.expected b/go/ql/integration-tests/all-platforms/go/diagnostics/newer-go-version-needed/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/diagnostics/newer-go-version-needed/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/diagnostics/no-go-files-found/build-environment.expected b/go/ql/integration-tests/all-platforms/go/diagnostics/no-go-files-found/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/diagnostics/no-go-files-found/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/diagnostics/package-not-found-with-go-mod/build-environment.expected b/go/ql/integration-tests/all-platforms/go/diagnostics/package-not-found-with-go-mod/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/diagnostics/package-not-found-with-go-mod/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/diagnostics/package-not-found-without-go-mod/build-environment.expected b/go/ql/integration-tests/all-platforms/go/diagnostics/package-not-found-without-go-mod/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/diagnostics/package-not-found-without-go-mod/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/diagnostics/unsupported-relative-path/build-environment.expected b/go/ql/integration-tests/all-platforms/go/diagnostics/unsupported-relative-path/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/diagnostics/unsupported-relative-path/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/go-get-without-modules-sample/build-environment.expected b/go/ql/integration-tests/all-platforms/go/go-get-without-modules-sample/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/go-get-without-modules-sample/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/go-mod-sample/build-environment.expected b/go/ql/integration-tests/all-platforms/go/go-mod-sample/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/go-mod-sample/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/go-mod-without-version/build-environment.expected b/go/ql/integration-tests/all-platforms/go/go-mod-without-version/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/go-mod-without-version/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/go-version-bump/build-environment.expected b/go/ql/integration-tests/all-platforms/go/go-version-bump/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/go-version-bump/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/make-sample/build-environment.expected b/go/ql/integration-tests/all-platforms/go/make-sample/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/make-sample/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/mixed-layout/build-environment.expected b/go/ql/integration-tests/all-platforms/go/mixed-layout/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/mixed-layout/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/ninja-sample/build-environment.expected b/go/ql/integration-tests/all-platforms/go/ninja-sample/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/ninja-sample/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/resolve-build-environment/newer-go-needed/build-environment.expected b/go/ql/integration-tests/all-platforms/go/resolve-build-environment/newer-go-needed/build-environment.expected new file mode 100644 index 000000000000..0ef0c180822c --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/resolve-build-environment/newer-go-needed/build-environment.expected @@ -0,0 +1,7 @@ +{ + "configuration" : { + "go" : { + "version" : "1.22" + } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/resolve-build-environment/newer-go-needed/diagnostics.expected b/go/ql/integration-tests/all-platforms/go/resolve-build-environment/newer-go-needed/diagnostics.expected new file mode 100644 index 000000000000..b64c1397938d --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/resolve-build-environment/newer-go-needed/diagnostics.expected @@ -0,0 +1,31 @@ +{ + "location": { + "file": "go.mod" + }, + "markdownMessage": "As of Go 1.21, toolchain versions [must use the 1.N.P syntax](https://go.dev/doc/toolchain#version).\n\n`1.22` in `go.mod` does not match this syntax and there is no additional `toolchain` directive, which may cause some `go` commands to fail.", + "severity": "warning", + "source": { + "extractorName": "go", + "id": "go/autobuilder/invalid-go-toolchain-version", + "name": "Invalid Go toolchain version" + }, + "visibility": { + "cliSummaryTable": true, + "statusPage": true, + "telemetry": true + } +} +{ + "markdownMessage": "A single `go.mod` file was found.\n\n`go.mod`", + "severity": "note", + "source": { + "extractorName": "go", + "id": "go/autobuilder/single-root-go-mod-found", + "name": "A single `go.mod` file was found in the root" + }, + "visibility": { + "cliSummaryTable": false, + "statusPage": false, + "telemetry": true + } +} diff --git a/go/ql/integration-tests/all-platforms/go/resolve-build-environment/newer-go-needed/src/go.mod b/go/ql/integration-tests/all-platforms/go/resolve-build-environment/newer-go-needed/src/go.mod new file mode 100644 index 000000000000..881685330d07 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/resolve-build-environment/newer-go-needed/src/go.mod @@ -0,0 +1,3 @@ +go 1.22 + +module main diff --git a/go/ql/integration-tests/all-platforms/go/resolve-build-environment/newer-go-needed/src/main.go b/go/ql/integration-tests/all-platforms/go/resolve-build-environment/newer-go-needed/src/main.go new file mode 100644 index 000000000000..37148d1f7af4 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/resolve-build-environment/newer-go-needed/src/main.go @@ -0,0 +1,3 @@ +package main + +func Main() {} diff --git a/go/ql/integration-tests/all-platforms/go/resolve-build-environment/newer-go-needed/test.py b/go/ql/integration-tests/all-platforms/go/resolve-build-environment/newer-go-needed/test.py new file mode 100644 index 000000000000..87741c370883 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/resolve-build-environment/newer-go-needed/test.py @@ -0,0 +1,3 @@ +from go_integration_test import * + +go_integration_test(toolchain="go1.21.0") diff --git a/go/ql/integration-tests/all-platforms/go/single-go-mod-and-go-files-not-under-it/build-environment.expected b/go/ql/integration-tests/all-platforms/go/single-go-mod-and-go-files-not-under-it/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/single-go-mod-and-go-files-not-under-it/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/single-go-mod-in-root/build-environment.expected b/go/ql/integration-tests/all-platforms/go/single-go-mod-in-root/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/single-go-mod-in-root/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/single-go-mod-not-in-root/build-environment.expected b/go/ql/integration-tests/all-platforms/go/single-go-mod-not-in-root/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/single-go-mod-not-in-root/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/single-go-work-not-in-root/build-environment.expected b/go/ql/integration-tests/all-platforms/go/single-go-work-not-in-root/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/single-go-work-not-in-root/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/two-go-mods-nested-none-in-root/build-environment.expected b/go/ql/integration-tests/all-platforms/go/two-go-mods-nested-none-in-root/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/two-go-mods-nested-none-in-root/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/two-go-mods-nested-one-in-root/build-environment.expected b/go/ql/integration-tests/all-platforms/go/two-go-mods-nested-one-in-root/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/two-go-mods-nested-one-in-root/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/two-go-mods-not-nested/build-environment.expected b/go/ql/integration-tests/all-platforms/go/two-go-mods-not-nested/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/two-go-mods-not-nested/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/all-platforms/go/two-go-mods-one-failure/build-environment.expected b/go/ql/integration-tests/all-platforms/go/two-go-mods-one-failure/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/all-platforms/go/two-go-mods-one-failure/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/linux-only/go/dep-sample/build-environment.expected b/go/ql/integration-tests/linux-only/go/dep-sample/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/linux-only/go/dep-sample/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +} diff --git a/go/ql/integration-tests/linux-only/go/glide-sample/build-environment.expected b/go/ql/integration-tests/linux-only/go/glide-sample/build-environment.expected new file mode 100644 index 000000000000..0b225ce00857 --- /dev/null +++ b/go/ql/integration-tests/linux-only/go/glide-sample/build-environment.expected @@ -0,0 +1,5 @@ +{ + "configuration" : { + "go" : { } + } +}