mirror of
https://github.com/golang/go.git
synced 2025-10-23 21:13:20 +00:00
cmd/go, testing: indicate when no tests are run
For example, testing the current directory: $ go test -run XXX testing: warning: no tests to run PASS ok testing 0.013s $ And in a summary: $ go test -run XXX testing ok testing 0.013s [no tests to run] $ These make it easy to spot when the -run regexp hasn't matched anything or there are no tests. Previously the message was printed in the "current directory" case when there were no tests at all, but not for no matches, and either way was not surfaced in the directory list summary form. Fixes #15211. Change-Id: I1c82a423d6bd429fb991c9ca964c9d26c96fd3c5 Reviewed-on: https://go-review.googlesource.com/22341 Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
This commit is contained in:
parent
95abb5a36a
commit
ead08e91f6
9 changed files with 194 additions and 17 deletions
|
|
@ -21,7 +21,14 @@ type InternalExample struct {
|
|||
Unordered bool
|
||||
}
|
||||
|
||||
// An internal function but exported because it is cross-package; part of the implementation
|
||||
// of the "go test" command.
|
||||
func RunExamples(matchString func(pat, str string) (bool, error), examples []InternalExample) (ok bool) {
|
||||
_, ok = runExamples(matchString, examples)
|
||||
return ok
|
||||
}
|
||||
|
||||
func runExamples(matchString func(pat, str string) (bool, error), examples []InternalExample) (ran, ok bool) {
|
||||
ok = true
|
||||
|
||||
var eg InternalExample
|
||||
|
|
@ -35,12 +42,13 @@ func RunExamples(matchString func(pat, str string) (bool, error), examples []Int
|
|||
if !matched {
|
||||
continue
|
||||
}
|
||||
ran = true
|
||||
if !runExample(eg) {
|
||||
ok = false
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
return ran, ok
|
||||
}
|
||||
|
||||
func sortLines(output string) string {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue