parent
2674cacd16
commit
3f6ef3ae55
7 changed files with 97 additions and 14 deletions
|
|
@ -214,6 +214,7 @@ proc addRevDep(options: Options, dep: tuple[name, version: string],
|
|||
|
||||
proc removeRevDep(options: Options, pkg: PackageInfo) =
|
||||
## Removes ``pkg`` from the reverse dependencies of every package.
|
||||
assert(not pkg.isMinimal)
|
||||
proc remove(options: Options, pkg: PackageInfo, depTup: PkgTuple,
|
||||
thisDep: JsonNode) =
|
||||
for ver, val in thisDep:
|
||||
|
|
@ -294,9 +295,9 @@ proc processDeps(pkginfo: PackageInfo, options: Options): seq[string] =
|
|||
# We add the reverse deps to the JSON file here because we don't want
|
||||
# them added if the above errorenous condition occurs
|
||||
# (unsatisfiable dependendencies).
|
||||
# N.B. NimbleData is saved in installFromDir.
|
||||
for i in reverseDeps:
|
||||
addRevDep(options, i, pkginfo)
|
||||
saveNimbleData(options)
|
||||
|
||||
proc buildFromDir(pkgInfo: PackageInfo, paths: seq[string], forRelease: bool) =
|
||||
## Builds a package as specified by ``pkgInfo``.
|
||||
|
|
@ -448,6 +449,10 @@ proc installFromDir(dir: string, latest: bool, options: Options,
|
|||
# Save a nimblemeta.json file.
|
||||
saveNimbleMeta(pkgDestDir, url, filesInstalled)
|
||||
|
||||
# Save the nimble data (which might now contain reverse deps added in
|
||||
# processDeps).
|
||||
saveNimbleData(options)
|
||||
|
||||
# Return the paths to the dependencies of this package.
|
||||
result.paths.add pkgDestDir
|
||||
result.pkg = pkgInfo
|
||||
|
|
@ -839,7 +844,11 @@ proc uninstall(options: Options) =
|
|||
|
||||
for pkg in pkgsToDelete:
|
||||
# If we reach this point then the package can be safely removed.
|
||||
removeRevDep(options, pkg)
|
||||
|
||||
# removeRevDep needs the package dependency info, so we can't just pass
|
||||
# a minimal pkg info.
|
||||
let pkgFull = readPackageInfo(pkg.mypath, options, false)
|
||||
removeRevDep(options, pkgFull)
|
||||
removePkgDir(options.getPkgsDir / (pkg.name & '-' & pkg.version), options)
|
||||
echo("Removed ", pkg.name, " (", $pkg.version, ")")
|
||||
|
||||
|
|
|
|||
11
tests/issue113/a/a.nimble
Normal file
11
tests/issue113/a/a.nimble
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Package
|
||||
|
||||
version = "0.1.0"
|
||||
author = "Dominik Picheta"
|
||||
description = "Root package, depends on b."
|
||||
license = "MIT"
|
||||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 0.12.1", "b"
|
||||
|
||||
11
tests/issue113/b/b.nimble
Normal file
11
tests/issue113/b/b.nimble
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Package
|
||||
|
||||
version = "0.1.0"
|
||||
author = "Dominik Picheta"
|
||||
description = "Second dep. Depended by a and depends on c."
|
||||
license = "MIT"
|
||||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 0.12.1", "c"
|
||||
|
||||
1
tests/issue113/buildfail/buildfail.nim
Normal file
1
tests/issue113/buildfail/buildfail.nim
Normal file
|
|
@ -0,0 +1 @@
|
|||
var x: string = 42
|
||||
13
tests/issue113/buildfail/buildfail.nimble
Normal file
13
tests/issue113/buildfail/buildfail.nimble
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Package
|
||||
|
||||
version = "0.1.0"
|
||||
author = "Dominik Picheta"
|
||||
description = "Testing issue 113."
|
||||
license = "MIT"
|
||||
|
||||
bin = @["buildfail"]
|
||||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 0.12.1", "c"
|
||||
|
||||
11
tests/issue113/c/c.nimble
Normal file
11
tests/issue113/c/c.nimble
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Package
|
||||
|
||||
version = "0.1.0"
|
||||
author = "Dominik Picheta"
|
||||
description = "Third dep. Depended by b."
|
||||
license = "MIT"
|
||||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 0.12.1"
|
||||
|
||||
|
|
@ -18,6 +18,33 @@ template cd*(dir: string, body: stmt) =
|
|||
proc processOutput(output: string): seq[string] =
|
||||
output.strip.splitLines().filter((x: string) => (x.len > 0))
|
||||
|
||||
proc inLines(lines: seq[string], line: string): bool =
|
||||
for i in lines:
|
||||
if line.normalize in i.normalize: return true
|
||||
|
||||
test "issue 113 (uninstallation problems)":
|
||||
cd "issue113/c":
|
||||
check execCmdEx("../../" & path & " install -y").exitCode == QuitSuccess
|
||||
cd "issue113/b":
|
||||
check execCmdEx("../../" & path & " install -y").exitCode == QuitSuccess
|
||||
cd "issue113/a":
|
||||
check execCmdEx("../../" & path & " install -y").exitCode == QuitSuccess
|
||||
|
||||
# Try to remove c.
|
||||
let (output, exitCode) = execCmdEx(path & " remove -y c")
|
||||
let lines = output.strip.splitLines()
|
||||
check exitCode != QuitSuccess
|
||||
check "cannot uninstall c (0.1.0) because b (0.1.0) depends on it" in
|
||||
lines[^1].normalize
|
||||
|
||||
check execCmdEx(path & " remove -y a").exitCode == QuitSuccess
|
||||
check execCmdEx(path & " remove -y b").exitCode == QuitSuccess
|
||||
|
||||
cd "issue113/buildfail":
|
||||
check execCmdEx("../../" & path & " install -y").exitCode != QuitSuccess
|
||||
|
||||
check execCmdEx(path & " remove -y c").exitCode == QuitSuccess
|
||||
|
||||
test "can refresh with default urls":
|
||||
check execCmdEx(path & " refresh").exitCode == QuitSuccess
|
||||
|
||||
|
|
@ -39,12 +66,12 @@ test "can refresh with custom urls":
|
|||
let (output, exitCode) = execCmdEx(path & " refresh")
|
||||
let lines = output.strip.splitLines()
|
||||
check exitCode == QuitSuccess
|
||||
check "reading from config file" in lines[0].normalize
|
||||
check "downloading \"official\" package list" in lines[1].normalize
|
||||
check "trying http://google.com" in lines[2].normalize
|
||||
check "packages.json file is invalid" in lines[3].normalize
|
||||
check "404 not found" in lines[5].normalize
|
||||
check "done" in lines[^1].normalize
|
||||
check inLines(lines, "reading from config file")
|
||||
check inLines(lines, "downloading \"official\" package list")
|
||||
check inLines(lines, "trying http://google.com")
|
||||
check inLines(lines, "packages.json file is invalid")
|
||||
check inLines(lines, "404 not found")
|
||||
check inLines(lines, "done")
|
||||
|
||||
# Restore config
|
||||
if fileExists(configBakFile):
|
||||
|
|
@ -114,16 +141,16 @@ test "issue #27":
|
|||
|
||||
test "issue #126":
|
||||
cd "issue126/a":
|
||||
let (output, exitCode) = execCmdEx("../../" & path & " install")
|
||||
let (output, exitCode) = execCmdEx("../../" & path & " install -y")
|
||||
let lines = output.strip.splitLines()
|
||||
check exitCode != QuitSuccess
|
||||
check "issue-126 is an invalid package name: cannot contain '-'" in lines[^1]
|
||||
check exitCode != QuitSuccess # TODO
|
||||
check inLines(lines, "issue-126 is an invalid package name: cannot contain '-'")
|
||||
|
||||
cd "issue126/b":
|
||||
let (output1, exitCode1) = execCmdEx("../../" & path & " install")
|
||||
let (output1, exitCode1) = execCmdEx("../../" & path & " install -y")
|
||||
let lines1 = output1.strip.splitLines()
|
||||
check exitCode1 != QuitSuccess
|
||||
check "The .nimble file name must match name specified inside".normalize in lines1[^1].normalize
|
||||
check exitCode1 == QuitSuccess
|
||||
check inLines(lines1, "The .nimble file name must match name specified inside")
|
||||
|
||||
test "issue #108":
|
||||
cd "issue108":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue