1
0
mirror of https://github.com/golang/go synced 2024-09-30 05:24:29 -06:00

cmd/go: convert TestCoverageNoStatements to the script framework.

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

Updates #36320
Updates #17751

Change-Id: Ie2c60ec0654ef605439beeed92cf5f1c2c8a1dd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/213681
Reviewed-by: Jay Conrod <jayconrod@google.com>
This commit is contained in:
Michael Matloob 2020-01-07 16:41:26 -05:00
parent 8538f5f08f
commit fcfc16694f
9 changed files with 57 additions and 51 deletions

View File

@ -2045,14 +2045,6 @@ func TestCoverageRuns(t *testing.T) {
checkCoverage(tg, data) checkCoverage(tg, data)
} }
func TestCoverageNoStatements(t *testing.T) {
tooSlow(t)
tg := testgo(t)
defer tg.cleanup()
tg.run("test", "-cover", "./testdata/testcover/pkg4")
tg.grepStdout("[no statements]", "expected [no statements] for pkg4")
}
func TestTestEmpty(t *testing.T) { func TestTestEmpty(t *testing.T) {
if !canRace { if !canRace {
t.Skip("no race detector") t.Skip("no race detector")

View File

@ -0,0 +1,57 @@
[short] skip
go test -cover ./pkg1 ./pkg2 ./pkg3 ./pkg4
stdout 'pkg1 \[no test files\]'
stdout 'pkg2 \S+ coverage: 0.0% of statements \[no tests to run\]'
stdout 'pkg3 \S+ coverage: 100.0% of statements'
stdout 'pkg4 \S+ coverage: \[no statements\]'
-- pkg1/a.go --
package pkg1
import "fmt"
func F() {
fmt.Println("pkg1")
}
-- pkg2/a.go --
package pkg2
import "fmt"
func F() {
fmt.Println("pkg2")
}
-- pkg2/a_test.go --
package pkg2
-- pkg3/a.go --
package pkg3
import "fmt"
func F() {
fmt.Println("pkg3")
}
-- pkg3/a_test.go --
package pkg3
import "testing"
func TestF(t *testing.T) {
F()
}
-- pkg4/a.go --
package pkg4
type T struct {
X bool
}
-- pkg4/a_test.go --
package pkg4
import (
"testing"
)
func TestT(t *testing.T) {
_ = T{}
}

View File

@ -1,7 +0,0 @@
package pkg1
import "fmt"
func F() {
fmt.Println("pkg1")
}

View File

@ -1,7 +0,0 @@
package pkg2
import "fmt"
func F() {
fmt.Println("pkg2")
}

View File

@ -1 +0,0 @@
package pkg2

View File

@ -1,7 +0,0 @@
package pkg3
import "fmt"
func F() {
fmt.Println("pkg3")
}

View File

@ -1,7 +0,0 @@
package pkg3
import "testing"
func TestF(t *testing.T) {
F()
}

View File

@ -1,5 +0,0 @@
package pkg4
type T struct {
X bool
}

View File

@ -1,9 +0,0 @@
package pkg4
import (
"testing"
)
func TestT(t *testing.T) {
_ = T{}
}