diff --git a/cmd/bisync/bisync_test.go b/cmd/bisync/bisync_test.go index ead511beb..f41fdc58d 100644 --- a/cmd/bisync/bisync_test.go +++ b/cmd/bisync/bisync_test.go @@ -1104,26 +1104,31 @@ func (b *bisyncTest) checkPreReqs(ctx context.Context, opt *bisync.Options) (con testSetModtime(b.fs2) } - if b.testCase == "normalization" || b.testCase == "extended_char_paths" || b.testCase == "extended_filenames" { + if b.testCase == "normalization" || b.testCase == "extended_filenames" { // test whether remote is capable of running test const chars = "ě{chr:81}{chr:fe}{spc}áñhࢺ_測試Рускийěáñ👸🏼🧝🏾‍♀️💆🏿‍♂️🐨🤙🏼🤮🧑🏻‍🔧🧑‍🔬éö" testfilename1 := splitLine(norm.NFD.String(norm.NFC.String(chars)))[0] testfilename2 := splitLine(norm.NFC.String(norm.NFD.String(chars)))[0] tempDir, err := cache.Get(ctx, b.tempDir) require.NoError(b.t, err) + ctx := accounting.WithStatsGroup(ctx, random.String(8)) // keep stats separate preTest := func(f fs.Fs, testfilename string) string { + // the path roots already hold the scenario's files, so probe in a fresh dir + dir := "pretest-" + strings.ToLower(random.String(8)) in := bytes.NewBufferString(testfilename) - objinfo := object.NewStaticObjectInfo(testfilename, initDate, int64(len(testfilename)), true, nil, nil) + objinfo := object.NewStaticObjectInfo(path.Join(dir, testfilename), initDate, int64(len(testfilename)), true, nil, nil) obj, err := f.Put(ctx, in, objinfo) if err != nil { b.t.Skipf("Fs is incapable of running test, skipping: %s (expected: \n%s (%s) actual: \n%s (%v))\n (fs: %s) \n", b.testCase, testfilename, detectEncoding(testfilename), "upload failed", err, f) } - entries, err := f.List(ctx, "") - assert.NoError(b.t, err) - if entries.Len() == 1 && entries[0].Remote() != testfilename { - diffStr, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{A: []string{testfilename}, B: []string{entries[0].Remote()}}) + entries, err := f.List(ctx, dir) + require.NoError(b.t, err) + require.Equal(b.t, 1, entries.Len()) + got := path.Base(entries[0].Remote()) + if got != testfilename { + diffStr, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{A: []string{testfilename}, B: []string{got}}) // we can still deal with this as long as both remotes auto-convert the same way. - b.t.Logf("Warning: this remote seems to auto-convert special characters (testcase: %s) (expected: \n%s (%s) actual: \n%s (%s))\n (fs: %s) \n%v", b.testCase, testfilename, detectEncoding(testfilename), entries[0].Remote(), detectEncoding(entries[0].Remote()), f, diffStr) + b.t.Logf("Warning: this remote seems to auto-convert special characters (testcase: %s) (expected: \n%s (%s) actual: \n%s (%s))\n (fs: %s) \n%v", b.testCase, testfilename, detectEncoding(testfilename), got, detectEncoding(got), f, diffStr) } // test whether we can fix-case ctxFixCase, ci := fs.AddConfig(ctx) @@ -1140,7 +1145,12 @@ func (b *bisyncTest) checkPreReqs(ctx context.Context, opt *bisync.Options) (con if obj != nil { require.NoError(b.t, upperObj.Remove(ctx)) } - return entries[0].Remote() + for _, d := range []fs.Fs{f, tempDir} { + if err := d.Rmdir(ctx, dir); err != nil && !errors.Is(err, fs.ErrorDirNotFound) { + require.NoError(b.t, err) + } + } + return got } got1 := preTest(b.fs1, testfilename1) got1 += preTest(b.fs1, testfilename2) diff --git a/cmd/bisync/testdata/test_extended_filenames/golden/test.log b/cmd/bisync/testdata/test_extended_filenames/golden/test.log index eda13848c..aaa1d5ec1 100644 --- a/cmd/bisync/testdata/test_extended_filenames/golden/test.log +++ b/cmd/bisync/testdata/test_extended_filenames/golden/test.log @@ -25,7 +25,9 @@ INFO : Bisyncing with Comparison Settings: INFO : Synching Path1 "{path1/}" with Path2 "{path2/}" INFO : Copying Path2 files to Path1 INFO : - Path2 Resync is copying files to - Path1 +INFO : There was nothing to transfer INFO : - Path1 Resync is copying files to - Path2 +INFO : There was nothing to transfer INFO : Resync updating listings INFO : Validating listings for Path1 "{path1/}" vs Path2 "{path2/}" INFO : Bisync successful diff --git a/cmd/bisync/testdata/test_normalization/golden/test.log b/cmd/bisync/testdata/test_normalization/golden/test.log index aea5f4161..ef40e7c0e 100644 --- a/cmd/bisync/testdata/test_normalization/golden/test.log +++ b/cmd/bisync/testdata/test_normalization/golden/test.log @@ -17,6 +17,7 @@ INFO : Bisyncing with Comparison Settings: INFO : Synching Path1 "{path1/}" with Path2 "{path2/}" INFO : Copying Path2 files to Path1 INFO : - Path2 Resync is copying files to - Path1 +INFO : There was nothing to transfer INFO : - Path1 Resync is copying files to - Path2 INFO : Resync updating listings INFO : Validating listings for Path1 "{path1/}" vs Path2 "{path2/}" @@ -150,6 +151,7 @@ INFO : - Path2 Queue copy to Path1 - { INFO : - Path1 Queue copy to Path2 - "{path2/}測試_Руский___ě_áñ👸🏼🧝🏾\u200d♀️💆🏿\u200d♂️🐨🤙🏼🤮🧑🏻\u200d🔧🧑\u200d🔬éö/測試_Руский___ě_áñ👸🏼🧝🏾\u200d♀️💆🏿\u200d♂️🐨🤙🏼🤮🧑🏻\u200d🔧🧑\u200d🔬éö.txt" INFO : - Path2 Queue copy to Path1 - {path1/}file1.txt INFO : - Path2 Do queued copies to - Path1 +INFO : There was nothing to transfer INFO : - Path1 Do queued copies to - Path2 INFO : Updating listings INFO : Validating listings for Path1 "{path1/}" vs Path2 "{path2/}" @@ -170,7 +172,9 @@ INFO : Bisyncing with Comparison Settings: INFO : Synching Path1 "{path1/}" with Path2 "{path2/}" INFO : Copying Path2 files to Path1 INFO : - Path2 Resync is copying files to - Path1 +INFO : There was nothing to transfer INFO : - Path1 Resync is copying files to - Path2 +INFO : There was nothing to transfer INFO : Resync updating listings INFO : Validating listings for Path1 "{path1/}" vs Path2 "{path2/}" INFO : Bisync successful @@ -209,7 +213,9 @@ INFO : - Path1 Queue copy to Path2 - { INFO : - Path1 Queue copy to Path2 - "{path2/}測試_Руский___ě_áñ👸🏼🧝🏾\u200d♀️💆🏿\u200d♂️🐨🤙🏼🤮🧑🏻\u200d🔧🧑\u200d🔬éö/測試_Руский___ě_áñ👸🏼🧝🏾\u200d♀️💆🏿\u200d♂️🐨🤙🏼🤮🧑🏻\u200d🔧🧑\u200d🔬éö.txt" INFO : - Path2 Queue copy to Path1 - {path1/}file1.txt INFO : - Path2 Do queued copies to - Path1 +INFO : There was nothing to transfer INFO : - Path1 Do queued copies to - Path2 +INFO : There was nothing to transfer INFO : Updating listings INFO : Validating listings for Path1 "{path1/}" vs Path2 "{path2/}" INFO : Bisync successful