mirror of
https://github.com/golang/go
synced 2024-11-25 11:07:59 -07:00
testing: do not print 'no tests' when there are examples
I am not sure why RunTests and RunExamples are exported, but I assume that because they are we should not change the signature, so I added an unexported global shared by Main and RunTests. Fixes #3237. R=golang-dev, gri CC=golang-dev https://golang.org/cl/5779043
This commit is contained in:
parent
3dcedb620c
commit
291636b99b
@ -107,6 +107,8 @@ var (
|
|||||||
cpuListStr = flag.String("test.cpu", "", "comma-separated list of number of CPUs to use for each test")
|
cpuListStr = flag.String("test.cpu", "", "comma-separated list of number of CPUs to use for each test")
|
||||||
parallel = flag.Int("test.parallel", runtime.GOMAXPROCS(0), "maximum test parallelism")
|
parallel = flag.Int("test.parallel", runtime.GOMAXPROCS(0), "maximum test parallelism")
|
||||||
|
|
||||||
|
haveExamples bool // are there examples?
|
||||||
|
|
||||||
cpuList []int
|
cpuList []int
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -279,6 +281,7 @@ func Main(matchString func(pat, str string) (bool, error), tests []InternalTest,
|
|||||||
|
|
||||||
before()
|
before()
|
||||||
startAlarm()
|
startAlarm()
|
||||||
|
haveExamples = len(examples) > 0
|
||||||
testOk := RunTests(matchString, tests)
|
testOk := RunTests(matchString, tests)
|
||||||
exampleOk := RunExamples(matchString, examples)
|
exampleOk := RunExamples(matchString, examples)
|
||||||
if !testOk || !exampleOk {
|
if !testOk || !exampleOk {
|
||||||
@ -303,7 +306,7 @@ func (t *T) report() {
|
|||||||
|
|
||||||
func RunTests(matchString func(pat, str string) (bool, error), tests []InternalTest) (ok bool) {
|
func RunTests(matchString func(pat, str string) (bool, error), tests []InternalTest) (ok bool) {
|
||||||
ok = true
|
ok = true
|
||||||
if len(tests) == 0 {
|
if len(tests) == 0 && !haveExamples {
|
||||||
fmt.Fprintln(os.Stderr, "testing: warning: no tests to run")
|
fmt.Fprintln(os.Stderr, "testing: warning: no tests to run")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user