fstest: reduce precision of directory time checks on CI

For unknown reasons the precision of modification times of directories
on the CI is > 15mS compared to files which are 100nS. The tests
work fine when run in Virtualbox though so I conjecture this is
something to do with the file system used there.
This commit is contained in:
Nick Craig-Wood 2024-04-24 11:38:22 +01:00
parent 0bfd70c405
commit bd8523f208
2 changed files with 16 additions and 2 deletions

View file

@ -27,6 +27,7 @@ import (
"github.com/rclone/rclone/fs/config/configfile"
"github.com/rclone/rclone/fs/hash"
"github.com/rclone/rclone/fs/walk"
"github.com/rclone/rclone/fstest/testy"
"github.com/rclone/rclone/lib/random"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -620,7 +621,15 @@ func CheckDirModTime(ctx context.Context, t *testing.T, f fs.Fs, dir fs.Director
return
}
gotT := dir.ModTime(ctx)
AssertTimeEqualWithPrecision(t, dir.Remote(), wantT, gotT, f.Precision())
precision := f.Precision()
// For unknown reasons the precision of modification times of
// directories on the CI is about >15mS. The tests work fine
// when run in Virtualbox though so I conjecture this is
// something to do with the file system used there.
if runtime.GOOS == "windows" && testy.CI() {
precision = 100 * time.Millisecond
}
AssertTimeEqualWithPrecision(t, dir.Remote(), wantT, gotT, precision)
}
// Gz returns a compressed version of its input string

View file

@ -6,9 +6,14 @@ import (
"testing"
)
// CI returns true if we are running on the CI server
func CI() bool {
return os.Getenv("CI") != ""
}
// SkipUnreliable skips this test if running on CI
func SkipUnreliable(t *testing.T) {
if os.Getenv("CI") == "" {
if !CI() {
return
}
t.Skip("Skipping Unreliable Test on CI")