Add test for unexpected directory layout error

This commit is contained in:
Owen Mansel-Chan
2023-03-08 12:17:53 +00:00
parent 83569911ae
commit d6712b2111
4 changed files with 40 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
{
"markdownMessage": "You should replace relative package paths (that contain `.` or `..`) with absolute paths. Alternatively you can [use a Go module](https://go.dev/blog/using-go-modules).",
"severity": "error",
"source": {
"extractorName": "go",
"id": "go/autobuilder/relative-import-paths",
"name": "Some imports use unsupported relative package paths"
},
"visibility": {
"cliSummaryTable": true,
"statusPage": true,
"telemetry": true
}
}

View File

@@ -0,0 +1,9 @@
import sys
from create_database_utils import *
from diagnostics_test_utils import *
os.environ['GITHUB_REPOSITORY'] = "a/b"
run_codeql_database_create([], lang="go", source="work", db=None, runFunction=runUnsuccessfully)
check_diagnostics()

View File

@@ -0,0 +1,9 @@
package main
import (
"./subpkg"
)
func main() {
subpkg.F()
}

View File

@@ -0,0 +1,8 @@
package subpkg
import "fmt"
func F() {
// It is required that there is an import in this package, which is import by another package using a local path
fmt.Println("subpkg.F")
}