The go test flag -skip had no effect in example tests.
Fixes #61482
Change-Id: I28dfddb88fef3fead2a3c74f9cb63a674a768231
GitHub-Last-Rev:
e8c3c3460af906f4c7be7f7a8b4a4c60b71fcec1
GitHub-Pull-Request: golang/go#61491
Reviewed-on: https://go-review.googlesource.com/c/go/+/511837
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
go test -v -skip 2/3 skip_test.go
stdout RUN.*Test1
stdout RUN.*Test2
+stdout RUN.*ExampleTest1
! stdout Test2/3
go test -v -skip 2/4 skip_test.go
stdout RUN.*Test1
stdout RUN.*Test2
stdout RUN.*Test2/3
+stdout RUN.*ExampleTest1
+go test -v -skip Example skip_test.go
+stdout RUN.*Test1
+stdout RUN.*Test2
+stdout RUN.*Test2/3
-- skip_test.go --
package skip_test
func Test2(t *testing.T) {
t.Run("3", func(t *testing.T) {})
}
+
+func ExampleTest1() {
+ // Output:
+}
import (
"fmt"
- "os"
"sort"
"strings"
"time"
func runExamples(matchString func(pat, str string) (bool, error), examples []InternalExample) (ran, ok bool) {
ok = true
- var eg InternalExample
+ m := newMatcher(matchString, *match, "-test.run", *skip)
+ var eg InternalExample
for _, eg = range examples {
- matched, err := matchString(*match, eg.Name)
- if err != nil {
- fmt.Fprintf(os.Stderr, "testing: invalid regexp for -test.run: %s\n", err)
- os.Exit(1)
- }
+ _, matched, _ := m.fullName(nil, eg.Name)
if !matched {
continue
}