]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: convert TestCoverageNoStatements to the script framework.
authorMichael Matloob <matloob@golang.org>
Tue, 7 Jan 2020 21:41:26 +0000 (16:41 -0500)
committerMichael Matloob <matloob@golang.org>
Wed, 19 Feb 2020 20:48:19 +0000 (20:48 +0000)
Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: Ie2c60ec0654ef605439beeed92cf5f1c2c8a1dd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/213681
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/go_test.go
src/cmd/go/testdata/script/cover_statements.txt [new file with mode: 0644]
src/cmd/go/testdata/testcover/pkg1/a.go [deleted file]
src/cmd/go/testdata/testcover/pkg2/a.go [deleted file]
src/cmd/go/testdata/testcover/pkg2/a_test.go [deleted file]
src/cmd/go/testdata/testcover/pkg3/a.go [deleted file]
src/cmd/go/testdata/testcover/pkg3/a_test.go [deleted file]
src/cmd/go/testdata/testcover/pkg4/a.go [deleted file]
src/cmd/go/testdata/testcover/pkg4/a_test.go [deleted file]

index 2c952474c53e137a7648e6b2c734ec0f76f7a2fc..57a5bb8f5a70aca92671ca0d5883e3772d03e4a0 100644 (file)
@@ -2045,14 +2045,6 @@ func TestCoverageRuns(t *testing.T) {
        checkCoverage(tg, data)
 }
 
-func TestCoverageNoStatements(t *testing.T) {
-       tooSlow(t)
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.run("test", "-cover", "./testdata/testcover/pkg4")
-       tg.grepStdout("[no statements]", "expected [no statements] for pkg4")
-}
-
 func TestTestEmpty(t *testing.T) {
        if !canRace {
                t.Skip("no race detector")
diff --git a/src/cmd/go/testdata/script/cover_statements.txt b/src/cmd/go/testdata/script/cover_statements.txt
new file mode 100644 (file)
index 0000000..314ea6b
--- /dev/null
@@ -0,0 +1,57 @@
+[short] skip
+go test -cover ./pkg1 ./pkg2 ./pkg3 ./pkg4
+stdout 'pkg1   \[no test files\]'
+stdout 'pkg2   \S+     coverage: 0.0% of statements \[no tests to run\]'
+stdout 'pkg3   \S+     coverage: 100.0% of statements'
+stdout 'pkg4   \S+     coverage: \[no statements\]'
+
+-- pkg1/a.go --
+package pkg1
+
+import "fmt"
+
+func F() {
+       fmt.Println("pkg1")
+}
+-- pkg2/a.go --
+package pkg2
+
+import "fmt"
+
+func F() {
+       fmt.Println("pkg2")
+}
+-- pkg2/a_test.go --
+package pkg2
+-- pkg3/a.go --
+package pkg3
+
+import "fmt"
+
+func F() {
+       fmt.Println("pkg3")
+}
+-- pkg3/a_test.go --
+package pkg3
+
+import "testing"
+
+func TestF(t *testing.T) {
+       F()
+}
+-- pkg4/a.go --
+package pkg4
+
+type T struct {
+       X bool
+}
+-- pkg4/a_test.go --
+package pkg4
+
+import (
+       "testing"
+)
+
+func TestT(t *testing.T) {
+       _ = T{}
+}
diff --git a/src/cmd/go/testdata/testcover/pkg1/a.go b/src/cmd/go/testdata/testcover/pkg1/a.go
deleted file mode 100644 (file)
index e291611..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package pkg1
-
-import "fmt"
-
-func F() {
-       fmt.Println("pkg1")
-}
diff --git a/src/cmd/go/testdata/testcover/pkg2/a.go b/src/cmd/go/testdata/testcover/pkg2/a.go
deleted file mode 100644 (file)
index 7bd9bd4..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package pkg2
-
-import "fmt"
-
-func F() {
-       fmt.Println("pkg2")
-}
diff --git a/src/cmd/go/testdata/testcover/pkg2/a_test.go b/src/cmd/go/testdata/testcover/pkg2/a_test.go
deleted file mode 100644 (file)
index 4f791ad..0000000
+++ /dev/null
@@ -1 +0,0 @@
-package pkg2
diff --git a/src/cmd/go/testdata/testcover/pkg3/a.go b/src/cmd/go/testdata/testcover/pkg3/a.go
deleted file mode 100644 (file)
index bf86ed8..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package pkg3
-
-import "fmt"
-
-func F() {
-       fmt.Println("pkg3")
-}
diff --git a/src/cmd/go/testdata/testcover/pkg3/a_test.go b/src/cmd/go/testdata/testcover/pkg3/a_test.go
deleted file mode 100644 (file)
index 39c2c5a..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package pkg3
-
-import "testing"
-
-func TestF(t *testing.T) {
-       F()
-}
diff --git a/src/cmd/go/testdata/testcover/pkg4/a.go b/src/cmd/go/testdata/testcover/pkg4/a.go
deleted file mode 100644 (file)
index cf09e6f..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package pkg4
-
-type T struct {
-       X bool
-}
diff --git a/src/cmd/go/testdata/testcover/pkg4/a_test.go b/src/cmd/go/testdata/testcover/pkg4/a_test.go
deleted file mode 100644 (file)
index 12b8685..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-package pkg4
-
-import (
-       "testing"
-)
-
-func TestT(t *testing.T) {
-       _ = T{}
-}