1
mirror of https://github.com/rclone/rclone synced 2024-12-25 17:03:45 +01:00

bisync: avoid starting tests we don't have time to finish

To prevent all-or-nothing retries, for tests that take longer (in total) than the
-timeout but less than the -timeout * -maxtries

https://github.com/rclone/rclone/pull/7743#issuecomment-2057250848
This commit is contained in:
nielash 2024-04-17 05:24:41 -04:00 committed by Nick Craig-Wood
parent 58e09e1cd4
commit 8977655869

View File

@ -335,13 +335,23 @@ func testBisync(t *testing.T, path1, path2 string) {
}
}
require.False(t, b.stopAt > 0 && len(testList) > 1, "-stop-at is meaningful only for a single test")
deadline, hasDeadline := t.Deadline()
var maxRunDuration time.Duration
for _, testCase := range testList {
testCase = strings.ReplaceAll(testCase, "-", "_")
testCase = strings.TrimPrefix(testCase, "test_")
t.Run(testCase, func(childTest *testing.T) {
startTime := time.Now()
remaining := time.Until(deadline)
if hasDeadline && (remaining < maxRunDuration || remaining < 10*time.Second) { // avoid starting tests we don't have time to finish
childTest.Fatalf("test %v timed out - not enough time to start test (%v remaining, need %v for test)", testCase, remaining, maxRunDuration)
}
bCopy := *b
bCopy.runTestCase(ctx, childTest, testCase)
if time.Since(startTime) > maxRunDuration {
maxRunDuration = time.Since(startTime)
}
})
}
}