tg.grepStderr(regexp.QuoteMeta(quoted), "go get -u error does not mention shadow/root1/src/foo")
}
-func TestInstallFailsWithNoBuildableFiles(t *testing.T) {
- tg := testgo(t)
- defer tg.cleanup()
- tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
- tg.setenv("CGO_ENABLED", "0")
- tg.runFail("install", "cgotest")
- tg.grepStderr("build constraints exclude all Go files", "go install cgotest did not report 'build constraints exclude all Go files'")
-}
-
// Issue 21895
func TestMSanAndRaceRequireCgo(t *testing.T) {
if !canMSan && !canRace {
}
}
-func TestGoListDedupsPackages(t *testing.T) {
- tg := testgo(t)
- defer tg.cleanup()
- // TODO: tg.parallel()
- tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
- tg.run("list", "xtestonly", "./testdata/src/xtestonly/...")
- got := strings.TrimSpace(tg.getStdout())
- const want = "xtestonly"
- if got != want {
- t.Errorf("got %q; want %q", got, want)
- }
-}
-
func TestGoListDeps(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
}
}
-func TestGoTestXtestonlyWorks(t *testing.T) {
- tg := testgo(t)
- defer tg.cleanup()
- tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
- tg.run("clean", "-i", "xtestonly")
- tg.run("test", "xtestonly")
-}
-
func TestGoTestBuildsAnXtestContainingOnlyNonRunnableExamples(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
--- /dev/null
+# Setup
+mkdir $WORK/tmp/testdata/src/xtestonly
+cp f.go $WORK/tmp/testdata/src/xtestonly/f.go
+cp f_test.go $WORK/tmp/testdata/src/xtestonly/f_test.go
+env GOPATH=$WORK/tmp/testdata
+cd $WORK
+
+# Check output of go list to ensure no duplicates
+go list xtestonly ./testdata/src/xtestonly/...
+cmp stdout $WORK/gopath/src/wantstdout
+
+-- wantstdout --
+xtestonly
+-- f.go --
+package xtestonly
+
+func F() int { return 42 }
+-- f_test.go --
+package xtestonly_test
+
+import (
+ "testing"
+ "xtestonly"
+)
+
+func TestF(t *testing.T) {
+ if x := xtestonly.F(); x != 42 {
+ t.Errorf("f.F() = %d, want 42", x)
+ }
+}
--- /dev/null
+[short] skip
+
+go test xtestonly
+! stdout '^ok.*\[no tests to run\]'
+stdout '^ok'
+
+-- xtestonly/f.go --
+package xtestonly
+
+func F() int { return 42 }
+-- xtestonly/f_test.go --
+package xtestonly_test
+
+import (
+ "testing"
+ "xtestonly"
+)
+
+func TestF(t *testing.T) {
+ if x := xtestonly.F(); x != 42 {
+ t.Errorf("f.F() = %d, want 42", x)
+ }
+}