Ensure that time has passed between foo0 and foo1
On Windows, the resolution of time.Now() can be surprisingly low: 15ms according to the comments in the source of time.Now(). Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>v0.8
parent
594ebbfac0
commit
f4393eaa31
|
@ -39,5 +39,5 @@ jobs:
|
|||
- name: Unit test
|
||||
env:
|
||||
SKIP_INTEGRATION_TESTS: 1
|
||||
run: go test -mod=vendor -v ./cache/... ./client/... ./frontend/dockerfile/... ./session/... ./source/... ./util/...
|
||||
run: go test -mod=vendor -v ./cache/... ./client/... ./frontend/dockerfile/... ./session/... ./solver/... ./source/... ./util/...
|
||||
working-directory: src/github.com/moby/buildkit
|
||||
|
|
|
@ -37,12 +37,20 @@ func runStorageTest(t *testing.T, fn func(t *testing.T, st solver.CacheKeyStorag
|
|||
|
||||
func testResults(t *testing.T, st solver.CacheKeyStorage) {
|
||||
t.Parallel()
|
||||
timeNow := time.Now()
|
||||
err := st.AddResult("foo", solver.CacheResult{
|
||||
ID: "foo0",
|
||||
CreatedAt: time.Now(),
|
||||
CreatedAt: timeNow,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
// Windows time.Now() resolution can be quite coarse, so frequently
|
||||
// time.Now() will be the same between two nearby calls.
|
||||
if time.Now() == timeNow {
|
||||
time.Sleep(time.Duration(100) * time.Millisecond)
|
||||
}
|
||||
require.NotEqual(t, timeNow, time.Now(), "time has stopped")
|
||||
|
||||
err = st.AddResult("foo", solver.CacheResult{
|
||||
ID: "foo1",
|
||||
CreatedAt: time.Now(),
|
||||
|
@ -67,7 +75,7 @@ func testResults(t *testing.T, st solver.CacheKeyStorage) {
|
|||
require.True(t, ok)
|
||||
f1, ok := m["foo1"]
|
||||
require.True(t, ok)
|
||||
require.True(t, f0.CreatedAt.Before(f1.CreatedAt))
|
||||
require.True(t, f0.CreatedAt.Before(f1.CreatedAt), "f0.CreatedAt %v was not Before f1.CreatedAt %v", f0.CreatedAt, f1.CreatedAt)
|
||||
|
||||
m = map[string]solver.CacheResult{}
|
||||
err = st.WalkResults("bar", func(r solver.CacheResult) error {
|
||||
|
|
Loading…
Reference in New Issue