aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/testing.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/testing/testing.go b/src/testing/testing.go
index a552b36361..179987b699 100644
--- a/src/testing/testing.go
+++ b/src/testing/testing.go
@@ -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
}