1 Star 0 Fork 0

开源参考/scope

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
poll.go 614 Bytes
一键复制 编辑 原始数据 按行查看 历史
Jonathan Lange 提交于 2016-12-07 01:41 +08:00 . Move test & fs
package test
import (
"runtime"
"testing"
"time"
"github.com/weaveworks/common/test"
"github.com/weaveworks/scope/test/reflect"
)
// Poll repeatedly evaluates condition until we either timeout, or it succeeds.
func Poll(t *testing.T, d time.Duration, want interface{}, have func() interface{}) {
deadline := time.Now().Add(d)
for {
if time.Now().After(deadline) {
break
}
if reflect.DeepEqual(want, have()) {
return
}
time.Sleep(d / 10)
}
h := have()
if !reflect.DeepEqual(want, h) {
_, file, line, _ := runtime.Caller(1)
t.Fatalf("%s:%d: %s", file, line, test.Diff(want, h))
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/open_source_reference/scope.git
git@gitee.com:open_source_reference/scope.git
open_source_reference
scope
scope
master

搜索帮助