1
0
mirror of https://github.com/golang/go synced 2024-11-17 23:24:50 -07:00

cmd/go: convert TestCoverageRuns to the script framework

Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: Ie46118eddbd7c3ed0bb9ecee4bdc1cb6fdaf06a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/214291
Reviewed-by: Jay Conrod <jayconrod@google.com>
This commit is contained in:
Michael Matloob 2020-01-10 13:43:21 -05:00
parent 1331113405
commit b44008fec7
2 changed files with 13 additions and 21 deletions

View File

@ -1709,27 +1709,6 @@ func TestShadowingLogic(t *testing.T) {
} }
} }
// Check that coverage analysis works at all.
// Don't worry about the exact numbers but require not 0.0%.
func checkCoverage(tg *testgoData, data string) {
tg.t.Helper()
if regexp.MustCompile(`[^0-9]0\.0%`).MatchString(data) {
tg.t.Error("some coverage results are 0.0%")
}
}
func TestCoverageRuns(t *testing.T) {
skipIfGccgo(t, "gccgo has no cover tool")
tooSlow(t)
tg := testgo(t)
defer tg.cleanup()
tg.run("test", "-short", "-coverpkg=strings", "strings", "regexp")
data := tg.getStdout() + tg.getStderr()
tg.run("test", "-short", "-cover", "strings", "math", "regexp")
data += tg.getStdout() + tg.getStderr()
checkCoverage(tg, data)
}
func TestBuildDryRunWithCgo(t *testing.T) { func TestBuildDryRunWithCgo(t *testing.T) {
if !canCgo { if !canCgo {
t.Skip("skipping because cgo not enabled") t.Skip("skipping because cgo not enabled")

View File

@ -0,0 +1,13 @@
[gccgo] skip 'gccgo has no cover tool'
[short] skip
go test -short -coverpkg=strings strings regexp
! stdout '[^0-9]0\.0%'
stdout 'strings.*coverage:.*[1-9][0-9.]+%'
stdout 'regexp.*coverage:.*[1-9][0-9.]+%'
go test -short -cover strings math regexp
! stdout '[^0-9]0\.0%'
stdout 'strings.*coverage:.*[1-9][0-9.]+%'
stdout 'math.*coverage:.*[1-9][0-9.]+%'
stdout 'regexp.*coverage:.*[1-9][0-9.]+%'