mirror of
https://github.com/golang/go
synced 2024-11-18 10:14:45 -07:00
cmd/dist: add -k to "dist test" to keep going after error
Fixes #10336. Change-Id: Idc3f60851aea590575dc293165d4d6f85ae001bc Reviewed-on: https://go-review.googlesource.com/9645 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
6e8bcbbe89
commit
ab4e7988bb
13
src/cmd/dist/test.go
vendored
13
src/cmd/dist/test.go
vendored
@ -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() {
|
|||||||
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() {
|
|||||||
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() {
|
|||||||
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")
|
||||||
|
Loading…
Reference in New Issue
Block a user