]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: convert TestGoBuildTestOnly to the script framework
authorMichael Matloob <matloob@golang.org>
Wed, 8 Jan 2020 19:05:02 +0000 (14:05 -0500)
committerMichael Matloob <matloob@golang.org>
Wed, 19 Feb 2020 20:50:00 +0000 (20:50 +0000)
Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: I1832e15e6a15301e075d2ec9d5169a77f11328fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/213822
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/go_test.go
src/cmd/go/testdata/script/build_test_only.txt [new file with mode: 0644]

index 03f482628f46b3f10b07c4c331f79a7b6beefb26..ade3330e2c48363f2628bb7c657c40136ccf947c 100644 (file)
@@ -2303,27 +2303,6 @@ func TestListTemplateContextFunction(t *testing.T) {
        }
 }
 
-func TestGoBuildTestOnly(t *testing.T) {
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.makeTempdir()
-       tg.setenv("GOPATH", tg.path("."))
-       tg.tempFile("src/testonly/t_test.go", `package testonly`)
-       tg.tempFile("src/testonly2/t.go", `package testonly2`)
-       tg.cd(tg.path("src"))
-
-       // Named explicitly, test-only packages should be reported as unbuildable/uninstallable,
-       // even if there is a wildcard also matching.
-       tg.runFail("build", "testonly", "testonly...")
-       tg.grepStderr("no non-test Go files in", "go build ./xtestonly produced unexpected error")
-       tg.runFail("install", "./testonly")
-       tg.grepStderr("no non-test Go files in", "go install ./testonly produced unexpected error")
-
-       // Named through a wildcards, the test-only packages should be silently ignored.
-       tg.run("build", "testonly...")
-       tg.run("install", "./testonly...")
-}
-
 func TestGoTestXtestonlyWorks(t *testing.T) {
        tg := testgo(t)
        defer tg.cleanup()
diff --git a/src/cmd/go/testdata/script/build_test_only.txt b/src/cmd/go/testdata/script/build_test_only.txt
new file mode 100644 (file)
index 0000000..54dd597
--- /dev/null
@@ -0,0 +1,15 @@
+# Named explicitly, test-only packages should be reported as
+# unbuildable/uninstallable, even if there is a wildcard also matching.
+! go build testonly testonly...
+stderr 'no non-test Go files in'
+! go install ./testonly
+stderr 'no non-test Go files in'
+
+# Named through a wildcard, the test-only packages should be silently ignored.
+go build testonly...
+go install ./testonly...
+
+-- testonly/t_test.go --
+package testonly
+-- testonly2/t.go --
+package testonly2