mirror of
https://github.com/golang/go
synced 2024-11-23 19:20:03 -07:00
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 <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
This commit is contained in:
parent
4ffd1a0f1c
commit
c57665f4e6
@ -2193,22 +2193,6 @@ func TestCoverageImportMainLoop(t *testing.T) {
|
|||||||
tg.grepStderr("not an importable package", "did not detect import main")
|
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) {
|
func TestCoverageErrorLine(t *testing.T) {
|
||||||
skipIfGccgo(t, "gccgo has no cover tool")
|
skipIfGccgo(t, "gccgo has no cover tool")
|
||||||
tooSlow(t)
|
tooSlow(t)
|
||||||
|
37
src/cmd/go/testdata/script/cover_pattern.txt
vendored
Normal file
37
src/cmd/go/testdata/script/cover_pattern.txt
vendored
Normal file
@ -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
src/cmd/go/testdata/src/sleepy1/p_test.go
vendored
10
src/cmd/go/testdata/src/sleepy1/p_test.go
vendored
@ -1,10 +0,0 @@
|
|||||||
package p
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func Test1(t *testing.T) {
|
|
||||||
time.Sleep(200 * time.Millisecond)
|
|
||||||
}
|
|
10
src/cmd/go/testdata/src/sleepy2/p_test.go
vendored
10
src/cmd/go/testdata/src/sleepy2/p_test.go
vendored
@ -1,10 +0,0 @@
|
|||||||
package p
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func Test1(t *testing.T) {
|
|
||||||
time.Sleep(200 * time.Millisecond)
|
|
||||||
}
|
|
5
src/cmd/go/testdata/src/sleepybad/p.go
vendored
5
src/cmd/go/testdata/src/sleepybad/p.go
vendored
@ -1,5 +0,0 @@
|
|||||||
package p
|
|
||||||
|
|
||||||
// missing import
|
|
||||||
|
|
||||||
var _ = io.DoesNotExist
|
|
Loading…
Reference in New Issue
Block a user