]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: convert TestCoverageRuns to the script framework
authorMichael Matloob <matloob@golang.org>
Fri, 10 Jan 2020 18:43:21 +0000 (13:43 -0500)
committerMichael Matloob <matloob@golang.org>
Wed, 19 Feb 2020 21:03:13 +0000 (21:03 +0000)
Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

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

index 35571a75468075002b16100d64ed8524fd789f6f..4d9486f5f0f82fecaddd5f1cfef6bb695e1e15da 100644 (file)
@@ -1709,27 +1709,6 @@ func TestShadowingLogic(t *testing.T) {
        }
 }
 
-// Check that coverage analysis works at all.
-// Don't worry about the exact numbers but require not 0.0%.
-func checkCoverage(tg *testgoData, data string) {
-       tg.t.Helper()
-       if regexp.MustCompile(`[^0-9]0\.0%`).MatchString(data) {
-               tg.t.Error("some coverage results are 0.0%")
-       }
-}
-
-func TestCoverageRuns(t *testing.T) {
-       skipIfGccgo(t, "gccgo has no cover tool")
-       tooSlow(t)
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.run("test", "-short", "-coverpkg=strings", "strings", "regexp")
-       data := tg.getStdout() + tg.getStderr()
-       tg.run("test", "-short", "-cover", "strings", "math", "regexp")
-       data += tg.getStdout() + tg.getStderr()
-       checkCoverage(tg, data)
-}
-
 func TestBuildDryRunWithCgo(t *testing.T) {
        if !canCgo {
                t.Skip("skipping because cgo not enabled")
diff --git a/src/cmd/go/testdata/script/cover_runs.txt b/src/cmd/go/testdata/script/cover_runs.txt
new file mode 100644 (file)
index 0000000..38a7bb7
--- /dev/null
@@ -0,0 +1,13 @@
+[gccgo] skip 'gccgo has no cover tool'
+[short] skip
+
+go test -short -coverpkg=strings strings regexp
+! stdout '[^0-9]0\.0%'
+stdout  'strings.*coverage:.*[1-9][0-9.]+%'
+stdout  'regexp.*coverage:.*[1-9][0-9.]+%'
+
+go test -short -cover strings math regexp
+! stdout '[^0-9]0\.0%'
+stdout  'strings.*coverage:.*[1-9][0-9.]+%'
+stdout  'math.*coverage:.*[1-9][0-9.]+%'
+stdout  'regexp.*coverage:.*[1-9][0-9.]+%'
\ No newline at end of file