Merge pull request #345 from samdmarshall/fix-srcdir-path-exception
Modifying how package install path is validated
This commit is contained in:
commit
9e6db081db
4 changed files with 19 additions and 1 deletions
|
|
@ -79,7 +79,14 @@ proc changeRoot*(origRoot, newRoot, path: string): string =
|
||||||
## newRoot: /home/test/
|
## newRoot: /home/test/
|
||||||
## path: /home/dom/bar/blah/2/foo.txt
|
## path: /home/dom/bar/blah/2/foo.txt
|
||||||
## Return value -> /home/test/bar/blah/2/foo.txt
|
## Return value -> /home/test/bar/blah/2/foo.txt
|
||||||
if path.startsWith(origRoot):
|
|
||||||
|
## The additional check of `path.samePaths(origRoot)` is necessary to prevent
|
||||||
|
## a regression, where by ending the `srcDir` defintion in a nimble file in a
|
||||||
|
## trailing separator would cause the `path.startsWith(origRoot)` evaluation to
|
||||||
|
## fail because of the value of `origRoot` would be longer than `path` due to
|
||||||
|
## the trailing separator. This would cause this method to throw during package
|
||||||
|
## installation.
|
||||||
|
if path.startsWith(origRoot) or path.samePaths(origRoot):
|
||||||
return newRoot / path[origRoot.len .. path.len-1]
|
return newRoot / path[origRoot.len .. path.len-1]
|
||||||
else:
|
else:
|
||||||
raise newException(ValueError,
|
raise newException(ValueError,
|
||||||
|
|
|
||||||
7
tests/issue338/issue338.nimble
Normal file
7
tests/issue338/issue338.nimble
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Package
|
||||||
|
version = "0.1.0"
|
||||||
|
author = "Samantha Marshall"
|
||||||
|
description = "test case to validate successful install when `srcDir` value ends in a directory separator"
|
||||||
|
license = "MIT"
|
||||||
|
|
||||||
|
srcDir = "src/"
|
||||||
0
tests/issue338/src/issue338.nim
Normal file
0
tests/issue338/src/issue338.nim
Normal file
|
|
@ -286,6 +286,10 @@ test "issue #206":
|
||||||
(output, exitCode) = execNimble("install", "-y")
|
(output, exitCode) = execNimble("install", "-y")
|
||||||
check exitCode == QuitSuccess
|
check exitCode == QuitSuccess
|
||||||
|
|
||||||
|
test "issue #338":
|
||||||
|
cd "issue338":
|
||||||
|
check execNimble("install", "-y").exitCode == QuitSuccess
|
||||||
|
|
||||||
test "can list":
|
test "can list":
|
||||||
check execNimble("list").exitCode == QuitSuccess
|
check execNimble("list").exitCode == QuitSuccess
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue