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:
|
else:
|
||||||
display("Info:", "Dependency on $1 already satisfied" % $dep,
|
display("Info:", "Dependency on $1 already satisfied" % $dep,
|
||||||
priority = HighPriority)
|
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)
|
result.add(pkg)
|
||||||
# Process the dependencies of this dependency.
|
# Process the dependencies of this dependency.
|
||||||
result.add(processDeps(pkg.toFullInfo(options), options))
|
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")
|
raise newException(NimbleError, "A package name needs to be specified")
|
||||||
|
|
||||||
var errors = 0
|
var errors = 0
|
||||||
|
let pkgs = getInstalledPkgsMin(options.getPkgsDir(), options)
|
||||||
for name, version in options.action.packages.items:
|
for name, version in options.action.packages.items:
|
||||||
var installed: seq[VersionAndPath] = @[]
|
var installed: seq[VersionAndPath] = @[]
|
||||||
# There may be several, list all available ones and sort by version.
|
# There may be several, list all available ones and sort by version.
|
||||||
for kind, path in walkDir(options.getPkgsDir):
|
for x in pkgs.items():
|
||||||
if kind != pcDir or not path.startsWith(options.getPkgsDir / name & "-"):
|
let
|
||||||
continue
|
pName = x.pkginfo.name
|
||||||
|
pVer = x.pkginfo.specialVersion
|
||||||
var nimbleFile = findNimbleFile(path, false)
|
if name == pName:
|
||||||
if nimbleFile.existsFile:
|
|
||||||
var pkgInfo = getPkgInfo(path, options)
|
|
||||||
var v: VersionAndPath
|
var v: VersionAndPath
|
||||||
v.version = newVersion(pkgInfo.specialVersion)
|
v.version = newVersion(pVer)
|
||||||
v.path = pkgInfo.getRealDir()
|
v.path = x.pkginfo.getRealDir()
|
||||||
installed.add(v)
|
installed.add(v)
|
||||||
else:
|
|
||||||
display("Warning:", "No .nimble file found for " & path, Warning,
|
|
||||||
MediumPriority)
|
|
||||||
|
|
||||||
if installed.len > 0:
|
if installed.len > 0:
|
||||||
sort(installed, cmp[VersionAndPath], Descending)
|
sort(installed, cmp[VersionAndPath], Descending)
|
||||||
|
|
|
||||||
|
|
@ -336,8 +336,17 @@ proc getInstalledPkgsMin*(libsDir: string, options: Options):
|
||||||
pkg.specialVersion = version
|
pkg.specialVersion = version
|
||||||
pkg.isMinimal = true
|
pkg.isMinimal = true
|
||||||
pkg.isInstalled = true
|
pkg.isInstalled = true
|
||||||
pkg.isLinked =
|
let nimbleFileDir = nimbleFile.splitFile().dir
|
||||||
cmpPaths(nimbleFile.splitFile().dir, path) != 0
|
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))
|
result.add((pkg, meta))
|
||||||
|
|
||||||
proc withinRange*(pkgInfo: PackageInfo, verRange: VersionRange): bool =
|
proc withinRange*(pkgInfo: PackageInfo, verRange: VersionRange): bool =
|
||||||
|
|
|
||||||
|
|
@ -595,8 +595,8 @@ suite "develop feature":
|
||||||
check fileExists(path)
|
check fileExists(path)
|
||||||
let split = readFile(path).processOutput()
|
let split = readFile(path).processOutput()
|
||||||
check split.len == 2
|
check split.len == 2
|
||||||
check split[0].endsWith("develop/hybrid/hybrid.nimble")
|
check split[0].endsWith("develop" / "hybrid" / "hybrid.nimble")
|
||||||
check split[1].endsWith("develop/hybrid")
|
check split[1].endsWith("develop" / "hybrid")
|
||||||
|
|
||||||
test "can develop with srcDir":
|
test "can develop with srcDir":
|
||||||
cd "develop/srcdirtest":
|
cd "develop/srcdirtest":
|
||||||
|
|
@ -610,11 +610,11 @@ suite "develop feature":
|
||||||
check fileExists(path)
|
check fileExists(path)
|
||||||
let split = readFile(path).processOutput()
|
let split = readFile(path).processOutput()
|
||||||
check split.len == 2
|
check split.len == 2
|
||||||
check split[0].endsWith("develop/srcdirtest/srcdirtest.nimble")
|
check split[0].endsWith("develop" / "srcdirtest" / "srcdirtest.nimble")
|
||||||
check split[1].endsWith("develop/srcdirtest/src")
|
check split[1].endsWith("develop" / "srcdirtest" / "src")
|
||||||
|
|
||||||
cd "develop/dependent":
|
cd "develop/dependent":
|
||||||
let (output, exitCode) = execNimble("c", "-r", "src/dependent.nim")
|
let (output, exitCode) = execNimble("c", "-r", "src" / "dependent.nim")
|
||||||
checkpoint output
|
checkpoint output
|
||||||
check(output.processOutput.inLines("hello"))
|
check(output.processOutput.inLines("hello"))
|
||||||
check exitCode == QuitSuccess
|
check exitCode == QuitSuccess
|
||||||
|
|
@ -644,10 +644,20 @@ suite "develop feature":
|
||||||
check exitCode == QuitSuccess
|
check exitCode == QuitSuccess
|
||||||
|
|
||||||
(output, exitCode) = execNimble("path", "srcdirtest")
|
(output, exitCode) = execNimble("path", "srcdirtest")
|
||||||
|
|
||||||
checkpoint output
|
checkpoint output
|
||||||
check exitCode == QuitSuccess
|
check exitCode == QuitSuccess
|
||||||
check output.strip() == getCurrentDir() / "src"
|
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":
|
suite "test command":
|
||||||
test "Runs passing unit tests":
|
test "Runs passing unit tests":
|
||||||
cd "testCommand/testsPass":
|
cd "testCommand/testsPass":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue