Skip to content

Commit

Permalink
Merge pull request #16462 from github/mbg/go/add-resolve-env-tests
Browse files Browse the repository at this point in the history
Go: Add tests for `resolve build-environment`
  • Loading branch information
mbg committed May 15, 2024
2 parents 64b8f97 + 28c8611 commit 586e900
Show file tree
Hide file tree
Showing 33 changed files with 190 additions and 1 deletion.
9 changes: 8 additions & 1 deletion go/integration-tests-lib/go_integration_test.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"configuration" : {
"go" : {
"version" : "1.22"
}
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
go 1.22

module main
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package main

func Main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from go_integration_test import *

go_integration_test(toolchain="go1.21.0")
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}

0 comments on commit 586e900

Please sign in to comment.