diff options
| author | Daniel Martà <mvdan@mvdan.cc> | 2017-08-09 16:56:08 +0900 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2017-08-25 22:47:57 +0000 |
| commit | 86dde2debbab6dec105e0bf74ef74d7220974dde (patch) | |
| tree | 25ac2691f260f4740dbffa4ce21fc759dde2dc79 /src/testing/testing.go | |
| parent | 7e455b628c2d9f2286270238fbd2b1ab38643a2a (diff) | |
| download | go-86dde2debbab6dec105e0bf74ef74d7220974dde.tar.xz | |
testing: error if -parallel is given N<1
Otherwise, if there are any parallel tests, it will hang and panic with
"all goroutines are asleep - deadlock!".
Do not use flag.Uint to handle the error for us because we also want to
error on N==0, and because it would make setting the default to
GOMAXPROCS(0) more difficult, since it's an int.
Check for it right after flag.Parse, and mimic flag errors by printing
the usage and returning exit code 2.
Fixes #20542.
Change-Id: I0c9d4587f83d406a8f5e42ed74e40be46d639ffb
Reviewed-on: https://go-review.googlesource.com/54150
Run-TryBot: Daniel Martà <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/testing/testing.go')
| -rw-r--r-- | src/testing/testing.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/testing/testing.go b/src/testing/testing.go index 53283796f8..8b4bfc31a8 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -913,6 +913,12 @@ func (m *M) Run() int { flag.Parse() } + if *parallel < 1 { + fmt.Fprintln(os.Stderr, "testing: -parallel can only be given a positive integer") + flag.Usage() + return 2 + } + if len(*matchList) != 0 { listTests(m.deps.MatchString, m.tests, m.benchmarks, m.examples) return 0 |
