go/src/testing
Alberto Bertogli ab196aeff2 testing: only call flag.Parse if it has not been called before
Calling flag.Parse twice can be problematic if other goroutines called
flag.Parsed in between: the race detector complains due to the
write after read from a different goroutine.

This can happen if TestMain calls flag.Parse and launches goroutines
that call flag.Parsed, for example if it initializes a server which
checks flags.

This patch makes testing.M.Run only parse the flags if they have not
been parsed already.

Change-Id: Id9f8c31c5f90614e3f34c63d1a32cf7e9055d68e
Reviewed-on: https://go-review.googlesource.com/16739
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-12 19:48:06 +00:00
..
iotest testing/iotest: fix copy/paste error in comment 2014-12-29 19:05:37 +00:00
quick testing/quick: terminate for arbitrary recursive types 2015-08-29 19:23:37 +00:00
allocs.go
allocs_test.go runtime: account for tiny allocs, for testing.AllocsPerRun 2014-09-17 14:49:32 -04:00
benchmark.go testing: pad benchmark names to align results 2015-02-07 21:52:25 +00:00
benchmark_test.go
cover.go
example.go testing: make the output of -v more uniform and aligned when using fixed-width fonts 2015-05-08 18:38:25 +00:00
export_test.go
testing.go testing: only call flag.Parse if it has not been called before 2015-11-12 19:48:06 +00:00
testing_test.go cmd/go, testing: add TestMain support 2014-09-19 13:51:06 -04:00