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

fstest: remove WinPath as it is no longer needed

Nick Craig-Wood7e738c9d71c4
diff --git a/fstest/fstest.go b/fstest/fstest.go
index 3e2fa38fa..81eefc828 100644
--- a/fstest/fstest.go
+++ b/fstest/fstest.go
@@ -142,17 +142,6 @@ func (i *Item) Check(t *testing.T, obj fs.Object, precision time.Duration) {
i.CheckModTime(t, obj, obj.ModTime(context.Background()), precision)
}
-// WinPath converts a path into a windows safe path
-func WinPath(s string) string {
- return strings.Map(func(r rune) rune {
- switch r {
- case '<', '>', '"', '|', '?', '*', ':':
- return '_'
- }
- return r
- }, s)
-}
-
// Normalize runs a utf8 normalization on the string if running on OS
// X. This is because OS X denormalizes file names it writes to the
// local file system.
@@ -318,11 +307,11 @@ func CheckListingWithRoot(t *testing.T, f fs.Fs, dir string, items []Item, expec
if expectedDirs != nil {
expectedDirsCopy := make([]string, len(expectedDirs))
for i, dir := range expectedDirs {
- expectedDirsCopy[i] = WinPath(Normalize(dir))
+ expectedDirsCopy[i] = Normalize(dir)
}
actualDirs := []string{}
for _, dir := range dirs {
- actualDirs = append(actualDirs, WinPath(Normalize(dir.Remote())))
+ actualDirs = append(actualDirs, Normalize(dir.Remote()))
}
sort.Strings(actualDirs)
sort.Strings(expectedDirsCopy)
@@ -383,11 +372,11 @@ func CompareItems(t *testing.T, entries fs.DirEntries, items []Item, expectedDir
if expectedDirs != nil {
expectedDirsCopy := make([]string, len(expectedDirs))
for i, dir := range expectedDirs {
- expectedDirsCopy[i] = WinPath(Normalize(dir))
+ expectedDirsCopy[i] = Normalize(dir)
}
actualDirs := []string{}
for _, dir := range dirs {
- actualDirs = append(actualDirs, WinPath(Normalize(dir.Remote())))
+ actualDirs = append(actualDirs, Normalize(dir.Remote()))
}
sort.Strings(actualDirs)
sort.Strings(expectedDirsCopy)
diff --git a/fstest/fstests/fstests.go b/fstest/fstests/fstests.go
index b5b2c834d..7e69a73ab 100644
--- a/fstest/fstests/fstests.go
+++ b/fstest/fstests/fstests.go
@@ -101,7 +101,7 @@ func NextMultipleOf(m fs.SizeSuffix) func(fs.SizeSuffix) fs.SizeSuffix {
func dirsToNames(dirs []fs.Directory) []string {
names := []string{}
for _, dir := range dirs {
- names = append(names, fstest.WinPath(fstest.Normalize(dir.Remote())))
+ names = append(names, fstest.Normalize(dir.Remote()))
}
sort.Strings(names)
return names
@@ -111,7 +111,7 @@ func dirsToNames(dirs []fs.Directory) []string {
func objsToNames(objs []fs.Object) []string {
names := []string{}
for _, obj := range objs {
- names = append(names, fstest.WinPath(fstest.Normalize(obj.Remote())))
+ names = append(names, fstest.Normalize(obj.Remote()))
}
sort.Strings(names)
return names
@@ -335,12 +335,6 @@ func Run(t *testing.T, opt *Opt) {
return fs.UnWrapFs(f).Features().BucketBased && strings.Contains(strings.Trim(f.Root(), "/"), "/")
}
- // Remove bad characters from Windows file name if set
- if opt.SkipBadWindowsCharacters {
- t.Logf("Removing bad windows characters from test file")
- file2.Path = fstest.WinPath(file2.Path)
- }
-
// Initialise the remote
fstest.Initialise()
@@ -780,7 +774,7 @@ func Run(t *testing.T, opt *Opt) {
for i := 1; i <= *fstest.ListRetries; i++ {
objs, dirs, err := walk.GetAll(ctx, remote, dir, true, 1)
if errors.Cause(err) == fs.ErrorDirNotFound {
- objs, dirs, err = walk.GetAll(ctx, remote, fstest.WinPath(dir), true, 1)
+ objs, dirs, err = walk.GetAll(ctx, remote, dir, true, 1)
}
require.NoError(t, err)
objNames = objsToNames(objs)
@@ -803,13 +797,13 @@ func Run(t *testing.T, opt *Opt) {
dir = path.Dir(dir)
if dir == "." {
dir = ""
- expectedObjNames = append(expectedObjNames, fstest.WinPath(file1.Path))
+ expectedObjNames = append(expectedObjNames, file1.Path)
}
if deepest {
- expectedObjNames = append(expectedObjNames, fstest.WinPath(file2.Path))
+ expectedObjNames = append(expectedObjNames, file2.Path)
deepest = false
} else {
- expectedDirNames = append(expectedDirNames, fstest.WinPath(child))
+ expectedDirNames = append(expectedDirNames, child)
}
list(dir, expectedDirNames, expectedObjNames)
}
@@ -829,14 +823,14 @@ func Run(t *testing.T, opt *Opt) {
objs, dirs, err := walk.GetAll(ctx, remote, "", true, -1)
require.NoError(t, err)
assert.Equal(t, []string{
- "hello_ sausage",
- "hello_ sausage/êé",
- "hello_ sausage/êé/Hello, 世界",
- "hello_ sausage/êé/Hello, 世界/ _ ' @ _ _ & _ + ≠",
+ "hello? sausage",
+ "hello? sausage/êé",
+ "hello? sausage/êé/Hello, 世界",
+ "hello? sausage/êé/Hello, 世界/ \" ' @ < > & ? + ≠",
}, dirsToNames(dirs))
assert.Equal(t, []string{
"file name.txt",
- "hello_ sausage/êé/Hello, 世界/ _ ' @ _ _ & _ + ≠/z.txt",
+ "hello? sausage/êé/Hello, 世界/ \" ' @ < > & ? + ≠/z.txt",
}, objsToNames(objs))
})
@@ -847,12 +841,12 @@ func Run(t *testing.T, opt *Opt) {
objs, dirs, err := walk.GetAll(ctx, remote, path.Dir(path.Dir(path.Dir(path.Dir(file2.Path)))), true, -1)
require.NoError(t, err)
assert.Equal(t, []string{
- "hello_ sausage/êé",
- "hello_ sausage/êé/Hello, 世界",
- "hello_ sausage/êé/Hello, 世界/ _ ' @ _ _ & _ + ≠",
+ "hello? sausage/êé",
+ "hello? sausage/êé/Hello, 世界",
+ "hello? sausage/êé/Hello, 世界/ \" ' @ < > & ? + ≠",
}, dirsToNames(dirs))
assert.Equal(t, []string{
- "hello_ sausage/êé/Hello, 世界/ _ ' @ _ _ & _ + ≠/z.txt",
+ "hello? sausage/êé/Hello, 世界/ \" ' @ < > & ? + ≠/z.txt",
}, objsToNames(objs))
})
@@ -907,7 +901,7 @@ func Run(t *testing.T, opt *Opt) {
}
require.NoError(t, err)
assert.Equal(t, []string{file1.Path}, objsToNames(objs))
- assert.Equal(t, []string{`hello_ sausage`, `hello_ sausage/êé`}, dirsToNames(dirs))
+ assert.Equal(t, []string{"hello? sausage", "hello? sausage/êé"}, dirsToNames(dirs))
}
t.Run("FsListLevel2", TestFsListLevel2)