mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 01:31:17 +00:00
Add -cpu 4 to tests.
This commit is contained in:
20
test/poll.go
Normal file
20
test/poll.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Poll repeatedly evaluates condition until we either timeout, or it suceeds.
|
||||
func Poll(t *testing.T, d time.Duration, condition func() bool, msg string) {
|
||||
deadline := time.Now().Add(d)
|
||||
for {
|
||||
if time.Now().After(deadline) {
|
||||
t.Fatal(msg)
|
||||
}
|
||||
if condition() {
|
||||
return
|
||||
}
|
||||
time.Sleep(d / 10)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user