Skip to content

Commit 1a9bd9c

Browse files
authored
Merge pull request github#13135 from owen-mc/go/fix-unit-test
Go: fix unit test
2 parents 167a572 + 77c8357 commit 1a9bd9c

File tree

2 files changed

+27
-35
lines changed

2 files changed

+27
-35
lines changed

go/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ ql/lib/go.dbscheme.stats: ql/lib/go.dbscheme build/stats/src.stamp extractor
113113

114114
test: all build/testdb/check-upgrade-path
115115
codeql test run -j0 ql/test --search-path build/codeql-extractor-go --consistency-queries ql/test/consistency --compilation-cache=$(cache)
116-
# use GOOS=linux because GOOS=darwin GOARCH=386 is no longer supported
116+
# use GOOS=linux because GOOS=darwin GOARCH=386 is no longer supported
117117
env GOOS=linux GOARCH=386 codeql$(EXE) test run -j0 ql/test/query-tests/Security/CWE-681 --search-path build/codeql-extractor-go --consistency-queries ql/test/consistency --compilation-cache=$(cache)
118-
cd extractor; go test -mod=vendor ./... | grep -vF "[no test files]"
118+
cd extractor; go test -mod=vendor ./...
119119
bash extractor-smoke-test/test.sh || (echo "Extractor smoke test FAILED"; exit 1)
120120

121121
.PHONY: build/testdb/check-upgrade-path

go/extractor/cli/go-autobuilder/go-autobuilder_test.go

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -36,45 +36,37 @@ func TestParseGoVersion(t *testing.T) {
3636

3737
func TestGetVersionToInstall(t *testing.T) {
3838
tests := map[versionInfo]string{
39-
// checkForUnsupportedVersions()
40-
41-
// go.mod version below minGoVersion
42-
{"0.0", true, "1.20.3", true}: "",
43-
{"0.0", true, "9999.0", true}: "",
44-
{"0.0", true, "1.2.2", true}: "",
45-
{"0.0", true, "", false}: "",
46-
// go.mod version above maxGoVersion
47-
{"9999.0", true, "1.20.3", true}: "",
48-
{"9999.0", true, "9999.0.1", true}: "",
49-
{"9999.0", true, "1.1", true}: "",
50-
{"9999.0", true, "", false}: "",
51-
// Go installation found with version below minGoVersion
52-
{"1.20", true, "1.2.2", true}: "1.20",
53-
{"1.11", true, "1.2.2", true}: "1.11",
39+
// getVersionWhenGoModVersionNotFound()
40+
{"", false, "", false}: maxGoVersion,
5441
{"", false, "1.2.2", true}: maxGoVersion,
55-
// Go installation found with version above maxGoVersion
56-
{"1.20", true, "9999.0.1", true}: "1.20",
57-
{"1.11", true, "9999.0.1", true}: "1.11",
58-
{"", false, "9999.0.1", true}: maxGoVersion,
42+
{"", false, "9999.0.1", true}: maxGoVersion,
43+
{"", false, "1.11.13", true}: "",
44+
{"", false, "1.20.3", true}: "",
5945

60-
// checkForVersionsNotFound()
46+
// getVersionWhenGoModVersionTooHigh()
47+
{"9999.0", true, "", false}: maxGoVersion,
48+
{"9999.0", true, "9999.0.1", true}: "",
49+
{"9999.0", true, "1.1", true}: maxGoVersion,
50+
{"9999.0", true, minGoVersion, false}: maxGoVersion,
51+
{"9999.0", true, maxGoVersion, true}: "",
6152

62-
// Go installation not found, go.mod version in supported range
63-
{"1.20", true, "", false}: "1.20",
64-
{"1.11", true, "", false}: "1.11",
65-
// Go installation not found, go.mod not found
66-
{"", false, "", false}: maxGoVersion,
67-
// Go installation found with version in supported range, go.mod not found
68-
{"", false, "1.11.13", true}: "",
69-
{"", false, "1.20.3", true}: "",
70-
71-
// compareVersions()
53+
// getVersionWhenGoModVersionTooLow()
54+
{"0.0", true, "", false}: minGoVersion,
55+
{"0.0", true, "9999.0", true}: minGoVersion,
56+
{"0.0", true, "1.2.2", true}: minGoVersion,
57+
{"0.0", true, "1.20.3", true}: "",
7258

73-
// Go installation found with version in supported range, go.mod version in supported range and go.mod version > go installation version
59+
// getVersionWhenGoModVersionSupported()
60+
{"1.20", true, "", false}: "1.20",
61+
{"1.11", true, "", false}: "1.11",
62+
{"1.20", true, "1.2.2", true}: "1.20",
63+
{"1.11", true, "1.2.2", true}: "1.11",
64+
{"1.20", true, "9999.0.1", true}: "1.20",
65+
{"1.11", true, "9999.0.1", true}: "1.11",
66+
// go.mod version > go installation version
7467
{"1.20", true, "1.11.13", true}: "1.20",
7568
{"1.20", true, "1.12", true}: "1.20",
76-
// Go installation found with version in supported range, go.mod version in supported range and go.mod version <= go installation version
77-
// (Note comparisons ignore the patch version)
69+
// go.mod version <= go installation version (Note comparisons ignore the patch version)
7870
{"1.11", true, "1.20", true}: "",
7971
{"1.11", true, "1.20.3", true}: "",
8072
{"1.20", true, "1.20.3", true}: "",

0 commit comments

Comments
 (0)