]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: convert TestListTests to the script framework
authorMichael Matloob <matloob@golang.org>
Thu, 2 Jan 2020 20:24:21 +0000 (15:24 -0500)
committerMichael Matloob <matloob@golang.org>
Wed, 19 Feb 2020 20:38:24 +0000 (20:38 +0000)
The original test has four subtests. I think it's okay to just have
one corresponding script test instead of having four different
tests.

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

Updates #36320
Updates #17751

Change-Id: I97bc2cbb3ad5a297d7457476b8c831ee6e0f49b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/213126
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/go_test.go
src/cmd/go/testdata/script/list_test_simple.txt [new file with mode: 0644]
src/cmd/go/testdata/src/testlist/bench_test.go [deleted file]
src/cmd/go/testdata/src/testlist/example_test.go [deleted file]
src/cmd/go/testdata/src/testlist/test_test.go [deleted file]

index 98838dd4c1e5657a8f70b8b95849c83bc491d554..97f6ff68ec050aaac264c0ab6c8565c26509ba85 100644 (file)
@@ -3856,24 +3856,6 @@ func main() {}`)
        }))
 }
 
-func TestListTests(t *testing.T) {
-       tooSlow(t)
-       var tg *testgoData
-       testWith := func(listName, expected string) func(*testing.T) {
-               return func(t *testing.T) {
-                       tg = testgo(t)
-                       defer tg.cleanup()
-                       tg.run("test", "./testdata/src/testlist/...", fmt.Sprintf("-list=%s", listName))
-                       tg.grepStdout(expected, fmt.Sprintf("-test.list=%s returned %q, expected %s", listName, tg.getStdout(), expected))
-               }
-       }
-
-       t.Run("Test", testWith("Test", "TestSimple"))
-       t.Run("Bench", testWith("Benchmark", "BenchmarkSimple"))
-       t.Run("Example1", testWith("Example", "ExampleSimple"))
-       t.Run("Example2", testWith("Example", "ExampleWithEmptyOutput"))
-}
-
 func TestBuildmodePIE(t *testing.T) {
        if testing.Short() && testenv.Builder() == "" {
                t.Skipf("skipping in -short mode on non-builder")
diff --git a/src/cmd/go/testdata/script/list_test_simple.txt b/src/cmd/go/testdata/script/list_test_simple.txt
new file mode 100644 (file)
index 0000000..862b7a8
--- /dev/null
@@ -0,0 +1,65 @@
+[short] skip
+
+cd $WORK
+
+# Test
+go test './gopath/src/testlist/...' -list=Test
+stdout TestSimple
+
+# Benchmark
+go test './gopath/src/testlist/...' -list=Benchmark
+stdout BenchmarkSimple
+
+# Examples
+go test './gopath/src/testlist/...' -list=Example
+stdout ExampleSimple
+stdout ExampleWithEmptyOutput
+
+-- testlist/bench_test.go --
+package testlist
+
+import (
+       "fmt"
+       "testing"
+)
+
+func BenchmarkSimplefunc(b *testing.B) {
+       b.StopTimer()
+       b.StartTimer()
+       for i := 0; i < b.N; i++ {
+               _ = fmt.Sprint("Test for bench")
+       }
+}
+-- testlist/example_test.go --
+package testlist
+
+import (
+       "fmt"
+)
+
+func ExampleSimple() {
+       fmt.Println("Test with Output.")
+
+       // Output: Test with Output.
+}
+
+func ExampleWithEmptyOutput() {
+       fmt.Println("")
+
+       // Output:
+}
+
+func ExampleNoOutput() {
+       _ = fmt.Sprint("Test with no output")
+}
+-- testlist/test_test.go --
+package testlist
+
+import (
+       "fmt"
+       "testing"
+)
+
+func TestSimple(t *testing.T) {
+       _ = fmt.Sprint("Test simple")
+}
\ No newline at end of file
diff --git a/src/cmd/go/testdata/src/testlist/bench_test.go b/src/cmd/go/testdata/src/testlist/bench_test.go
deleted file mode 100644 (file)
index 22f147b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-package testlist
-
-import (
-       "fmt"
-       "testing"
-)
-
-func BenchmarkSimplefunc(b *testing.B) {
-       b.StopTimer()
-       b.StartTimer()
-       for i := 0; i < b.N; i++ {
-               _ = fmt.Sprint("Test for bench")
-       }
-}
diff --git a/src/cmd/go/testdata/src/testlist/example_test.go b/src/cmd/go/testdata/src/testlist/example_test.go
deleted file mode 100644 (file)
index 0298dfd..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-package testlist
-
-import (
-       "fmt"
-)
-
-func ExampleSimple() {
-       fmt.Println("Test with Output.")
-
-       // Output: Test with Output.
-}
-
-func ExampleWithEmptyOutput() {
-       fmt.Println("")
-
-       // Output:
-}
-
-func ExampleNoOutput() {
-       _ = fmt.Sprint("Test with no output")
-}
diff --git a/src/cmd/go/testdata/src/testlist/test_test.go b/src/cmd/go/testdata/src/testlist/test_test.go
deleted file mode 100644 (file)
index bdc09f2..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-package testlist
-
-import (
-       "fmt"
-       "testing"
-)
-
-func TestSimple(t *testing.T) {
-       _ = fmt.Sprint("Test simple")
-}