Skip to content

Commit f39ba34

Browse files
committed
testing: enforce -skip and -run in example tests
The go test flags -skip and -run had no effect in example tests. Fixes #61482
1 parent 7c1157f commit f39ba34

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/testing/example.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package testing
66

77
import (
88
"fmt"
9-
"os"
109
"sort"
1110
"strings"
1211
"time"
@@ -29,14 +28,11 @@ func RunExamples(matchString func(pat, str string) (bool, error), examples []Int
2928
func runExamples(matchString func(pat, str string) (bool, error), examples []InternalExample) (ran, ok bool) {
3029
ok = true
3130

32-
var eg InternalExample
31+
m := newMatcher(matchString, *match, "-test.run", *skip)
3332

33+
var eg InternalExample
3434
for _, eg = range examples {
35-
matched, err := matchString(*match, eg.Name)
36-
if err != nil {
37-
fmt.Fprintf(os.Stderr, "testing: invalid regexp for -test.run: %s\n", err)
38-
os.Exit(1)
39-
}
35+
_, matched, _ := m.fullName(nil, eg.Name)
4036
if !matched {
4137
continue
4238
}

0 commit comments

Comments
 (0)