parent
a3a60eca51
commit
fe21329f3d
3 changed files with 35 additions and 25 deletions
|
|
@ -190,11 +190,6 @@ proc processDeps(pkginfo: PackageInfo, options: Options): seq[PackageInfo] =
|
|||
else:
|
||||
display("Info:", "Dependency on $1 already satisfied" % $dep,
|
||||
priority = HighPriority)
|
||||
if pkg.isLinked:
|
||||
# TODO (#393): This can be optimised since the .nimble-link files have
|
||||
# a secondary line that specifies the srcDir.
|
||||
pkg = pkg.toFullInfo(options)
|
||||
|
||||
result.add(pkg)
|
||||
# Process the dependencies of this dependency.
|
||||
result.add(processDeps(pkg.toFullInfo(options), options))
|
||||
|
|
@ -627,23 +622,19 @@ proc listPaths(options: Options) =
|
|||
raise newException(NimbleError, "A package name needs to be specified")
|
||||
|
||||
var errors = 0
|
||||
let pkgs = getInstalledPkgsMin(options.getPkgsDir(), options)
|
||||
for name, version in options.action.packages.items:
|
||||
var installed: seq[VersionAndPath] = @[]
|
||||
# There may be several, list all available ones and sort by version.
|
||||
for kind, path in walkDir(options.getPkgsDir):
|
||||
if kind != pcDir or not path.startsWith(options.getPkgsDir / name & "-"):
|
||||
continue
|
||||
|
||||
var nimbleFile = findNimbleFile(path, false)
|
||||
if nimbleFile.existsFile:
|
||||
var pkgInfo = getPkgInfo(path, options)
|
||||
for x in pkgs.items():
|
||||
let
|
||||
pName = x.pkginfo.name
|
||||
pVer = x.pkginfo.specialVersion
|
||||
if name == pName:
|
||||
var v: VersionAndPath
|
||||
v.version = newVersion(pkgInfo.specialVersion)
|
||||
v.path = pkgInfo.getRealDir()
|
||||
v.version = newVersion(pVer)
|
||||
v.path = x.pkginfo.getRealDir()
|
||||
installed.add(v)
|
||||
else:
|
||||
display("Warning:", "No .nimble file found for " & path, Warning,
|
||||
MediumPriority)
|
||||
|
||||
if installed.len > 0:
|
||||
sort(installed, cmp[VersionAndPath], Descending)
|
||||
|
|
|
|||
|
|
@ -336,8 +336,17 @@ proc getInstalledPkgsMin*(libsDir: string, options: Options):
|
|||
pkg.specialVersion = version
|
||||
pkg.isMinimal = true
|
||||
pkg.isInstalled = true
|
||||
pkg.isLinked =
|
||||
cmpPaths(nimbleFile.splitFile().dir, path) != 0
|
||||
let nimbleFileDir = nimbleFile.splitFile().dir
|
||||
pkg.isLinked = cmpPaths(nimbleFileDir, path) != 0
|
||||
|
||||
# Read the package's 'srcDir' (this is stored in the .nimble-link so
|
||||
# we can easily grab it)
|
||||
if pkg.isLinked:
|
||||
let nimbleLinkPath = path / name.addFileExt("nimble-link")
|
||||
let realSrcPath = readNimbleLink(nimbleLinkPath).packageDir
|
||||
assert realSrcPath.startsWith(nimbleFileDir)
|
||||
pkg.srcDir = realSrcPath.replace(nimbleFileDir)
|
||||
pkg.srcDir.removePrefix(DirSep)
|
||||
result.add((pkg, meta))
|
||||
|
||||
proc withinRange*(pkgInfo: PackageInfo, verRange: VersionRange): bool =
|
||||
|
|
|
|||
|
|
@ -595,8 +595,8 @@ suite "develop feature":
|
|||
check fileExists(path)
|
||||
let split = readFile(path).processOutput()
|
||||
check split.len == 2
|
||||
check split[0].endsWith("develop/hybrid/hybrid.nimble")
|
||||
check split[1].endsWith("develop/hybrid")
|
||||
check split[0].endsWith("develop" / "hybrid" / "hybrid.nimble")
|
||||
check split[1].endsWith("develop" / "hybrid")
|
||||
|
||||
test "can develop with srcDir":
|
||||
cd "develop/srcdirtest":
|
||||
|
|
@ -610,11 +610,11 @@ suite "develop feature":
|
|||
check fileExists(path)
|
||||
let split = readFile(path).processOutput()
|
||||
check split.len == 2
|
||||
check split[0].endsWith("develop/srcdirtest/srcdirtest.nimble")
|
||||
check split[1].endsWith("develop/srcdirtest/src")
|
||||
check split[0].endsWith("develop" / "srcdirtest" / "srcdirtest.nimble")
|
||||
check split[1].endsWith("develop" / "srcdirtest" / "src")
|
||||
|
||||
cd "develop/dependent":
|
||||
let (output, exitCode) = execNimble("c", "-r", "src/dependent.nim")
|
||||
let (output, exitCode) = execNimble("c", "-r", "src" / "dependent.nim")
|
||||
checkpoint output
|
||||
check(output.processOutput.inLines("hello"))
|
||||
check exitCode == QuitSuccess
|
||||
|
|
@ -644,10 +644,20 @@ suite "develop feature":
|
|||
check exitCode == QuitSuccess
|
||||
|
||||
(output, exitCode) = execNimble("path", "srcdirtest")
|
||||
|
||||
checkpoint output
|
||||
check exitCode == QuitSuccess
|
||||
check output.strip() == getCurrentDir() / "src"
|
||||
|
||||
suite "path command":
|
||||
test "can get correct path for srcDir (#531)":
|
||||
check execNimble("uninstall", "srcdirtest", "-y").exitCode == QuitSuccess
|
||||
cd "develop/srcdirtest":
|
||||
let (output, exitCode) = execNimble("install", "-y")
|
||||
check exitCode == QuitSuccess
|
||||
let (output, exitCode) = execNimble("path", "srcdirtest")
|
||||
check output.strip() == installDir / "pkgs" / "srcdirtest-1.0"
|
||||
|
||||
suite "test command":
|
||||
test "Runs passing unit tests":
|
||||
cd "testCommand/testsPass":
|
||||
|
|
@ -735,4 +745,4 @@ suite "Module tests":
|
|||
|
||||
test "cli":
|
||||
cd "..":
|
||||
check execCmdEx("nim c -r src/nimblepkg/cli").exitCode == QuitSuccess
|
||||
check execCmdEx("nim c -r src/nimblepkg/cli").exitCode == QuitSuccess
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue