os.nim: use the new pathnorm.normalizePath implementation

This commit is contained in:
Araq 2018-12-14 08:57:55 +01:00
commit ce9815bcf5
4 changed files with 67 additions and 85 deletions

View file

@ -190,61 +190,32 @@ block walkDirRec:
removeDir("walkdir_test")
block normalizedPath:
when defined(posix):
block relative:
doAssert normalizedPath(".") == "."
doAssert normalizedPath("..") == ".."
doAssert normalizedPath("../") == ".."
doAssert normalizedPath("../..") == "../.."
doAssert normalizedPath("../a/..") == ".."
doAssert normalizedPath("../a/../") == ".."
doAssert normalizedPath("./") == "."
block relative:
doAssert normalizedPath(".") == ""
doAssert normalizedPath("..") == ".."
doAssert normalizedPath("../") == ".."
doAssert normalizedPath("../..") == unixToNativePath"../.."
doAssert normalizedPath("../a/..") == ".."
doAssert normalizedPath("../a/../") == ".."
doAssert normalizedPath("./") == ""
block absolute:
doAssert normalizedPath("/") == "/"
doAssert normalizedPath("/.") == "/"
doAssert normalizedPath("/..") == "/"
doAssert normalizedPath("/../") == "/"
doAssert normalizedPath("/../..") == "/"
doAssert normalizedPath("/../../") == "/"
doAssert normalizedPath("/../../../") == "/"
doAssert normalizedPath("/a/b/../../foo") == "/foo"
doAssert normalizedPath("/a/b/../../../foo") == "/foo"
doAssert normalizedPath("/./") == "/"
doAssert normalizedPath("//") == "/"
doAssert normalizedPath("///") == "/"
doAssert normalizedPath("/a//b") == "/a/b"
doAssert normalizedPath("/a///b") == "/a/b"
doAssert normalizedPath("/a/b/c/..") == "/a/b"
doAssert normalizedPath("/a/b/c/../") == "/a/b"
else:
block relative:
doAssert normalizedPath(".") == "."
doAssert normalizedPath("..") == ".."
doAssert normalizedPath("..\\") == ".."
doAssert normalizedPath("..\\..") == "..\\.."
doAssert normalizedPath("..\\a\\..") == ".."
doAssert normalizedPath("..\\a\\..\\") == ".."
doAssert normalizedPath(".\\") == "."
block absolute:
doAssert normalizedPath("\\") == "\\"
doAssert normalizedPath("\\.") == "\\"
doAssert normalizedPath("\\..") == "\\"
doAssert normalizedPath("\\..\\") == "\\"
doAssert normalizedPath("\\..\\..") == "\\"
doAssert normalizedPath("\\..\\..\\") == "\\"
doAssert normalizedPath("\\..\\..\\..\\") == "\\"
doAssert normalizedPath("\\a\\b\\..\\..\\foo") == "\\foo"
doAssert normalizedPath("\\a\\b\\..\\..\\..\\foo") == "\\foo"
doAssert normalizedPath("\\.\\") == "\\"
doAssert normalizedPath("\\\\") == "\\"
doAssert normalizedPath("\\\\\\") == "\\"
doAssert normalizedPath("\\a\\\\b") == "\\a\\b"
doAssert normalizedPath("\\a\\\\\\b") == "\\a\\b"
doAssert normalizedPath("\\a\\b\\c\\..") == "\\a\\b"
doAssert normalizedPath("\\a\\b\\c\\..\\") == "\\a\\b"
block absolute:
doAssert normalizedPath("/") == unixToNativePath"/"
doAssert normalizedPath("/.") == unixToNativePath"/"
doAssert normalizedPath("/..") == unixToNativePath"/.."
doAssert normalizedPath("/../") == unixToNativePath"/.."
doAssert normalizedPath("/../..") == unixToNativePath"/../.."
doAssert normalizedPath("/../../") == unixToNativePath"/../.."
doAssert normalizedPath("/../../../") == unixToNativePath"/../../.."
doAssert normalizedPath("/a/b/../../foo") == unixToNativePath"/foo"
doAssert normalizedPath("/a/b/../../../foo") == unixToNativePath"/../foo"
doAssert normalizedPath("/./") == unixToNativePath"/"
doAssert normalizedPath("//") == unixToNativePath"/"
doAssert normalizedPath("///") == unixToNativePath"/"
doAssert normalizedPath("/a//b") == unixToNativePath"/a/b"
doAssert normalizedPath("/a///b") == unixToNativePath"/a/b"
doAssert normalizedPath("/a/b/c/..") == unixToNativePath"/a/b"
doAssert normalizedPath("/a/b/c/../") == unixToNativePath"/a/b"
block isHidden:
when defined(posix):