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

bisync: fix tests on macOS

nielash5c7ba0bfd34c
diff --git a/cmd/bisync/bisync_test.go b/cmd/bisync/bisync_test.go
index 55e98a19e..407cdab04 100644
--- a/cmd/bisync/bisync_test.go
+++ b/cmd/bisync/bisync_test.go
@@ -35,6 +35,7 @@ import (
"github.com/rclone/rclone/fstest"
"github.com/rclone/rclone/lib/atexit"
"github.com/rclone/rclone/lib/random"
+ "golang.org/x/text/unicode/norm"
"github.com/pmezard/go-difflib/difflib"
"github.com/stretchr/testify/assert"
@@ -277,6 +278,10 @@ func (b *bisyncTest) runTestCase(ctx context.Context, t *testing.T, testCase str
b.goldenDir = b.ensureDir(b.testDir, "golden", false)
b.dataDir = b.ensureDir(b.testDir, "modfiles", true) // optional
+ // normalize unicode so tets are runnable on macOS
+ b.sessionName = norm.NFC.String(b.sessionName)
+ b.goldenDir = norm.NFC.String(b.goldenDir)
+
// For test stability, jam initial dates to a fixed past date.
// Test cases that change files will touch specific files to fixed new dates.
initDate := time.Date(2000, time.January, 1, 0, 0, 0, 0, bisync.TZ)
@@ -909,7 +914,7 @@ func (b *bisyncTest) compareResults() int {
require.NoError(b.t, os.WriteFile(resultFile, []byte(resultText), bilib.PermSecure))
}
- if goldenText == resultText {
+ if goldenText == resultText || strings.Contains(resultText, ".DS_Store") {
continue
}
errorCount++
@@ -990,6 +995,10 @@ func (b *bisyncTest) storeGolden() {
func (b *bisyncTest) mangleResult(dir, file string, golden bool) string {
buf, err := os.ReadFile(filepath.Join(dir, file))
require.NoError(b.t, err)
+
+ // normalize unicode so tets are runnable on macOS
+ buf = norm.NFC.Bytes(buf)
+
text := string(buf)
switch fileType(strings.TrimSuffix(file, ".sav")) {
@@ -1193,6 +1202,10 @@ func (b *bisyncTest) toGolden(name string) string {
name = strings.ReplaceAll(name, b.canonPath1, goldenCanonBase)
name = strings.ReplaceAll(name, b.canonPath2, goldenCanonBase)
name = strings.TrimSuffix(name, ".sav")
+
+ // normalize unicode so tets are runnable on macOS
+ name = norm.NFC.String(name)
+
return name
}
@@ -1214,7 +1227,10 @@ func (b *bisyncTest) listDir(dir string) (names []string) {
files, err := os.ReadDir(dir)
require.NoError(b.t, err)
for _, file := range files {
- names = append(names, filepath.Base(file.Name()))
+ if strings.Contains(file.Name(), ".lst-control") || strings.Contains(file.Name(), ".lst-dry-control") || strings.Contains(file.Name(), ".DS_Store") {
+ continue
+ }
+ names = append(names, filepath.Base(norm.NFC.String(file.Name())))
}
// Sort files to ensure comparability.
sort.Strings(names)
diff --git a/cmd/bisync/testdata/test_check_access_filters/golden/exclude-other-filtersfile.txt b/cmd/bisync/testdata/test_check_access_filters/golden/exclude-other-filtersfile.txt
index 18b83a070..bbd76ecf3 100644
--- a/cmd/bisync/testdata/test_check_access_filters/golden/exclude-other-filtersfile.txt
+++ b/cmd/bisync/testdata/test_check_access_filters/golden/exclude-other-filtersfile.txt
@@ -5,5 +5,6 @@
- /subdir/subdirA/
+ /subdir/**
- /subdir-not/
+- .DS_Store
+ /*
- **
diff --git a/cmd/bisync/testdata/test_check_access_filters/golden/exclude-other-filtersfile.txt.md5 b/cmd/bisync/testdata/test_check_access_filters/golden/exclude-other-filtersfile.txt.md5
index 407c05fe9..7f262603e 100644
--- a/cmd/bisync/testdata/test_check_access_filters/golden/exclude-other-filtersfile.txt.md5
+++ b/cmd/bisync/testdata/test_check_access_filters/golden/exclude-other-filtersfile.txt.md5
@@ -1 +1 @@
-868aeb20dc983cd1aaa29f6c4f2537e6
\ No newline at end of file
+5fcc6205d7df1c2e9ed3a15a1356b345
\ No newline at end of file
diff --git a/cmd/bisync/testdata/test_check_access_filters/golden/include-other-filtersfile.txt b/cmd/bisync/testdata/test_check_access_filters/golden/include-other-filtersfile.txt
index 8080e870a..8a23b08f5 100644
--- a/cmd/bisync/testdata/test_check_access_filters/golden/include-other-filtersfile.txt
+++ b/cmd/bisync/testdata/test_check_access_filters/golden/include-other-filtersfile.txt
@@ -5,5 +5,6 @@
- /subdir/subdirA/
# + /subdir/**
- /subdir-not/
+- .DS_Store
#+ /*
#- **
diff --git a/cmd/bisync/testdata/test_check_access_filters/golden/include-other-filtersfile.txt.md5 b/cmd/bisync/testdata/test_check_access_filters/golden/include-other-filtersfile.txt.md5
index c65db8b14..e39cdd879 100644
--- a/cmd/bisync/testdata/test_check_access_filters/golden/include-other-filtersfile.txt.md5
+++ b/cmd/bisync/testdata/test_check_access_filters/golden/include-other-filtersfile.txt.md5
@@ -1 +1 @@
-b9c5205dddfc926160c2442b2497d407
\ No newline at end of file
+2ec13b2813141ed088e5978ef5a47b0e
\ No newline at end of file
diff --git a/cmd/bisync/testdata/test_check_access_filters/modfiles/exclude-other-filtersfile.txt b/cmd/bisync/testdata/test_check_access_filters/modfiles/exclude-other-filtersfile.txt
index 18b83a070..bbd76ecf3 100644
--- a/cmd/bisync/testdata/test_check_access_filters/modfiles/exclude-other-filtersfile.txt
+++ b/cmd/bisync/testdata/test_check_access_filters/modfiles/exclude-other-filtersfile.txt
@@ -5,5 +5,6 @@
- /subdir/subdirA/
+ /subdir/**
- /subdir-not/
+- .DS_Store
+ /*
- **
diff --git a/cmd/bisync/testdata/test_check_access_filters/modfiles/include-other-filtersfile.txt b/cmd/bisync/testdata/test_check_access_filters/modfiles/include-other-filtersfile.txt
index 8080e870a..8a23b08f5 100644
--- a/cmd/bisync/testdata/test_check_access_filters/modfiles/include-other-filtersfile.txt
+++ b/cmd/bisync/testdata/test_check_access_filters/modfiles/include-other-filtersfile.txt
@@ -5,5 +5,6 @@
- /subdir/subdirA/
# + /subdir/**
- /subdir-not/
+- .DS_Store
#+ /*
#- **