From 2863969cc3a5c17cc69a2d967911954b5cc1f7ad Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Mon, 30 Dec 2019 16:41:39 -0500 Subject: [PATCH] cmd/go: convert TestIssue7108 to the script framework Part of converting all tests to script framework to improve test parallelism. Updates #36320 Updates #17751 Change-Id: Ic16a0c6c1eabeba003b9cff620e2911078fd6cf8 Reviewed-on: https://go-review.googlesource.com/c/go/+/212813 Run-TryBot: Michael Matloob TryBot-Result: Gobot Gobot Reviewed-by: Jay Conrod --- src/cmd/go/go_test.go | 8 -------- src/cmd/go/testdata/script/test_badtest.txt | 19 ++++++++++++++++++- src/cmd/go/testdata/src/notest/hello.go | 6 ------ 3 files changed, 18 insertions(+), 15 deletions(-) delete mode 100644 src/cmd/go/testdata/src/notest/hello.go diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index 45d9ab6a89..7d37f512bf 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -2588,14 +2588,6 @@ func TestListTemplateContextFunction(t *testing.T) { } } -// cmd/go: "go test" should fail if package does not build -func TestIssue7108(t *testing.T) { - tg := testgo(t) - defer tg.cleanup() - tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata")) - tg.runFail("test", "notest") -} - func TestGoBuildTestOnly(t *testing.T) { tg := testgo(t) defer tg.cleanup() diff --git a/src/cmd/go/testdata/script/test_badtest.txt b/src/cmd/go/testdata/script/test_badtest.txt index f5db6941a0..e79fc511b3 100644 --- a/src/cmd/go/testdata/script/test_badtest.txt +++ b/src/cmd/go/testdata/script/test_badtest.txt @@ -1,11 +1,21 @@ env GO111MODULE=off -! go test badtest/... +! go test badtest/badexec ! stdout ^ok stdout ^FAIL\tbadtest/badexec + +! go test badtest/badsyntax +! stdout ^ok stdout ^FAIL\tbadtest/badsyntax + +! go test badtest/badvar +! stdout ^ok stdout ^FAIL\tbadtest/badvar +! go test notest +! stdout ^ok +stderr '^notest.hello.go:6:1: syntax error: non-declaration statement outside function body' # Exercise issue #7108 + -- badtest/badexec/x_test.go -- package badexec @@ -30,3 +40,10 @@ package badvar_test func f() { _ = notdefined } +-- notest/hello.go -- +package notest + +func hello() { + println("hello world") +} +Hello world \ No newline at end of file diff --git a/src/cmd/go/testdata/src/notest/hello.go b/src/cmd/go/testdata/src/notest/hello.go deleted file mode 100644 index 7c42c32fb0..0000000000 --- a/src/cmd/go/testdata/src/notest/hello.go +++ /dev/null @@ -1,6 +0,0 @@ -package notest - -func hello() { - println("hello world") -} -Hello world