1
0
mirror of https://github.com/golang/go synced 2024-11-23 07:10:05 -07:00

cmd/go: convert TestGoBuildTestOnly to the script framework

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>
This commit is contained in:
Michael Matloob 2020-01-08 14:05:02 -05:00
parent b865bd1fb1
commit d50429ab60
2 changed files with 15 additions and 21 deletions

View 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()

View File

@ -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