]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: convert TestCgoConsistentResults to the script framework
authorMichael Matloob <matloob@golang.org>
Thu, 26 Dec 2019 23:19:58 +0000 (18:19 -0500)
committerMichael Matloob <matloob@golang.org>
Wed, 19 Feb 2020 20:37:54 +0000 (20:37 +0000)
The call to tooSlow is rewritten into a check for [short].

Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: I1f3e7664d575219b6fc525bd88babed15d1bd3b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/212622
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/go_test.go
src/cmd/go/testdata/script/build_cgo_consistent_results.txt [new file with mode: 0644]

index 8ca34d49ca3a493c22499f0a32a3ed32630126b4..70dee65f7fbc4f9048007c7a0c8765fe839eb358 100644 (file)
@@ -3320,38 +3320,6 @@ func TestParallelTest(t *testing.T) {
        tg.run("test", "-p=4", "p1", "p2", "p3", "p4")
 }
 
-func TestCgoConsistentResults(t *testing.T) {
-       tooSlow(t)
-       if !canCgo {
-               t.Skip("skipping because cgo not enabled")
-       }
-       switch runtime.GOOS {
-       case "solaris", "illumos":
-               testenv.SkipFlaky(t, 13247)
-       }
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.parallel()
-       tg.makeTempdir()
-       tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
-       exe1 := tg.path("cgotest1" + exeSuffix)
-       exe2 := tg.path("cgotest2" + exeSuffix)
-       tg.run("build", "-o", exe1, "cgotest")
-       tg.run("build", "-x", "-o", exe2, "cgotest")
-       b1, err := ioutil.ReadFile(exe1)
-       tg.must(err)
-       b2, err := ioutil.ReadFile(exe2)
-       tg.must(err)
-
-       if !tg.doGrepMatch(`-fdebug-prefix-map=\$WORK`, &tg.stderr) {
-               t.Skip("skipping because C compiler does not support -fdebug-prefix-map")
-       }
-       if !bytes.Equal(b1, b2) {
-               t.Error("building cgotest twice did not produce the same output")
-       }
-}
-
 // Issue 14444: go get -u .../ duplicate loads errors
 func TestGoGetUpdateAllDoesNotTryToLoadDuplicates(t *testing.T) {
        testenv.MustHaveExternalNetwork(t)
diff --git a/src/cmd/go/testdata/script/build_cgo_consistent_results.txt b/src/cmd/go/testdata/script/build_cgo_consistent_results.txt
new file mode 100644 (file)
index 0000000..42f1cc1
--- /dev/null
@@ -0,0 +1,19 @@
+[short] skip
+[!cgo] skip
+
+[solaris] skip "skipping on Solaris; see golang.org/issue/13247"
+[illumos] skip "skipping on Solaris; see golang.org/issue/13247"
+
+go build -o $WORK/exe1$GOEXE cgotest
+go build -x -o $WORK/exe2$GOEXE cgotest
+
+# TODO(matloob): skip if stderr does not contain '-fdebug-prefix-map=\$WORK'
+
+cmp $WORK/exe1$GOEXE $WORK/exe2$GOEXE
+
+-- cgotest/m.go --
+package cgotest
+
+import "C"
+
+var _ C.int