diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2020-04-21 14:53:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-21 23:53:55 +0200 |
commit | 7ce0358351d8e241463e744d75e78c4cd810d19f (patch) | |
tree | 7ee05b7135d445d4fa87e3ea10c19306e6fdd507 /tests/js | |
parent | dd24004fabaf315463b89d38ac553b20080fd1cd (diff) | |
download | Nim-7ce0358351d8e241463e744d75e78c4cd810d19f.tar.gz |
fix #13222: make relativePath more robust and flexible (#13451)
* * relativePath(foo) now works * relativePath(rel, abs) and relativePath(abs, rel) now work (fixes #13222) * relativePath, absolutePath, getCurrentDir now available in more targets (eg: vm, nodejs etc) * fix bug: isAbsolutePath now works with -d:js; add tests * workaround https://github.com/nim-lang/Nim/issues/13469 * remove `relativePath(path)` overload for now * add back changelog after rebase
Diffstat (limited to 'tests/js')
-rw-r--r-- | tests/js/tos.nim | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/js/tos.nim b/tests/js/tos.nim index 7395a0ad7..30c19c1ae 100644 --- a/tests/js/tos.nim +++ b/tests/js/tos.nim @@ -5,3 +5,17 @@ import os block: doAssert "./foo//./bar/".normalizedPath == "foo/bar" doAssert relativePath(".//foo/bar", "foo") == "bar" + doAssert "/".isAbsolute + doAssert not "".isAbsolute + doAssert not ".".isAbsolute + doAssert not "foo".isAbsolute + doAssert relativePath("", "bar") == "" + doAssert normalizedPath(".///foo//./") == "foo" + let cwd = getCurrentDir() + + let isWindows = '\\' in cwd + # defined(windows) doesn't work with -d:nodejs but should + # these actually break because of that (see https://github.com/nim-lang/Nim/issues/13469) + if not isWindows: + doAssert cwd.isAbsolute + doAssert relativePath(getCurrentDir() / "foo", "bar") == "../foo" |