Skip to content

Commit 321eb34

Browse files
authored
Merge pull request #17637 from smowton/smowton/admin/go-test-extraction-tests
Go: augment test-extraction tests
2 parents 64720ad + 05d2e16 commit 321eb34

File tree

7 files changed

+41
-2
lines changed

7 files changed

+41
-2
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
go 1.14
1+
go 1.18
22

33
module testsample
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package pkg1
2+
3+
type Generic[T any] struct {
4+
element T
5+
}
6+
7+
func TestMe() {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package pkg1_test
2+
3+
import (
4+
"testsample/pkg1"
5+
)
6+
7+
func UsePkg1() {
8+
pkg1.TestMe()
9+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package pkg1
2+
3+
func UsePkg1() {
4+
TestMe()
5+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package pkg2
2+
3+
import (
4+
"testsample/pkg1"
5+
)
6+
7+
// This tests the case of cross-package generic type references
8+
// in the presence of test extraction. We need to make sure we
9+
// extract packages, including test variants, in the right order
10+
// such that we've seen pkg1.Generic before we try to use it here.
11+
12+
type Specialised = pkg1.Generic[string]

go/ql/integration-tests/test-extraction/test.expected

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
#select
2+
| src/pkg1/def.go:0:0:0:0 | src/pkg1/def.go |
3+
| src/pkg1/def_blackbox_test.go:0:0:0:0 | src/pkg1/def_blackbox_test.go |
4+
| src/pkg1/def_test.go:0:0:0:0 | src/pkg1/def_test.go |
5+
| src/pkg2/use.go:0:0:0:0 | src/pkg2/use.go |
26
| src/testme.go:0:0:0:0 | src/testme.go |
37
| src/testme_blackbox_test.go:0:0:0:0 | src/testme_blackbox_test.go |
48
| src/testme_test.go:0:0:0:0 | src/testme_test.go |
59
calls
10+
| src/pkg1/def_blackbox_test.go:8:2:8:14 | call to TestMe | src/pkg1/def.go:7:1:7:16 | function declaration |
11+
| src/pkg1/def_test.go:4:2:4:9 | call to TestMe | src/pkg1/def.go:7:1:7:16 | function declaration |
612
| src/testme_blackbox_test.go:10:18:10:44 | call to PublicFunction | src/testme.go:3:1:3:38 | function declaration |
713
| src/testme_test.go:9:18:9:33 | call to PublicFunction | src/testme.go:3:1:3:38 | function declaration |
814
| src/testme_test.go:14:19:14:35 | call to privateFunction | src/testme.go:5:1:5:39 | function declaration |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22

33
def test_traced(codeql, go):
4-
codeql.database.create(source_root="src", command="go test -c")
4+
codeql.database.create(source_root="src", command="go test -c ./...")
55

66
def test_autobuild(codeql, go):
77
codeql.database.create(source_root="src", extractor_option = ["extract_tests=true"])

0 commit comments

Comments
 (0)