From a7be8cccf80e04bb5c09e9f8c53d2eec4bc36d3a Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Mon, 30 Dec 2019 17:51:16 -0500 Subject: [PATCH] cmd/go: convert tests using testdata/src/syntaxerror to scripts This includes TestMatchesNoTestsDoesNotOverrideBuildFailure and TestErrorMessageForSyntaxErrorInTestGoFileSaysFAIL. Convert the tests that use the testdata/src/syntaxerror directory to the script framework. Part of converting all tests to script framework to improve test parallelism. Updates #36320 Updates #17751 Change-Id: I2b2b616e8c124996ae8c8e5b737f15bb493ec588 Reviewed-on: https://go-review.googlesource.com/c/go/+/212816 Run-TryBot: Michael Matloob TryBot-Result: Gobot Gobot Reviewed-by: Jay Conrod --- src/cmd/go/go_test.go | 19 ------------------- .../test_match_no_tests_build_failure.txt | 15 +++++++++++++++ .../script/test_syntax_error_says_fail.txt | 14 ++++++++++++++ src/cmd/go/testdata/src/syntaxerror/x.go | 1 - src/cmd/go/testdata/src/syntaxerror/x_test.go | 4 ---- 5 files changed, 29 insertions(+), 24 deletions(-) create mode 100644 src/cmd/go/testdata/script/test_match_no_tests_build_failure.txt create mode 100644 src/cmd/go/testdata/script/test_syntax_error_says_fail.txt delete mode 100644 src/cmd/go/testdata/src/syntaxerror/x.go delete mode 100644 src/cmd/go/testdata/src/syntaxerror/x_test.go diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index e45e2588469970..5e332ae2acb280 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -1217,15 +1217,6 @@ func TestAccidentalGitCheckout(t *testing.T) { } } -func TestErrorMessageForSyntaxErrorInTestGoFileSaysFAIL(t *testing.T) { - tg := testgo(t) - defer tg.cleanup() - tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata")) - tg.runFail("test", "syntaxerror") - tg.grepStderr("x_test.go:", "did not diagnose error") - tg.grepStdout("FAIL", "go test did not say FAIL") -} - func TestWildcardsDoNotLookInUselessDirectories(t *testing.T) { tg := testgo(t) defer tg.cleanup() @@ -3812,16 +3803,6 @@ func TestMatchesNoTests(t *testing.T) { tg.grepBoth(noMatchesPattern, "go test did not say [no tests to run]") } -func TestMatchesNoTestsDoesNotOverrideBuildFailure(t *testing.T) { - tg := testgo(t) - defer tg.cleanup() - tg.parallel() - tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata")) - tg.runFail("test", "-run", "ThisWillNotMatch", "syntaxerror") - tg.grepBothNot(noMatchesPattern, "go test did say [no tests to run]") - tg.grepBoth("FAIL", "go test did not say FAIL") -} - func TestMatchesNoBenchmarksIsOK(t *testing.T) { tg := testgo(t) defer tg.cleanup() diff --git a/src/cmd/go/testdata/script/test_match_no_tests_build_failure.txt b/src/cmd/go/testdata/script/test_match_no_tests_build_failure.txt new file mode 100644 index 00000000000000..92cb690dcc720a --- /dev/null +++ b/src/cmd/go/testdata/script/test_match_no_tests_build_failure.txt @@ -0,0 +1,15 @@ +# Test that when there's a build failure and a -run flag that doesn't match, +# that the error for not matching tests does not override the error for +# the build failure. + +! go test -run ThisWillNotMatch syntaxerror +! stderr '(?m)^ok.*\[no tests to run\]' +stdout 'FAIL' + +-- syntaxerror/x.go -- +package p +-- syntaxerror/x_test.go -- +package p + +func f() (x.y, z int) { +} diff --git a/src/cmd/go/testdata/script/test_syntax_error_says_fail.txt b/src/cmd/go/testdata/script/test_syntax_error_says_fail.txt new file mode 100644 index 00000000000000..29fa805b434723 --- /dev/null +++ b/src/cmd/go/testdata/script/test_syntax_error_says_fail.txt @@ -0,0 +1,14 @@ +# Test that the error message for a syntax error in a test go file +# says FAIL. + +! go test syntaxerror +stderr 'x_test.go:' # check that the error is diagnosed +stdout 'FAIL' # check that go test says FAIL + +-- syntaxerror/x.go -- +package p +-- syntaxerror/x_test.go -- +package p + +func f() (x.y, z int) { +} diff --git a/src/cmd/go/testdata/src/syntaxerror/x.go b/src/cmd/go/testdata/src/syntaxerror/x.go deleted file mode 100644 index c89cd18d0fe7d7..00000000000000 --- a/src/cmd/go/testdata/src/syntaxerror/x.go +++ /dev/null @@ -1 +0,0 @@ -package p diff --git a/src/cmd/go/testdata/src/syntaxerror/x_test.go b/src/cmd/go/testdata/src/syntaxerror/x_test.go deleted file mode 100644 index 2460743e50186d..00000000000000 --- a/src/cmd/go/testdata/src/syntaxerror/x_test.go +++ /dev/null @@ -1,4 +0,0 @@ -package p - -func f() (x.y, z int) { -}