mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Merge pull request #16462 from github/mbg/go/add-resolve-env-tests
Go: Add tests for `resolve build-environment`
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : {
|
||||
"version" : "1.22"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
go 1.22
|
||||
|
||||
module main
|
||||
@@ -0,0 +1,3 @@
|
||||
package main
|
||||
|
||||
func Main() {}
|
||||
@@ -0,0 +1,3 @@
|
||||
from go_integration_test import *
|
||||
|
||||
go_integration_test(toolchain="go1.21.0")
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"configuration" : {
|
||||
"go" : { }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user