Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

fstest: reduce precision of directory time checks on CI

Nick Craig-Woodbd8523f208b8
diff --git a/fstest/fstest.go b/fstest/fstest.go
index ef4d11418..d29c25422 100644
--- a/fstest/fstest.go
+++ b/fstest/fstest.go
@@ -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
diff --git a/fstest/testy/testy.go b/fstest/testy/testy.go
index ca2d4ebe8..5b73c0139 100644
--- a/fstest/testy/testy.go
+++ b/fstest/testy/testy.go
@@ -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")