]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: convert TestCoverageImportMainLoop and TestGoTestMain
authorMichael Matloob <matloob@golang.org>
Mon, 30 Dec 2019 20:47:54 +0000 (15:47 -0500)
committerMichael Matloob <matloob@golang.org>
Tue, 7 Jan 2020 17:52:37 +0000 (17:52 +0000)
Convert these two tests to the script framework.

Updates #17751
Updates #36320

Change-Id: I9cc14360fab949dab91f9e5e667be85002ef5926
Reviewed-on: https://go-review.googlesource.com/c/go/+/212811
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/go_test.go
src/cmd/go/testdata/script/cover_import_main_loop.txt [new file with mode: 0644]
src/cmd/go/testdata/script/test_main_twice.txt [moved from src/cmd/go/testdata/src/multimain/multimain_test.go with 69% similarity]
src/cmd/go/testdata/src/importmain/ismain/main.go [deleted file]
src/cmd/go/testdata/src/importmain/test/test.go [deleted file]
src/cmd/go/testdata/src/importmain/test/test_test.go [deleted file]

index 0d657b2ef8734f035548ae53f64ff2fb102213ec..072de5d18c817d3e187641af879869dbbe5738b4 100644 (file)
@@ -2144,17 +2144,6 @@ func TestCoverageNoStatements(t *testing.T) {
        tg.grepStdout("[no statements]", "expected [no statements] for pkg4")
 }
 
-func TestCoverageImportMainLoop(t *testing.T) {
-       skipIfGccgo(t, "gccgo has no cover tool")
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
-       tg.runFail("test", "importmain/test")
-       tg.grepStderr("not an importable package", "did not detect import main")
-       tg.runFail("test", "-cover", "importmain/test")
-       tg.grepStderr("not an importable package", "did not detect import main")
-}
-
 func TestCoverageErrorLine(t *testing.T) {
        skipIfGccgo(t, "gccgo has no cover tool")
        tooSlow(t)
@@ -2587,21 +2576,6 @@ func TestGoTestMainAsNormalTest(t *testing.T) {
        tg.grepBoth(okPattern, "go test did not say ok")
 }
 
-func TestGoTestMainTwice(t *testing.T) {
-       if testing.Short() {
-               t.Skip("Skipping in short mode")
-       }
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.makeTempdir()
-       tg.setenv("GOCACHE", tg.tempdir)
-       tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
-       tg.run("test", "-v", "multimain")
-       if strings.Count(tg.getStdout(), "notwithstanding") != 2 {
-               t.Fatal("tests did not run twice")
-       }
-}
-
 func TestGoTestXtestonlyWorks(t *testing.T) {
        tg := testgo(t)
        defer tg.cleanup()
diff --git a/src/cmd/go/testdata/script/cover_import_main_loop.txt b/src/cmd/go/testdata/script/cover_import_main_loop.txt
new file mode 100644 (file)
index 0000000..83eef0c
--- /dev/null
@@ -0,0 +1,22 @@
+[gccgo] skip # gccgo has no cover tool
+
+! go test -n importmain/test
+stderr 'not an importable package' # check that import main was detected
+! go test -n -cover importmain/test
+stderr 'not an importable package' # check that import main was detected
+
+-- importmain/ismain/main.go --
+package main
+
+import _ "importmain/test"
+
+func main() {}
+-- importmain/test/test.go --
+package test
+-- importmain/test/test_test.go --
+package test_test
+
+import "testing"
+import _ "importmain/ismain"
+
+func TestCase(t *testing.T) {}
similarity index 69%
rename from src/cmd/go/testdata/src/multimain/multimain_test.go
rename to src/cmd/go/testdata/script/test_main_twice.txt
index 007a86a5da8f128febcddc0ad00597e32a1a7338..bc481406945ba7103cebb33cd6a74b07e66cb629 100644 (file)
@@ -1,3 +1,10 @@
+[short] skip
+
+env GOCACHE=$TMPDIR
+go test -v multimain
+stdout -count=2 notwithstanding # check tests ran twice
+
+-- multimain/multimain_test.go --
 package multimain_test
 
 import "testing"
diff --git a/src/cmd/go/testdata/src/importmain/ismain/main.go b/src/cmd/go/testdata/src/importmain/ismain/main.go
deleted file mode 100644 (file)
index bf01907..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package main
-
-import _ "importmain/test"
-
-func main() {}
diff --git a/src/cmd/go/testdata/src/importmain/test/test.go b/src/cmd/go/testdata/src/importmain/test/test.go
deleted file mode 100644 (file)
index 56e5404..0000000
+++ /dev/null
@@ -1 +0,0 @@
-package test
diff --git a/src/cmd/go/testdata/src/importmain/test/test_test.go b/src/cmd/go/testdata/src/importmain/test/test_test.go
deleted file mode 100644 (file)
index 2268a82..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-package test_test
-
-import "testing"
-import _ "importmain/ismain"
-
-func TestCase(t *testing.T) {}