mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 08:23:47 +01:00
bisync: allow blank hashes on tests
Some backends support hashes but allow them to be blank. In other words, we can't expect them to be reliably non-blank, and we shouldn't treat a blank hash as an error. Before this change, the bisync integration tests errored if a backend said it supported hashes but in fact sometimes lacked them. After this change, such errors are ignored.
This commit is contained in:
parent
3c7ad8d961
commit
11ad2a1316
@ -15,6 +15,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -216,6 +217,7 @@ type bisyncTest struct {
|
|||||||
stopAt int
|
stopAt int
|
||||||
TestFn bisync.TestFunc
|
TestFn bisync.TestFunc
|
||||||
ignoreModtime bool // ignore modtimes when comparing final listings, for backends without support
|
ignoreModtime bool // ignore modtimes when comparing final listings, for backends without support
|
||||||
|
ignoreBlankHash bool // ignore blank hashes for backends where we allow them to be blank
|
||||||
}
|
}
|
||||||
|
|
||||||
var color = bisync.Color
|
var color = bisync.Color
|
||||||
@ -946,6 +948,10 @@ func (b *bisyncTest) checkPreReqs(ctx context.Context, opt *bisync.Options) (con
|
|||||||
if (!b.fs1.Features().CanHaveEmptyDirectories || !b.fs2.Features().CanHaveEmptyDirectories) && (b.testCase == "createemptysrcdirs" || b.testCase == "rmdirs") {
|
if (!b.fs1.Features().CanHaveEmptyDirectories || !b.fs2.Features().CanHaveEmptyDirectories) && (b.testCase == "createemptysrcdirs" || b.testCase == "rmdirs") {
|
||||||
b.t.Skip("skipping test as remote does not support empty dirs")
|
b.t.Skip("skipping test as remote does not support empty dirs")
|
||||||
}
|
}
|
||||||
|
ignoreHashBackends := []string{"TestWebdavNextcloud", "TestWebdavOwncloud", "TestAzureFiles"} // backends that support hashes but allow them to be blank
|
||||||
|
if slices.ContainsFunc(ignoreHashBackends, func(prefix string) bool { return strings.HasPrefix(b.fs1.Name(), prefix) }) || slices.ContainsFunc(ignoreHashBackends, func(prefix string) bool { return strings.HasPrefix(b.fs2.Name(), prefix) }) {
|
||||||
|
b.ignoreBlankHash = true
|
||||||
|
}
|
||||||
if b.fs1.Precision() == fs.ModTimeNotSupported || b.fs2.Precision() == fs.ModTimeNotSupported {
|
if b.fs1.Precision() == fs.ModTimeNotSupported || b.fs2.Precision() == fs.ModTimeNotSupported {
|
||||||
if b.testCase != "nomodtime" {
|
if b.testCase != "nomodtime" {
|
||||||
b.t.Skip("skipping test as at least one remote does not support setting modtime")
|
b.t.Skip("skipping test as at least one remote does not support setting modtime")
|
||||||
@ -1551,6 +1557,12 @@ func (b *bisyncTest) mangleResult(dir, file string, golden bool) string {
|
|||||||
if b.fs1.Hashes() == hash.Set(hash.None) || b.fs2.Hashes() == hash.Set(hash.None) {
|
if b.fs1.Hashes() == hash.Set(hash.None) || b.fs2.Hashes() == hash.Set(hash.None) {
|
||||||
logReplacements = append(logReplacements, `^.*{hashtype} differ.*$`, dropMe)
|
logReplacements = append(logReplacements, `^.*{hashtype} differ.*$`, dropMe)
|
||||||
}
|
}
|
||||||
|
if b.ignoreBlankHash {
|
||||||
|
logReplacements = append(logReplacements,
|
||||||
|
`^.*hash is missing.*$`, dropMe,
|
||||||
|
`^.*not equal on recheck.*$`, dropMe,
|
||||||
|
)
|
||||||
|
}
|
||||||
rep := logReplacements
|
rep := logReplacements
|
||||||
if b.testCase == "dry_run" {
|
if b.testCase == "dry_run" {
|
||||||
rep = append(rep, dryrunReplacements...)
|
rep = append(rep, dryrunReplacements...)
|
||||||
|
Loading…
Reference in New Issue
Block a user