Skip to content

Commit 1c4e515

Browse files
committed
cmd/go: convert TestGoTestBuildsAnXtestContainingOnly... to the script framework
The name of the test is too long to fit on the first line. It's TestGoTestBuildsAnXtestContainingOnlyNonRunnableExamples. Part of converting all tests to script framework to improve test parallelism. Updates #36320 Updates #17751 Change-Id: I490748271b10a85cbe1d34f9dbecb86ccf0101a7 Reviewed-on: https://go-review.googlesource.com/c/go/+/214423 Reviewed-by: Jay Conrod <[email protected]>
1 parent bec91ce commit 1c4e515

File tree

4 files changed

+26
-28
lines changed

4 files changed

+26
-28
lines changed

src/cmd/go/go_test.go

-7
Original file line numberDiff line numberDiff line change
@@ -1832,13 +1832,6 @@ func TestListTemplateContextFunction(t *testing.T) {
18321832
}
18331833
}
18341834

1835-
func TestGoTestBuildsAnXtestContainingOnlyNonRunnableExamples(t *testing.T) {
1836-
tg := testgo(t)
1837-
defer tg.cleanup()
1838-
tg.run("test", "-v", "./testdata/norunexample")
1839-
tg.grepStdout("File with non-runnable example was built.", "file with non-runnable example was not built")
1840-
}
1841-
18421835
// Test that you cannot use a local import in a package
18431836
// accessed by a non-local import (found in a GOPATH/GOROOT).
18441837
// See golang.org/issue/17475.

src/cmd/go/testdata/norunexample/example_test.go

-11
This file was deleted.

src/cmd/go/testdata/norunexample/test_test.go

-10
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
go test -v norunexample
2+
stdout 'File with non-runnable example was built.'
3+
4+
-- norunexample/example_test.go --
5+
package pkg_test
6+
7+
import "os"
8+
9+
func init() {
10+
os.Stdout.Write([]byte("File with non-runnable example was built.\n"))
11+
}
12+
13+
func Example_test() {
14+
// This test will not be run, it has no "Output:" comment.
15+
}
16+
-- norunexample/test_test.go --
17+
package pkg
18+
19+
import (
20+
"os"
21+
"testing"
22+
)
23+
24+
func TestBuilt(t *testing.T) {
25+
os.Stdout.Write([]byte("A normal test was executed.\n"))
26+
}

0 commit comments

Comments
 (0)