mirror of
https://github.com/golang/go
synced 2024-11-17 21:44:43 -07:00
cmd/go: convert TestListTests to the script framework
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>
This commit is contained in:
parent
8df6a5d9ad
commit
7b65f1d7bb
@ -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")
|
||||
|
65
src/cmd/go/testdata/script/list_test_simple.txt
vendored
Normal file
65
src/cmd/go/testdata/script/list_test_simple.txt
vendored
Normal file
@ -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")
|
||||
}
|
14
src/cmd/go/testdata/src/testlist/bench_test.go
vendored
14
src/cmd/go/testdata/src/testlist/bench_test.go
vendored
@ -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")
|
||||
}
|
||||
}
|
21
src/cmd/go/testdata/src/testlist/example_test.go
vendored
21
src/cmd/go/testdata/src/testlist/example_test.go
vendored
@ -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")
|
||||
}
|
10
src/cmd/go/testdata/src/testlist/test_test.go
vendored
10
src/cmd/go/testdata/src/testlist/test_test.go
vendored
@ -1,10 +0,0 @@
|
||||
package testlist
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSimple(t *testing.T) {
|
||||
_ = fmt.Sprint("Test simple")
|
||||
}
|
Loading…
Reference in New Issue
Block a user