mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
testing: don't start timing a Parallel test until it's actually starting
Fixes #5285. R=golang-dev, dvyukov CC=golang-dev https://golang.org/cl/13045044
This commit is contained in:
parent
43a39bfd7f
commit
6fb9cc1f63
1 changed files with 4 additions and 2 deletions
|
|
@ -357,6 +357,9 @@ func (c *common) Skipped() bool {
|
||||||
func (t *T) Parallel() {
|
func (t *T) Parallel() {
|
||||||
t.signal <- (*T)(nil) // Release main testing loop
|
t.signal <- (*T)(nil) // Release main testing loop
|
||||||
<-t.startParallel // Wait for serial tests to finish
|
<-t.startParallel // Wait for serial tests to finish
|
||||||
|
// Assuming Parallel is the first thing a test does, which is reasonable,
|
||||||
|
// reinitialize the test's start time because it's actually starting now.
|
||||||
|
t.start = time.Now()
|
||||||
}
|
}
|
||||||
|
|
||||||
// An internal type but exported because it is cross-package; part of the implementation
|
// An internal type but exported because it is cross-package; part of the implementation
|
||||||
|
|
@ -367,8 +370,6 @@ type InternalTest struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func tRunner(t *T, test *InternalTest) {
|
func tRunner(t *T, test *InternalTest) {
|
||||||
t.start = time.Now()
|
|
||||||
|
|
||||||
// When this goroutine is done, either because test.F(t)
|
// When this goroutine is done, either because test.F(t)
|
||||||
// returned normally or because a test failure triggered
|
// returned normally or because a test failure triggered
|
||||||
// a call to runtime.Goexit, record the duration and send
|
// a call to runtime.Goexit, record the duration and send
|
||||||
|
|
@ -384,6 +385,7 @@ func tRunner(t *T, test *InternalTest) {
|
||||||
t.signal <- t
|
t.signal <- t
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
t.start = time.Now()
|
||||||
test.F(t)
|
test.F(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue