aboutsummaryrefslogtreecommitdiff
path: root/src/testing/example.go
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>2016-04-20 14:29:30 -0300
committerRuss Cox <rsc@golang.org>2016-10-19 02:34:44 +0000
commitead08e91f6468ab1c35c250ec487935103c580f6 (patch)
tree6d9c2630e8ed00379d543aef06dc2d57f4355194 /src/testing/example.go
parent95abb5a36aa1a727db512772f632ecaf05df34aa (diff)
downloadgo-ead08e91f6468ab1c35c250ec487935103c580f6.tar.xz
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>
Diffstat (limited to 'src/testing/example.go')
-rw-r--r--src/testing/example.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/testing/example.go b/src/testing/example.go
index fd8343f3bf..e5bce7af4e 100644
--- a/src/testing/example.go
+++ b/src/testing/example.go
@@ -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 {