]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: support test filtering via repurposed env variable, negation
authorBrad Fitzpatrick <bradfitz@golang.org>
Thu, 14 May 2015 20:03:02 +0000 (13:03 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 14 May 2015 20:43:55 +0000 (20:43 +0000)
For upcoming sharded ARM builders.

Updates #10029

Change-Id: I3b1df9560be697c514a8ced0462814d406e23132
Reviewed-on: https://go-review.googlesource.com/10055
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/dist/test.go

index 848790ad2c1ab22a4c289ad885fe0355ac08efa5..addf61dad97071074d50c52c7021a1b835b53fb0 100644 (file)
@@ -14,6 +14,7 @@ import (
        "os/exec"
        "path/filepath"
        "regexp"
+       "runtime"
        "strconv"
        "strings"
        "time"
@@ -24,7 +25,9 @@ func cmdtest() {
        flag.BoolVar(&t.listMode, "list", false, "list available tests")
        flag.BoolVar(&t.noRebuild, "no-rebuild", false, "don't rebuild std and cmd packages")
        flag.StringVar(&t.banner, "banner", "##### ", "banner prefix; blank means no section banners")
-       flag.StringVar(&t.runRxStr, "run", "", "run only those tests matching the regular expression; empty means to run all")
+       flag.StringVar(&t.runRxStr, "run", os.Getenv("GOTESTONLY"),
+               "run only those tests matching the regular expression; empty means to run all. "+
+                       "Special exception: if the string begins with '!', the match is inverted.")
        xflagparse(0)
        t.run()
 }
@@ -35,6 +38,7 @@ type tester struct {
        noRebuild bool
        runRxStr  string
        runRx     *regexp.Regexp
+       runRxWant bool
        banner    string // prefix, or "" for none
 
        goroot     string
@@ -129,6 +133,19 @@ func (t *tester) run() {
        }
 
        if t.runRxStr != "" {
+               // Temporary (2015-05-14) special case for "std",
+               // which the plan9 builder was using for ages. Delete
+               // this once we update dashboard/builders.go to use a
+               // regexp instead.
+               if runtime.GOOS == "plan9" && t.runRxStr == "std" {
+                       t.runRxStr = "^go_test:"
+               }
+               if t.runRxStr[0] == '!' {
+                       t.runRxWant = false
+                       t.runRxStr = t.runRxStr[1:]
+               } else {
+                       t.runRxWant = true
+               }
                t.runRx = regexp.MustCompile(t.runRxStr)
        }
 
@@ -147,7 +164,7 @@ func (t *tester) run() {
 
        var lastHeading string
        for _, dt := range t.tests {
-               if t.runRx != nil && !t.runRx.MatchString(dt.name) {
+               if t.runRx != nil && (t.runRx.MatchString(dt.name) != t.runRxWant) {
                        t.partial = true
                        continue
                }
@@ -214,13 +231,6 @@ func (t *tester) registerTests() {
                })
        }
 
-       // Old hack for when Plan 9 on GCE was too slow.
-       // We're keeping this until test sharding (Issue 10029) is finished, though.
-       if os.Getenv("GOTESTONLY") == "std" {
-               t.partial = true
-               return
-       }
-
        // Runtime CPU tests.
        testName := "runtime:cpu124"
        t.tests = append(t.tests, distTest{