From c57665f4e62d713e3f4c20c3e8ea075f712b1c65 Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Mon, 30 Dec 2019 17:10:23 -0500 Subject: [PATCH] cmd/go: convert TestCoveragePattern to the script framework This test already runs in parallel, but still convert it to the script framework so we can delete the testdata/src directory and remove any ambiguity about which tests can run in parallel. Updates #36320 Change-Id: I6470979bd8bad0631dc6ead0d4eb9c83878356e8 Reviewed-on: https://go-review.googlesource.com/c/go/+/212815 Run-TryBot: Michael Matloob TryBot-Result: Gobot Gobot Reviewed-by: Jay Conrod --- src/cmd/go/go_test.go | 16 --------- src/cmd/go/testdata/script/cover_pattern.txt | 37 ++++++++++++++++++++ src/cmd/go/testdata/src/sleepy1/p_test.go | 10 ------ src/cmd/go/testdata/src/sleepy2/p_test.go | 10 ------ src/cmd/go/testdata/src/sleepybad/p.go | 5 --- 5 files changed, 37 insertions(+), 41 deletions(-) create mode 100644 src/cmd/go/testdata/script/cover_pattern.txt delete mode 100644 src/cmd/go/testdata/src/sleepy1/p_test.go delete mode 100644 src/cmd/go/testdata/src/sleepy2/p_test.go delete mode 100644 src/cmd/go/testdata/src/sleepybad/p.go diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index 95c6202edd4e16..4efb471411e040 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -2193,22 +2193,6 @@ func TestCoverageImportMainLoop(t *testing.T) { tg.grepStderr("not an importable package", "did not detect import main") } -func TestCoveragePattern(t *testing.T) { - skipIfGccgo(t, "gccgo has no cover tool") - tooSlow(t) - tg := testgo(t) - defer tg.cleanup() - tg.parallel() - tg.makeTempdir() - tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata")) - - // If coverpkg=sleepy... expands by package loading - // (as opposed to pattern matching on deps) - // then it will try to load sleepybad, which does not compile, - // and the test command will fail. - tg.run("test", "-coverprofile="+tg.path("cover.out"), "-coverpkg=sleepy...", "-run=^$", "sleepy1") -} - func TestCoverageErrorLine(t *testing.T) { skipIfGccgo(t, "gccgo has no cover tool") tooSlow(t) diff --git a/src/cmd/go/testdata/script/cover_pattern.txt b/src/cmd/go/testdata/script/cover_pattern.txt new file mode 100644 index 00000000000000..0b7f2d70a242d8 --- /dev/null +++ b/src/cmd/go/testdata/script/cover_pattern.txt @@ -0,0 +1,37 @@ +[gccgo] skip + +# If coverpkg=sleepy... expands by package loading +# (as opposed to pattern matching on deps) +# then it will try to load sleepybad, which does not compile, +# and the test command will fail. +! go list sleepy... +go test -c -n -coverprofile=$TMPDIR/cover.out -coverpkg=sleepy... -run=^$ sleepy1 + +-- sleepy1/p_test.go -- +package p + +import ( + "testing" + "time" +) + +func Test1(t *testing.T) { + time.Sleep(200 * time.Millisecond) +} +-- sleepy2/p_test.go -- +package p + +import ( + "testing" + "time" +) + +func Test1(t *testing.T) { + time.Sleep(200 * time.Millisecond) +} +-- sleepybad/p.go -- +package p + +import ^ + +var _ = io.DoesNotExist diff --git a/src/cmd/go/testdata/src/sleepy1/p_test.go b/src/cmd/go/testdata/src/sleepy1/p_test.go deleted file mode 100644 index 333be7d8e4c671..00000000000000 --- a/src/cmd/go/testdata/src/sleepy1/p_test.go +++ /dev/null @@ -1,10 +0,0 @@ -package p - -import ( - "testing" - "time" -) - -func Test1(t *testing.T) { - time.Sleep(200 * time.Millisecond) -} diff --git a/src/cmd/go/testdata/src/sleepy2/p_test.go b/src/cmd/go/testdata/src/sleepy2/p_test.go deleted file mode 100644 index 333be7d8e4c671..00000000000000 --- a/src/cmd/go/testdata/src/sleepy2/p_test.go +++ /dev/null @@ -1,10 +0,0 @@ -package p - -import ( - "testing" - "time" -) - -func Test1(t *testing.T) { - time.Sleep(200 * time.Millisecond) -} diff --git a/src/cmd/go/testdata/src/sleepybad/p.go b/src/cmd/go/testdata/src/sleepybad/p.go deleted file mode 100644 index e05b403e392867..00000000000000 --- a/src/cmd/go/testdata/src/sleepybad/p.go +++ /dev/null @@ -1,5 +0,0 @@ -package p - -// missing import - -var _ = io.DoesNotExist