Skip to content

Commit

Permalink
cmd/go: convert TestCoveragePattern to the script framework
Browse files Browse the repository at this point in the history
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 <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Jay Conrod <[email protected]>
  • Loading branch information
matloob committed Jan 3, 2020
1 parent 4ffd1a0 commit c57665f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 41 deletions.
16 changes: 0 additions & 16 deletions src/cmd/go/go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
37 changes: 37 additions & 0 deletions src/cmd/go/testdata/script/cover_pattern.txt
Original file line number Diff line number Diff line change
@@ -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
10 changes: 0 additions & 10 deletions src/cmd/go/testdata/src/sleepy1/p_test.go

This file was deleted.

10 changes: 0 additions & 10 deletions src/cmd/go/testdata/src/sleepy2/p_test.go

This file was deleted.

5 changes: 0 additions & 5 deletions src/cmd/go/testdata/src/sleepybad/p.go

This file was deleted.

0 comments on commit c57665f

Please sign in to comment.