From f44a960dcd1a49a7013f453e9d764aba23abae0d Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Fri, 15 May 2020 02:09:30 +0100 Subject: [PATCH] tests: Fix one multi-delete test failure in Windows CI (#9602) There is a disparency of behavior under Linux & Windows about the returned error when trying to rename a non existant path. err := os.Rename("/path/does/not/exist", "/tmp/copy") Linux: isSysErrNotDir(err) = false os.IsNotExist(err) = true Windows: isSysErrNotDir(err) = true os.IsNotExist(err) = true ENOTDIR in Linux is returned when the destination path of the rename call contains a file in one of the middle segments of the path (e.g. /tmp/file/dst, where /tmp/file is an actual file not a directory) However, as shown above, Windows has more scenarios when it returns ENOTDIR. For example, when the source path contains an inexistant directory in its path. In that case, we want errFileNotFound returned and not errFileAccessDenied, so this commit will add a further check to close the disparency between Windows & Linux. --- cmd/os-reliable.go | 6 +++++- cmd/server_test.go | 4 ---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/os-reliable.go b/cmd/os-reliable.go index 26c7df7b1..c76709d2e 100644 --- a/cmd/os-reliable.go +++ b/cmd/os-reliable.go @@ -131,7 +131,11 @@ func renameAll(srcFilePath, dstFilePath string) (err error) { if err = reliableRename(srcFilePath, dstFilePath); err != nil { switch { - case isSysErrNotDir(err): + case isSysErrNotDir(err) && !os.IsNotExist(err): + // Windows can have both isSysErrNotDir(err) and os.IsNotExist(err) returning + // true if the source file path contains an inexistant directory. In that case, + // we want to return errFileNotFound instead, which will honored in subsequent + // switch cases return errFileAccessDenied case isSysErrPathNotFound(err): // This is a special case should be handled only for diff --git a/cmd/server_test.go b/cmd/server_test.go index aa2074fd9..fd2523b38 100644 --- a/cmd/server_test.go +++ b/cmd/server_test.go @@ -28,7 +28,6 @@ import ( "net/http" "net/url" "reflect" - "runtime" "strings" "sync" "testing" @@ -121,9 +120,6 @@ func runAllTests(suite *TestSuiteCommon, c *check) { } func TestServerSuite(t *testing.T) { - if runtime.GOOS == "windows" { - t.Skip("cannot set up server reliably on Windows") - } testCases := []*TestSuiteCommon{ // Init and run test on FS backend with signature v4. {serverType: "FS", signer: signerV4},