mirror of
https://github.com/golang/go
synced 2024-11-17 21:04:43 -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:
parent
b865bd1fb1
commit
d50429ab60
@ -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()
|
||||
|
15
src/cmd/go/testdata/script/build_test_only.txt
vendored
Normal file
15
src/cmd/go/testdata/script/build_test_only.txt
vendored
Normal 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
|
Loading…
Reference in New Issue
Block a user