Skip to content

Commit

Permalink
fstest: reduce precision of directory time checks on CI
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ncw committed May 3, 2024
1 parent 0bfd70c commit bd8523f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 10 additions & 1 deletion fstest/fstest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion fstest/testy/testy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit bd8523f

Please sign in to comment.