]> Cypherpunks repositories - gostls13.git/commitdiff
testing: improve the documentation for the -run flag
authorRob Pike <r@golang.org>
Mon, 12 Sep 2016 03:17:02 +0000 (13:17 +1000)
committerRob Pike <r@golang.org>
Mon, 12 Sep 2016 06:12:35 +0000 (06:12 +0000)
It's not intuitive, especially in the presence of subtests, so improve the
explanation and extend and explain the examples.

Change-Id: I6c4d3f8944b60b12311d0c0f0a8e952e7c35a9ed
Reviewed-on: https://go-review.googlesource.com/28995
Reviewed-by: Andrew Gerrand <adg@golang.org>
src/testing/testing.go

index e1dbe0011bdea72b5e7f9595d5a74a33bb94b574..4a4cbcc989e2be9d49d6152702b0f8b0005030b6 100644 (file)
 // of the top-level test and the sequence of names passed to Run, separated by
 // slashes, with an optional trailing sequence number for disambiguation.
 //
-// The argument to the -run and -bench command-line flags is a slash-separated
-// list of regular expressions that match each name element in turn.
-// For example:
-//
-//     go test -run Foo     # Run top-level tests matching "Foo".
-//     go test -run Foo/A=  # Run subtests of Foo matching "A=".
-//     go test -run /A=1    # Run all subtests of a top-level test matching "A=1".
+// The argument to the -run and -bench command-line flags is an unanchored regular
+// expression that matches the test's name. For tests with multiple slash-separated
+// elements, such as subtests, the argument is itself slash-separated, with
+// expressions matching each name element in turn. Because it is unanchored, an
+// empty expression matches any string.
+// For example, using "matching" to mean "whose name contains":
+//
+//     go test -run ''      # Run all tests.
+//     go test -run Foo     # Run top-level tests matching "Foo", such as "TestFooBar".
+//     go test -run Foo/A=  # For top-level tests matching "Foo", run subtests matching "A=".
+//     go test -run /A=1    # For all top-level tests, run subtests matching "A=1".
 //
 // Subtests can also be used to control parallelism. A parent test will only
 // complete once all of its subtests complete. In this example, all tests are