ditch RunWithTimeout test helper
It breaks stack traces on failure. We can just rely on running `go test -timeout ...` instead, which we already do in tools/test.
This commit is contained in:
1 parent
0ef57a102f
commit
1374e4c4de
4 files changed
+1
-40
No files matched your search
@@ -6,7 +6,6 @@ import (
|
||||
"reflect"
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -36,22 +35,6 @@ func stackTrace(all bool) string {
|
||||
return string(buf[:stacklen])
|
||||
}
|
||||
|
||||
// Borrowed from net/http tests:
|
||||
// goTimeout runs f, failing t if f takes more than d to complete.
|
||||
func RunWithTimeout(t *testing.T, d time.Duration, f func()) {
|
||||
ch := make(chan bool, 2)
|
||||
timer := time.AfterFunc(d, func() {
|
||||
t.Errorf("Timeout expired after %v: stacks:\n%s", d, stackTrace(true))
|
||||
ch <- true
|
||||
})
|
||||
defer timer.Stop()
|
||||
go func() {
|
||||
defer func() { ch <- true }()
|
||||
f()
|
||||
}()
|
||||
<-ch
|
||||
}
|
||||
|
||||
// TrimTestArgs finds the first -- in os.Args and trim all args before that
|
||||
func TrimTestArgs() {
|
||||
i, l := 0, len(os.Args)
|
||||
|
||||
Reference in new issue
Block a user