-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Milestone
Description
package main
import (
"testing"
"time"
)
func TestOne(t *testing.T) {
tt(t)
}
func TestTwo(t *testing.T) {
tt(t)
}
func TestThree(t *testing.T) {
tt(t)
}
func tt(t *testing.T) {
t.Parallel()
time.Sleep(time.Second)
}
$ go test -timeout=1s -v
=== RUN TestOne
=== RUN TestTwo
=== RUN TestThree
--- PASS: TestThree (1.00s)
--- PASS: TestTwo (1.00s)
--- PASS: TestOne (1.00s)
PASS
ok github.com/broady/testtimeout 1.010s
$ go test -timeout=1s -parallel=1 -v
=== RUN TestOne
=== RUN TestTwo
=== RUN TestThree
panic: test timed out after 1s
<snip>
exit status 2
FAIL github.com/broady/testtimeout 1.016s
It looks like the test runner "starts" the timer for the tests even though the test code doesn't start executing. This results in a faulty test timeout.
go version devel +edb19aa Fri Mar 25 18:35:15 2016 +0000 linux/amd64
Reactions are currently unavailable