Go: Add integration test for extracting vendored dependencies

This commit is contained in:
Michael B. Gale
2024-07-08 14:05:06 +01:00
parent 31a5a7aebc
commit bc61a58000
11 changed files with 63 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
{
"configuration" : {
"go" : { }
}
}

View File

@@ -0,0 +1,14 @@
{
"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
}
}

View File

@@ -0,0 +1,2 @@
# go get has been observed to sometimes fail when multiple tests try to simultaneously fetch the same package.
goget

View File

@@ -0,0 +1,5 @@
go 1.14
require example.com/test v0.1.0
module test

View File

@@ -0,0 +1 @@
example.com/test v0.1.0/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=

View File

@@ -0,0 +1,11 @@
package test
import (
subdir "example.com/test"
)
func Test() {
foo := subdir.Add(2, 2)
println(foo)
}

View File

@@ -0,0 +1,5 @@
package test
func Add(a, b int) int {
return a + b
}

View File

@@ -0,0 +1,3 @@
# example.com/test v0.1.0
## explicit; go 1.14
example.com/test

View File

@@ -0,0 +1,5 @@
extractedFiles
| src/go.mod:0:0:0:0 | src/go.mod |
| src/test.go:0:0:0:0 | src/test.go |
| src/vendor/example.com/test/add.go:0:0:0:0 | src/vendor/example.com/test/add.go |
#select

View File

@@ -0,0 +1,4 @@
from go_integration_test import *
os.environ['CODEQL_EXTRACTOR_GO_EXTRACT_VENDOR_DIRS'] = "true"
go_integration_test()

View File

@@ -0,0 +1,8 @@
import go
import semmle.go.DiagnosticsReporting
query predicate extractedFiles(File f) { any() }
from string msg, int sev
where reportableDiagnostics(_, msg, sev)
select msg, sev