]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: replace TestCgoDependsOnSyscall with a simpler script test
authorBryan C. Mills <bcmills@google.com>
Tue, 17 Mar 2020 14:50:40 +0000 (10:50 -0400)
committerBryan C. Mills <bcmills@google.com>
Tue, 17 Mar 2020 17:10:51 +0000 (17:10 +0000)
The existing test attempted to remove '_race' binaries from
GOROOT/pkg, which could not only fail if GOROOT is read-only, but also
interfere with other tests run in parallel.

Updates #30316
Updates #37573
Updates #17751

Change-Id: Id7e2286ab67f8333baf4d52244b7f4476aa93a46
Reviewed-on: https://go-review.googlesource.com/c/go/+/223745
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/go/go_test.go
src/cmd/go/testdata/script/cgo_depends_on_syscall.txt [new file with mode: 0644]

index 53027b7ccb4c402d5bc13429a1f1c13b1ee02129..641cab8ddd0e538075dd4760cf0657fe041e0eae 100644 (file)
@@ -1545,34 +1545,6 @@ func TestSymlinkWarning(t *testing.T) {
        tg.grepStderr("ignoring symlink", "list should have reported symlink")
 }
 
-func TestCgoDependsOnSyscall(t *testing.T) {
-       if testing.Short() {
-               t.Skip("skipping test that removes $GOROOT/pkg/*_race in short mode")
-       }
-       if !canCgo {
-               t.Skip("skipping because cgo not enabled")
-       }
-       if !canRace {
-               t.Skip("skipping because race detector not supported")
-       }
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.parallel()
-
-       files, err := filepath.Glob(filepath.Join(runtime.GOROOT(), "pkg", "*_race"))
-       tg.must(err)
-       for _, file := range files {
-               tg.check(robustio.RemoveAll(file))
-       }
-       tg.tempFile("src/foo/foo.go", `
-               package foo
-               //#include <stdio.h>
-               import "C"`)
-       tg.setenv("GOPATH", tg.path("."))
-       tg.run("build", "-race", "foo")
-}
-
 func TestCgoShowsFullPathNames(t *testing.T) {
        if !canCgo {
                t.Skip("skipping because cgo not enabled")
diff --git a/src/cmd/go/testdata/script/cgo_depends_on_syscall.txt b/src/cmd/go/testdata/script/cgo_depends_on_syscall.txt
new file mode 100644 (file)
index 0000000..e5fa84f
--- /dev/null
@@ -0,0 +1,11 @@
+[!cgo] skip
+[!race] skip
+
+go list -race -deps foo
+stdout syscall
+
+-- foo/foo.go --
+package foo
+
+// #include <stdio.h>
+import "C"