Commit ab4e7988 authored by Shenghou Ma's avatar Shenghou Ma Committed by Minux Ma

cmd/dist: add -k to "dist test" to keep going after error

Fixes #10336.

Change-Id: Idc3f60851aea590575dc293165d4d6f85ae001bc
Reviewed-on: https://go-review.googlesource.com/9645Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 6e8bcbbe
...@@ -24,6 +24,7 @@ func cmdtest() { ...@@ -24,6 +24,7 @@ func cmdtest() {
var t tester var t tester
flag.BoolVar(&t.listMode, "list", false, "list available tests") flag.BoolVar(&t.listMode, "list", false, "list available tests")
flag.BoolVar(&t.noRebuild, "no-rebuild", false, "don't rebuild std and cmd packages") flag.BoolVar(&t.noRebuild, "no-rebuild", false, "don't rebuild std and cmd packages")
flag.BoolVar(&t.keepGoing, "k", false, "keep going even when error occurred")
flag.StringVar(&t.banner, "banner", "##### ", "banner prefix; blank means no section banners") flag.StringVar(&t.banner, "banner", "##### ", "banner prefix; blank means no section banners")
flag.StringVar(&t.runRxStr, "run", os.Getenv("GOTESTONLY"), flag.StringVar(&t.runRxStr, "run", os.Getenv("GOTESTONLY"),
"run only those tests matching the regular expression; empty means to run all. "+ "run only those tests matching the regular expression; empty means to run all. "+
...@@ -36,6 +37,7 @@ func cmdtest() { ...@@ -36,6 +37,7 @@ func cmdtest() {
type tester struct { type tester struct {
listMode bool listMode bool
noRebuild bool noRebuild bool
keepGoing bool
runRxStr string runRxStr string
runRx *regexp.Regexp runRx *regexp.Regexp
runRxWant bool runRxWant bool
...@@ -163,6 +165,7 @@ func (t *tester) run() { ...@@ -163,6 +165,7 @@ func (t *tester) run() {
os.Unsetenv("GOROOT_FINAL") os.Unsetenv("GOROOT_FINAL")
var lastHeading string var lastHeading string
ok := true
for _, dt := range t.tests { for _, dt := range t.tests {
if t.runRx != nil && (t.runRx.MatchString(dt.name) != t.runRxWant) { if t.runRx != nil && (t.runRx.MatchString(dt.name) != t.runRxWant) {
t.partial = true t.partial = true
...@@ -176,10 +179,18 @@ func (t *tester) run() { ...@@ -176,10 +179,18 @@ func (t *tester) run() {
fmt.Printf("# go tool dist test -run=^%s$\n", dt.name) fmt.Printf("# go tool dist test -run=^%s$\n", dt.name)
} }
if err := dt.fn(); err != nil { if err := dt.fn(); err != nil {
ok = false
if t.keepGoing {
log.Printf("Failed: %v", err)
} else {
log.Fatalf("Failed: %v", err) log.Fatalf("Failed: %v", err)
} }
} }
if t.partial { }
if !ok {
fmt.Println("\nFAILED")
os.Exit(1)
} else if t.partial {
fmt.Println("\nALL TESTS PASSED (some were excluded)") fmt.Println("\nALL TESTS PASSED (some were excluded)")
} else { } else {
fmt.Println("\nALL TESTS PASSED") fmt.Println("\nALL TESTS PASSED")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment