// Parallel signals that this test is to be run in parallel with (and only with)
// other parallel tests.
func (t *T) Parallel() {
+ // We don't want to include the time we spend waiting for serial tests
+ // in the test duration. Record the elapsed time thus far and reset the
+ // timer afterwards.
+ t.duration += time.Since(t.start)
t.signal <- (*T)(nil) // Release main testing loop
<-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()
}
// a call to runtime.Goexit, record the duration and send
// a signal saying that the test is done.
defer func() {
- t.duration = time.Now().Sub(t.start)
+ t.duration += time.Now().Sub(t.start)
// If the test panicked, print any test output before dying.
err := recover()
if !t.finished && err == nil {