checkCoverage(tg, data)
}
-func TestTestEmpty(t *testing.T) {
- if !canRace {
- t.Skip("no race detector")
- }
-
- wd, _ := os.Getwd()
- testdata := filepath.Join(wd, "testdata")
- for _, dir := range []string{"pkg", "test", "xtest", "pkgtest", "pkgxtest", "pkgtestxtest", "testxtest"} {
- t.Run(dir, func(t *testing.T) {
- tg := testgo(t)
- defer tg.cleanup()
- tg.setenv("GOPATH", testdata)
- tg.cd(filepath.Join(testdata, "src/empty/"+dir))
- tg.run("test", "-cover", "-coverpkg=.", "-race")
- })
- if testing.Short() {
- break
- }
- }
-}
-
-func TestNoGoError(t *testing.T) {
- wd, _ := os.Getwd()
- testdata := filepath.Join(wd, "testdata")
- for _, dir := range []string{"empty/test", "empty/xtest", "empty/testxtest", "exclude", "exclude/ignore", "exclude/empty"} {
- t.Run(dir, func(t *testing.T) {
- tg := testgo(t)
- defer tg.cleanup()
- tg.setenv("GOPATH", testdata)
- tg.cd(filepath.Join(testdata, "src"))
- tg.runFail("build", "./"+dir)
- var want string
- if strings.Contains(dir, "test") {
- want = "no non-test Go files in "
- } else if dir == "exclude" {
- want = "build constraints exclude all Go files in "
- } else {
- want = "no Go files in "
- }
- tg.grepStderr(want, "wrong reason for failure")
- })
- }
-}
-
-func TestTestRaceInstall(t *testing.T) {
- if !canRace {
- t.Skip("no race detector")
- }
- tooSlow(t)
-
- tg := testgo(t)
- defer tg.cleanup()
- tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
-
- tg.tempDir("pkg")
- pkgdir := tg.path("pkg")
- tg.run("install", "-race", "-pkgdir="+pkgdir, "std")
- tg.run("test", "-race", "-pkgdir="+pkgdir, "-i", "-v", "empty/pkg")
- if tg.getStderr() != "" {
- t.Error("go test -i -race: rebuilds cached packages")
- }
-}
-
func TestBuildDryRunWithCgo(t *testing.T) {
if !canCgo {
t.Skip("skipping because cgo not enabled")
tg.must(robustio.RemoveAll(matches[1]))
}
-func TestWrongGOOSErrorBeforeLoadError(t *testing.T) {
- skipIfGccgo(t, "gccgo assumes cross-compilation is always possible")
- tg := testgo(t)
- defer tg.cleanup()
- tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
- tg.setenv("GOOS", "windwos")
- tg.runFail("build", "exclude")
- tg.grepStderr("unsupported GOOS/GOARCH pair", "GOOS=windwos go build exclude did not report 'unsupported GOOS/GOARCH pair'")
-}
-
func TestUpxCompression(t *testing.T) {
if runtime.GOOS != "linux" ||
(runtime.GOARCH != "amd64" && runtime.GOARCH != "386") {
--- /dev/null
+! go build ./empty/test
+stderr 'no non-test Go files in '
+
+! go build ./empty/xtest
+stderr 'no non-test Go files in '
+
+! go build ./empty/testxtest
+stderr 'no non-test Go files in '
+
+! go build ./exclude
+stderr 'build constraints exclude all Go files in '
+
+! go build ./exclude/ignore
+stderr 'no Go files in '
+
+! go build ./exclude/empty
+stderr 'no Go files in '
+
+-- empty/test/test_test.go --
+package p
+-- empty/testxtest/test_test.go --
+package p
+-- empty/testxtest/xtest_test.go --
+package p_test
+-- empty/xtest/xtest_test.go --
+package p_test
+-- exclude/empty/x.txt --
+-- exclude/ignore/_x.go --
+package x
+-- exclude/x.go --
+// +build linux,!linux
+
+package x
+-- exclude/x_linux.go --
+// +build windows
+
+package x
--- /dev/null
+[!race] skip
+
+cd $GOPATH/src/empty/pkg
+go test -cover -coverpkg=. -race
+
+[short] stop # Only run first case in short mode
+
+cd $GOPATH/src/empty/test
+go test -cover -coverpkg=. -race
+
+cd $GOPATH/src/empty/xtest
+go test -cover -coverpkg=. -race
+
+cd $GOPATH/src/empty/pkgtest
+go test -cover -coverpkg=. -race
+
+cd $GOPATH/src/empty/pkgxtest
+go test -cover -coverpkg=. -race
+
+cd $GOPATH/src/empty/pkgtestxtest
+go test -cover -coverpkg=. -race
+
+cd $GOPATH/src/empty/testxtest
+go test -cover -coverpkg=. -race
+
+-- empty/pkg/pkg.go --
+package p
+-- empty/pkgtest/pkg.go --
+package p
+-- empty/pkgtest/test_test.go --
+package p
+-- empty/pkgtestxtest/pkg.go --
+package p
+-- empty/pkgtestxtest/test_test.go --
+package p
+-- empty/pkgtestxtest/xtest_test.go --
+package p_test
+-- empty/pkgxtest/pkg.go --
+package p
+-- empty/pkgxtest/xtest_test.go --
+package p_test
+-- empty/test/test_test.go --
+package p
+-- empty/testxtest/test_test.go --
+package p
+-- empty/testxtest/xtest_test.go --
+package p_test
+-- empty/xtest/xtest_test.go --
+package p_test