Commit c9b01891 authored by Ian Lance Taylor's avatar Ian Lance Taylor Committed by Brad Fitzpatrick

testing: exit with error if testing.Short is called before flag.Parse

Change-Id: I2fa547d1074ef0931196066678fadd7250a1148d
Reviewed-on: https://go-review.googlesource.com/121936
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent d05f31a3
......@@ -316,6 +316,13 @@ type common struct {
// Short reports whether the -test.short flag is set.
func Short() bool {
// Catch code that calls this from TestMain without first
// calling flag.Parse. This shouldn't really be a panic
if !flag.Parsed() {
fmt.Fprintf(os.Stderr, "testing: testing.Short called before flag.Parse\n")
os.Exit(2)
}
return *short
}
......
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