[RFC] 'walkDir' now has a new 'checkDir' flag, to mimic behaviour of other languages (#13642)

Co-authored-by: narimiran
This commit is contained in:
Timothee Cour 2020-03-20 08:39:55 -07:00 • committed by GitHub
commit 1d665adecd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 56 additions and 31 deletions

View file

@ -163,13 +163,19 @@ block walkDirRec:
removeDir("walkdir_test")
when not defined(windows):
block walkDirRelative:
createDir("walkdir_test")
createSymlink(".", "walkdir_test/c")
for k, p in walkDir("walkdir_test", true):
doAssert k == pcLinkToDir
removeDir("walkdir_test")
block: # walkDir
doAssertRaises(OSError):
for a in walkDir("nonexistant", checkDir = true): discard
doAssertRaises(OSError):
for p in walkDirRec("nonexistant", checkDir = true): discard
when not defined(windows):
block walkDirRelative:
createDir("walkdir_test")
createSymlink(".", "walkdir_test/c")
for k, p in walkDir("walkdir_test", true):
doAssert k == pcLinkToDir
removeDir("walkdir_test")
block normalizedPath:
doAssert normalizedPath("") == ""