mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
d05f31a3c5
commit
c9b018918d
1 changed files with 7 additions and 0 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue