Skip to content

Commit a901d7f

Browse files
committed
cmd/dist: support test filtering via repurposed env variable, negation
For upcoming sharded ARM builders. Updates #10029 Change-Id: I3b1df9560be697c514a8ced0462814d406e23132 Reviewed-on: https://go-review.googlesource.com/10055 Reviewed-by: Ian Lance Taylor <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 1e7f579 commit a901d7f

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/cmd/dist/test.go

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"os/exec"
1515
"path/filepath"
1616
"regexp"
17+
"runtime"
1718
"strconv"
1819
"strings"
1920
"time"
@@ -24,7 +25,9 @@ func cmdtest() {
2425
flag.BoolVar(&t.listMode, "list", false, "list available tests")
2526
flag.BoolVar(&t.noRebuild, "no-rebuild", false, "don't rebuild std and cmd packages")
2627
flag.StringVar(&t.banner, "banner", "##### ", "banner prefix; blank means no section banners")
27-
flag.StringVar(&t.runRxStr, "run", "", "run only those tests matching the regular expression; empty means to run all")
28+
flag.StringVar(&t.runRxStr, "run", os.Getenv("GOTESTONLY"),
29+
"run only those tests matching the regular expression; empty means to run all. "+
30+
"Special exception: if the string begins with '!', the match is inverted.")
2831
xflagparse(0)
2932
t.run()
3033
}
@@ -35,6 +38,7 @@ type tester struct {
3538
noRebuild bool
3639
runRxStr string
3740
runRx *regexp.Regexp
41+
runRxWant bool
3842
banner string // prefix, or "" for none
3943

4044
goroot string
@@ -129,6 +133,19 @@ func (t *tester) run() {
129133
}
130134

131135
if t.runRxStr != "" {
136+
// Temporary (2015-05-14) special case for "std",
137+
// which the plan9 builder was using for ages. Delete
138+
// this once we update dashboard/builders.go to use a
139+
// regexp instead.
140+
if runtime.GOOS == "plan9" && t.runRxStr == "std" {
141+
t.runRxStr = "^go_test:"
142+
}
143+
if t.runRxStr[0] == '!' {
144+
t.runRxWant = false
145+
t.runRxStr = t.runRxStr[1:]
146+
} else {
147+
t.runRxWant = true
148+
}
132149
t.runRx = regexp.MustCompile(t.runRxStr)
133150
}
134151

@@ -147,7 +164,7 @@ func (t *tester) run() {
147164

148165
var lastHeading string
149166
for _, dt := range t.tests {
150-
if t.runRx != nil && !t.runRx.MatchString(dt.name) {
167+
if t.runRx != nil && (t.runRx.MatchString(dt.name) != t.runRxWant) {
151168
t.partial = true
152169
continue
153170
}
@@ -214,13 +231,6 @@ func (t *tester) registerTests() {
214231
})
215232
}
216233

217-
// Old hack for when Plan 9 on GCE was too slow.
218-
// We're keeping this until test sharding (Issue 10029) is finished, though.
219-
if os.Getenv("GOTESTONLY") == "std" {
220-
t.partial = true
221-
return
222-
}
223-
224234
// Runtime CPU tests.
225235
testName := "runtime:cpu124"
226236
t.tests = append(t.tests, distTest{

0 commit comments

Comments
 (0)