Compare commits
No commits in common. "master" and "fixes-710" have entirely different histories.
21 changed files with 76 additions and 360 deletions
17
.travis.yml
17
.travis.yml
|
|
@ -1,5 +1,4 @@
|
||||||
os:
|
os:
|
||||||
- windows
|
|
||||||
- linux
|
- linux
|
||||||
- osx
|
- osx
|
||||||
|
|
||||||
|
|
@ -8,17 +7,23 @@ language: c
|
||||||
env:
|
env:
|
||||||
- BRANCH=0.19.6
|
- BRANCH=0.19.6
|
||||||
- BRANCH=0.20.2
|
- BRANCH=0.20.2
|
||||||
- BRANCH=1.0.6
|
|
||||||
# This is the latest working Nim version against which Nimble is being tested
|
# This is the latest working Nim version against which Nimble is being tested
|
||||||
- BRANCH=#ab525cc48abdbbbed1f772e58e9fe21474f70f07
|
- BRANCH=#2565d3d102efd21ba02ed1f3b96d892fe2637d2b
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- "$HOME/.choosenim"
|
- "$HOME/.choosenim/toolchains/nim-0.19.6"
|
||||||
|
- "$HOME/.choosenim/toolchains/nim-0.20.2"
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- curl https://gist.github.com/genotrance/fb53504a4fba88bc5201d3783df5c522/raw/travis.sh -LsSf -o travis.sh
|
- export CHOOSENIM_CHOOSE_VERSION=$BRANCH
|
||||||
- source travis.sh
|
- |
|
||||||
|
curl https://nim-lang.org/choosenim/init.sh -sSf > init.sh
|
||||||
|
sh init.sh -y
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- export CHOOSENIM_NO_ANALYTICS=1
|
||||||
|
- export PATH=$HOME/.nimble/bin:$PATH
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- cd tests
|
- cd tests
|
||||||
|
|
|
||||||
|
|
@ -3,33 +3,7 @@
|
||||||
|
|
||||||
# Nimble changelog
|
# Nimble changelog
|
||||||
|
|
||||||
## 0.11.0 - 22/09/2019
|
|
||||||
|
|
||||||
This is a major release containing nearly 60 commits. Most changes are
|
|
||||||
bug fixes, but this release also includes a couple new features:
|
|
||||||
|
|
||||||
- Binaries can now be built and run using the new ``run`` command.
|
|
||||||
- The ``NimblePkgVersion`` is now defined so you can easily get the package
|
|
||||||
version in your source code
|
|
||||||
([example](https://github.com/nim-lang/nimble/blob/4a2aaa07d/tests/nimbleVersionDefine/src/nimbleVersionDefine.nim)).
|
|
||||||
|
|
||||||
Some other highlights:
|
|
||||||
|
|
||||||
- Temporary files are now kept when the ``--debug`` flag is used.
|
|
||||||
- Fixed dependency resolution issues with "#head" packages (#432 and #672).
|
|
||||||
- The `install` command can now take Nim compiler flags via the new
|
|
||||||
``--passNim`` flag.
|
|
||||||
- Command line arguments are now passed properly to tasks (#633).
|
|
||||||
- The ``test`` command now respects the specified backend (#631).
|
|
||||||
- The ``dump`` command will no longer prompt and now has an implicit ``-y``.
|
|
||||||
- Fixed bugs with the new nimscript executor (#665).
|
|
||||||
- Fixed multiple downloads and installs of the same package (#678).
|
- Fixed multiple downloads and installs of the same package (#678).
|
||||||
- Nimble init no longer overwrites existing files (#581).
|
|
||||||
- Fixed incorrect submodule version being pulled when in a non-master branch (#675).
|
|
||||||
|
|
||||||
----
|
|
||||||
|
|
||||||
Full changelog: https://github.com/nim-lang/nimble/compare/v0.10.2...v0.11.0
|
|
||||||
|
|
||||||
## 0.10.2 - 03/06/2019
|
## 0.10.2 - 03/06/2019
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ Interested in learning **how to create a package**? Skip directly to that sectio
|
||||||
- [nimble install](#nimble-install)
|
- [nimble install](#nimble-install)
|
||||||
- [nimble uninstall](#nimble-uninstall)
|
- [nimble uninstall](#nimble-uninstall)
|
||||||
- [nimble build](#nimble-build)
|
- [nimble build](#nimble-build)
|
||||||
- [nimble run](#nimble-run)
|
|
||||||
- [nimble c](#nimble-c)
|
- [nimble c](#nimble-c)
|
||||||
- [nimble list](#nimble-list)
|
- [nimble list](#nimble-list)
|
||||||
- [nimble search](#nimble-search)
|
- [nimble search](#nimble-search)
|
||||||
|
|
@ -75,15 +74,10 @@ not need to install Nimble manually**.
|
||||||
But in case you still want to install Nimble manually, you can follow the
|
But in case you still want to install Nimble manually, you can follow the
|
||||||
following instructions.
|
following instructions.
|
||||||
|
|
||||||
There are two ways to install Nimble manually. Using ``koch`` and using Nimble
|
There are two ways to install Nimble manually. The first is using the
|
||||||
itself.
|
``koch`` tool included in the Nim distribution and
|
||||||
|
|
||||||
### Using koch
|
|
||||||
|
|
||||||
The ``koch`` tool is included in the Nim distribution and
|
|
||||||
[repository](https://github.com/nim-lang/Nim/blob/devel/koch.nim).
|
[repository](https://github.com/nim-lang/Nim/blob/devel/koch.nim).
|
||||||
Simply navigate to the location of your Nim installation and execute the
|
Simply execute the following command to compile and install Nimble.
|
||||||
following command to compile and install Nimble.
|
|
||||||
|
|
||||||
```
|
```
|
||||||
./koch nimble
|
./koch nimble
|
||||||
|
|
@ -92,19 +86,6 @@ following command to compile and install Nimble.
|
||||||
This will clone the Nimble repository, compile Nimble and copy it into
|
This will clone the Nimble repository, compile Nimble and copy it into
|
||||||
Nim's bin directory.
|
Nim's bin directory.
|
||||||
|
|
||||||
### Using Nimble
|
|
||||||
|
|
||||||
In most cases you will already have Nimble installed, you can install a newer
|
|
||||||
version of Nimble by simply running the following command:
|
|
||||||
|
|
||||||
```
|
|
||||||
nimble install nimble
|
|
||||||
```
|
|
||||||
|
|
||||||
This will download the latest release of Nimble and install it on your system.
|
|
||||||
|
|
||||||
Note that you must have `~/.nimble/bin` in your PATH for this to work, if you're
|
|
||||||
using choosenim then you likely already have this set up correctly.
|
|
||||||
|
|
||||||
## Nimble usage
|
## Nimble usage
|
||||||
|
|
||||||
|
|
@ -172,13 +153,12 @@ example:
|
||||||
This is of course Git-specific, for Mercurial, use ``tip`` instead of ``head``. A
|
This is of course Git-specific, for Mercurial, use ``tip`` instead of ``head``. A
|
||||||
branch, tag, or commit hash may also be specified in the place of ``head``.
|
branch, tag, or commit hash may also be specified in the place of ``head``.
|
||||||
|
|
||||||
Instead of specifying a VCS branch, you may also specify a concrete version or a
|
Instead of specifying a VCS branch, you may also specify a version range, for
|
||||||
version range, for example:
|
example:
|
||||||
|
|
||||||
$ nimble install nimgame@0.5
|
|
||||||
$ nimble install nimgame@"> 0.5"
|
$ nimble install nimgame@"> 0.5"
|
||||||
|
|
||||||
The latter command will install a version which is greater than ``0.5``.
|
In this case a version which is greater than ``0.5`` will be installed.
|
||||||
|
|
||||||
If you don't specify a parameter and there is a ``package.nimble`` file in your
|
If you don't specify a parameter and there is a ``package.nimble`` file in your
|
||||||
current working directory then Nimble will install the package residing in
|
current working directory then Nimble will install the package residing in
|
||||||
|
|
@ -239,13 +219,6 @@ flags, i.e. a debug build which includes stack traces but no GDB debug
|
||||||
information. The ``install`` command will build the package in release mode
|
information. The ``install`` command will build the package in release mode
|
||||||
instead.
|
instead.
|
||||||
|
|
||||||
### nimble run
|
|
||||||
|
|
||||||
The ``run`` command can be used to build and run any binary specified in your
|
|
||||||
package's ``bin`` list. You can pass any compilation flags you wish by specifying
|
|
||||||
them before the ``run`` command, and you can specify arguments for your binary
|
|
||||||
by specifying them after the ``run`` command.
|
|
||||||
|
|
||||||
### nimble c
|
### nimble c
|
||||||
|
|
||||||
The ``c`` (or ``compile``, ``js``, ``cc``, ``cpp``) command can be used by
|
The ``c`` (or ``compile``, ``js``, ``cc``, ``cpp``) command can be used by
|
||||||
|
|
@ -505,7 +478,7 @@ For a package named "foobar", the recommended project structure is the following
|
||||||
└── src
|
└── src
|
||||||
└── foobar.nim # Imported via `import foobar`
|
└── foobar.nim # Imported via `import foobar`
|
||||||
└── tests # Contains the tests
|
└── tests # Contains the tests
|
||||||
├── config.nims
|
├── nim.cfg
|
||||||
├── tfoo1.nim # First test
|
├── tfoo1.nim # First test
|
||||||
└── tfoo2.nim # Second test
|
└── tfoo2.nim # Second test
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,12 @@
|
||||||
|
|
||||||
import system except TResult
|
import system except TResult
|
||||||
|
|
||||||
import os, tables, strtabs, json, algorithm, sets, uri, sugar, sequtils, osproc
|
import os, tables, strtabs, json, algorithm, sets, uri, sugar, sequtils
|
||||||
import std/options as std_opt
|
import std/options as std_opt
|
||||||
|
|
||||||
import strutils except toLower
|
import strutils except toLower
|
||||||
from unicode import toLower
|
from unicode import toLower
|
||||||
from sequtils import toSeq
|
from sequtils import toSeq
|
||||||
from strformat import fmt
|
|
||||||
|
|
||||||
import nimblepkg/packageinfo, nimblepkg/version, nimblepkg/tools,
|
import nimblepkg/packageinfo, nimblepkg/version, nimblepkg/tools,
|
||||||
nimblepkg/download, nimblepkg/config, nimblepkg/common,
|
nimblepkg/download, nimblepkg/config, nimblepkg/common,
|
||||||
|
|
@ -201,13 +200,12 @@ proc processDeps(pkginfo: PackageInfo, options: Options): seq[PackageInfo] =
|
||||||
# in the path.
|
# in the path.
|
||||||
var pkgsInPath: StringTableRef = newStringTable(modeCaseSensitive)
|
var pkgsInPath: StringTableRef = newStringTable(modeCaseSensitive)
|
||||||
for pkgInfo in result:
|
for pkgInfo in result:
|
||||||
let currentVer = pkgInfo.getConcreteVersion(options)
|
|
||||||
if pkgsInPath.hasKey(pkgInfo.name) and
|
if pkgsInPath.hasKey(pkgInfo.name) and
|
||||||
pkgsInPath[pkgInfo.name] != currentVer:
|
pkgsInPath[pkgInfo.name] != pkgInfo.version:
|
||||||
raise newException(NimbleError,
|
raise newException(NimbleError,
|
||||||
"Cannot satisfy the dependency on $1 $2 and $1 $3" %
|
"Cannot satisfy the dependency on $1 $2 and $1 $3" %
|
||||||
[pkgInfo.name, currentVer, pkgsInPath[pkgInfo.name]])
|
[pkgInfo.name, pkgInfo.version, pkgsInPath[pkgInfo.name]])
|
||||||
pkgsInPath[pkgInfo.name] = currentVer
|
pkgsInPath[pkgInfo.name] = pkgInfo.version
|
||||||
|
|
||||||
# We add the reverse deps to the JSON file here because we don't want
|
# We add the reverse deps to the JSON file here because we don't want
|
||||||
# them added if the above errorenous condition occurs
|
# them added if the above errorenous condition occurs
|
||||||
|
|
@ -221,7 +219,7 @@ proc buildFromDir(
|
||||||
options: Options
|
options: Options
|
||||||
) =
|
) =
|
||||||
## Builds a package as specified by ``pkgInfo``.
|
## Builds a package as specified by ``pkgInfo``.
|
||||||
let binToBuild = options.getCompilationBinary(pkgInfo)
|
let binToBuild = options.getCompilationBinary()
|
||||||
# Handle pre-`build` hook.
|
# Handle pre-`build` hook.
|
||||||
let realDir = pkgInfo.getRealDir()
|
let realDir = pkgInfo.getRealDir()
|
||||||
cd realDir: # Make sure `execHook` executes the correct .nimble file.
|
cd realDir: # Make sure `execHook` executes the correct .nimble file.
|
||||||
|
|
@ -235,7 +233,6 @@ proc buildFromDir(
|
||||||
var args = args
|
var args = args
|
||||||
let nimblePkgVersion = "-d:NimblePkgVersion=" & pkgInfo.version
|
let nimblePkgVersion = "-d:NimblePkgVersion=" & pkgInfo.version
|
||||||
for path in paths: args.add("--path:\"" & path & "\" ")
|
for path in paths: args.add("--path:\"" & path & "\" ")
|
||||||
var binariesBuilt = 0
|
|
||||||
for bin in pkgInfo.bin:
|
for bin in pkgInfo.bin:
|
||||||
# Check if this is the only binary that we want to build.
|
# Check if this is the only binary that we want to build.
|
||||||
if binToBuild.isSome() and binToBuild.get() != bin:
|
if binToBuild.isSome() and binToBuild.get() != bin:
|
||||||
|
|
@ -251,15 +248,10 @@ proc buildFromDir(
|
||||||
if not existsDir(outputDir):
|
if not existsDir(outputDir):
|
||||||
createDir(outputDir)
|
createDir(outputDir)
|
||||||
|
|
||||||
let input = realDir / bin.changeFileExt("nim")
|
|
||||||
# `quoteShell` would be more robust than `\"` (and avoid quoting when
|
|
||||||
# un-necessary) but would require changing `extractBin`
|
|
||||||
let cmd = "\"$#\" $# --noNimblePath $# $# $# \"$#\"" %
|
|
||||||
[getNimBin(), pkgInfo.backend, nimblePkgVersion,
|
|
||||||
join(args, " "), outputOpt, input]
|
|
||||||
try:
|
try:
|
||||||
doCmd(cmd, showCmd = true)
|
doCmd("\"" & getNimBin() & "\" $# --noNimblePath $# $# $# \"$#\"" %
|
||||||
binariesBuilt.inc()
|
[pkgInfo.backend, nimblePkgVersion, join(args, " "), outputOpt,
|
||||||
|
realDir / bin.changeFileExt("nim")])
|
||||||
except NimbleError:
|
except NimbleError:
|
||||||
let currentExc = (ref NimbleError)(getCurrentException())
|
let currentExc = (ref NimbleError)(getCurrentException())
|
||||||
let exc = newException(BuildFailed, "Build failed for package: " &
|
let exc = newException(BuildFailed, "Build failed for package: " &
|
||||||
|
|
@ -269,11 +261,6 @@ proc buildFromDir(
|
||||||
exc.hint = hint
|
exc.hint = hint
|
||||||
raise exc
|
raise exc
|
||||||
|
|
||||||
if binariesBuilt == 0:
|
|
||||||
raiseNimbleError(
|
|
||||||
"No binaries built, did you specify a valid binary name?"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Handle post-`build` hook.
|
# Handle post-`build` hook.
|
||||||
cd realDir: # Make sure `execHook` executes the correct .nimble file.
|
cd realDir: # Make sure `execHook` executes the correct .nimble file.
|
||||||
discard execHook(options, actionBuild, false)
|
discard execHook(options, actionBuild, false)
|
||||||
|
|
@ -386,7 +373,7 @@ proc installFromDir(dir: string, requestedVer: VersionRange, options: Options,
|
||||||
options.action.passNimFlags
|
options.action.passNimFlags
|
||||||
else:
|
else:
|
||||||
@[]
|
@[]
|
||||||
buildFromDir(pkgInfo, paths, "-d:release" & flags, options)
|
buildFromDir(pkgInfo, paths, flags & "-d:release", options)
|
||||||
|
|
||||||
let pkgDestDir = pkgInfo.getPkgDest(options)
|
let pkgDestDir = pkgInfo.getPkgDest(options)
|
||||||
if existsDir(pkgDestDir) and existsFile(pkgDestDir / "nimblemeta.json"):
|
if existsDir(pkgDestDir) and existsFile(pkgDestDir / "nimblemeta.json"):
|
||||||
|
|
@ -539,9 +526,9 @@ proc build(options: Options) =
|
||||||
var args = options.getCompilationFlags()
|
var args = options.getCompilationFlags()
|
||||||
buildFromDir(pkgInfo, paths, args, options)
|
buildFromDir(pkgInfo, paths, args, options)
|
||||||
|
|
||||||
proc execBackend(pkgInfo: PackageInfo, options: Options) =
|
proc execBackend(options: Options) =
|
||||||
let
|
let
|
||||||
bin = options.getCompilationBinary(pkgInfo).get()
|
bin = options.getCompilationBinary().get()
|
||||||
binDotNim = bin.addFileExt("nim")
|
binDotNim = bin.addFileExt("nim")
|
||||||
if bin == "":
|
if bin == "":
|
||||||
raise newException(NimbleError, "You need to specify a file.")
|
raise newException(NimbleError, "You need to specify a file.")
|
||||||
|
|
@ -729,11 +716,6 @@ proc dump(options: Options) =
|
||||||
echo "backend: ", p.backend.escape
|
echo "backend: ", p.backend.escape
|
||||||
|
|
||||||
proc init(options: Options) =
|
proc init(options: Options) =
|
||||||
# Check whether the vcs is installed.
|
|
||||||
let vcsBin = options.action.vcsOption
|
|
||||||
if vcsBin != "" and findExe(vcsBin, true) == "":
|
|
||||||
raise newException(NimbleError, "Please install git or mercurial first")
|
|
||||||
|
|
||||||
# Determine the package name.
|
# Determine the package name.
|
||||||
let pkgName =
|
let pkgName =
|
||||||
if options.action.projName != "":
|
if options.action.projName != "":
|
||||||
|
|
@ -868,17 +850,6 @@ js - Compile using JavaScript backend.""",
|
||||||
pkgRoot
|
pkgRoot
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create a git or hg repo in the new nimble project.
|
|
||||||
if vcsBin != "":
|
|
||||||
let cmd = fmt"cd {pkgRoot} && {vcsBin} init"
|
|
||||||
let ret: tuple[output: string, exitCode: int] = execCmdEx(cmd)
|
|
||||||
if ret.exitCode != 0: quit ret.output
|
|
||||||
|
|
||||||
var ignoreFile = if vcsBin == "git": ".gitignore" else: ".hgignore"
|
|
||||||
var fd = open(joinPath(pkgRoot, ignoreFile), fmWrite)
|
|
||||||
fd.write(pkgName & "\n")
|
|
||||||
fd.close()
|
|
||||||
|
|
||||||
display("Success:", "Package $# created successfully" % [pkgName], Success,
|
display("Success:", "Package $# created successfully" % [pkgName], Success,
|
||||||
HighPriority)
|
HighPriority)
|
||||||
|
|
||||||
|
|
@ -1074,21 +1045,17 @@ proc test(options: Options) =
|
||||||
if options.continueTestsOnFailure:
|
if options.continueTestsOnFailure:
|
||||||
inc tests
|
inc tests
|
||||||
try:
|
try:
|
||||||
execBackend(pkgInfo, optsCopy)
|
execBackend(optsCopy)
|
||||||
except NimbleError:
|
except NimbleError:
|
||||||
inc failures
|
inc failures
|
||||||
else:
|
else:
|
||||||
execBackend(pkgInfo, optsCopy)
|
execBackend(optsCopy)
|
||||||
|
|
||||||
let
|
let
|
||||||
existsAfter = existsFile(binFileName)
|
existsAfter = existsFile(binFileName)
|
||||||
canRemove = not existsBefore and existsAfter
|
canRemove = not existsBefore and existsAfter
|
||||||
if canRemove:
|
if canRemove:
|
||||||
try:
|
removeFile(binFileName)
|
||||||
removeFile(binFileName)
|
|
||||||
except OSError as exc:
|
|
||||||
display("Warning:", "Failed to delete " & binFileName & ": " &
|
|
||||||
exc.msg, Warning, MediumPriority)
|
|
||||||
|
|
||||||
if failures == 0:
|
if failures == 0:
|
||||||
display("Success:", "All tests passed", Success, HighPriority)
|
display("Success:", "All tests passed", Success, HighPriority)
|
||||||
|
|
@ -1117,27 +1084,27 @@ proc check(options: Options) =
|
||||||
|
|
||||||
proc run(options: Options) =
|
proc run(options: Options) =
|
||||||
# Verify parameters.
|
# Verify parameters.
|
||||||
var pkgInfo = getPkgInfo(getCurrentDir(), options)
|
let binary = options.getCompilationBinary().get()
|
||||||
|
|
||||||
let binary = options.getCompilationBinary(pkgInfo).get("")
|
|
||||||
if binary.len == 0:
|
if binary.len == 0:
|
||||||
raiseNimbleError("Please specify a binary to run")
|
raiseNimbleError("Please specify a binary to run")
|
||||||
|
|
||||||
|
var pkgInfo = getPkgInfo(getCurrentDir(), options)
|
||||||
if binary notin pkgInfo.bin:
|
if binary notin pkgInfo.bin:
|
||||||
raiseNimbleError(
|
raiseNimbleError(
|
||||||
"Binary '$#' is not defined in '$#' package." % [binary, pkgInfo.name]
|
"Binary '$#' is not defined in '$#' package." % [binary, pkgInfo.name]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
let binaryPath = pkgInfo.getOutputDir(binary)
|
||||||
|
|
||||||
# Build the binary.
|
# Build the binary.
|
||||||
build(options)
|
build(options)
|
||||||
|
|
||||||
let binaryPath = pkgInfo.getOutputDir(binary)
|
# Now run it.
|
||||||
let cmd = quoteShellCommand(binaryPath & options.action.runFlags)
|
let args = options.action.runFlags.join(" ")
|
||||||
displayDebug("Executing", cmd)
|
|
||||||
cmd.execCmd.quit
|
|
||||||
|
|
||||||
|
doCmd("$# $#" % [binaryPath, args], showOutput = true)
|
||||||
|
|
||||||
proc doAction(options: var Options) =
|
proc doAction(options: Options) =
|
||||||
if options.showHelp:
|
if options.showHelp:
|
||||||
writeHelp()
|
writeHelp()
|
||||||
if options.showVersion:
|
if options.showVersion:
|
||||||
|
|
@ -1148,10 +1115,6 @@ proc doAction(options: var Options) =
|
||||||
if not existsDir(options.getPkgsDir):
|
if not existsDir(options.getPkgsDir):
|
||||||
createDir(options.getPkgsDir)
|
createDir(options.getPkgsDir)
|
||||||
|
|
||||||
if options.action.typ in {actionTasks, actionRun, actionBuild, actionCompile}:
|
|
||||||
# Implicitly disable package validation for these commands.
|
|
||||||
options.disableValidation = true
|
|
||||||
|
|
||||||
case options.action.typ
|
case options.action.typ
|
||||||
of actionRefresh:
|
of actionRefresh:
|
||||||
refresh(options)
|
refresh(options)
|
||||||
|
|
@ -1180,8 +1143,7 @@ proc doAction(options: var Options) =
|
||||||
of actionRun:
|
of actionRun:
|
||||||
run(options)
|
run(options)
|
||||||
of actionCompile, actionDoc:
|
of actionCompile, actionDoc:
|
||||||
var pkgInfo = getPkgInfo(getCurrentDir(), options)
|
execBackend(options)
|
||||||
execBackend(pkgInfo, options)
|
|
||||||
of actionInit:
|
of actionInit:
|
||||||
init(options)
|
init(options)
|
||||||
of actionPublish:
|
of actionPublish:
|
||||||
|
|
@ -1207,8 +1169,7 @@ proc doAction(options: var Options) =
|
||||||
var execResult: ExecutionResult[bool]
|
var execResult: ExecutionResult[bool]
|
||||||
if execCustom(options, execResult, failFast=not isPreDefined):
|
if execCustom(options, execResult, failFast=not isPreDefined):
|
||||||
if execResult.hasTaskRequestedCommand():
|
if execResult.hasTaskRequestedCommand():
|
||||||
var options = execResult.getOptionsForCommand(options)
|
doAction(execResult.getOptionsForCommand(options))
|
||||||
doAction(options)
|
|
||||||
else:
|
else:
|
||||||
# If there is no task defined for the `test` task, we run the pre-defined
|
# If there is no task defined for the `test` task, we run the pre-defined
|
||||||
# fallback logic.
|
# fallback logic.
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,7 @@ when not defined(nimscript):
|
||||||
preHooks*: HashSet[string]
|
preHooks*: HashSet[string]
|
||||||
name*: string
|
name*: string
|
||||||
## The version specified in the .nimble file.Assuming info is non-minimal,
|
## The version specified in the .nimble file.Assuming info is non-minimal,
|
||||||
## it will always be a non-special version such as '0.1.4'.
|
## it will always be a non-special version such as '0.1.4'
|
||||||
## If in doubt, use `getConcreteVersion` instead.
|
|
||||||
version*: string
|
version*: string
|
||||||
specialVersion*: string ## Either `myVersion` or a special version such as #head.
|
specialVersion*: string ## Either `myVersion` or a special version such as #head.
|
||||||
author*: string
|
author*: string
|
||||||
|
|
|
||||||
|
|
@ -300,17 +300,4 @@ when isMainModule:
|
||||||
})
|
})
|
||||||
doAssert expected == getVersionList(data)
|
doAssert expected == getVersionList(data)
|
||||||
|
|
||||||
|
|
||||||
block:
|
|
||||||
let data2 = @["v0.1.0", "v0.1.1", "v0.2.0",
|
|
||||||
"0.4.0", "v0.4.2"]
|
|
||||||
let expected2 = toOrderedTable[Version, string]({
|
|
||||||
newVersion("0.4.2"): "v0.4.2",
|
|
||||||
newVersion("0.4.0"): "0.4.0",
|
|
||||||
newVersion("0.2.0"): "v0.2.0",
|
|
||||||
newVersion("0.1.1"): "v0.1.1",
|
|
||||||
newVersion("0.1.0"): "v0.1.0",
|
|
||||||
})
|
|
||||||
doAssert expected2 == getVersionList(data2)
|
|
||||||
|
|
||||||
echo("Everything works!")
|
echo("Everything works!")
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ var
|
||||||
author*: string ## The package's author.
|
author*: string ## The package's author.
|
||||||
description*: string ## The package's description.
|
description*: string ## The package's description.
|
||||||
license*: string ## The package's license.
|
license*: string ## The package's license.
|
||||||
srcDir*: string ## The package's source directory.
|
srcdir*: string ## The package's source directory.
|
||||||
binDir*: string ## The package's binary directory.
|
binDir*: string ## The package's binary directory.
|
||||||
backend*: string ## The package's backend.
|
backend*: string ## The package's backend.
|
||||||
|
|
||||||
|
|
@ -101,7 +101,7 @@ proc printPkgInfo(): string =
|
||||||
printIfLen author
|
printIfLen author
|
||||||
printIfLen description
|
printIfLen description
|
||||||
printIfLen license
|
printIfLen license
|
||||||
printIfLen srcDir
|
printIfLen srcdir
|
||||||
printIfLen binDir
|
printIfLen binDir
|
||||||
printIfLen backend
|
printIfLen backend
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,6 @@ proc needsLiveOutput(actionName: string, options: Options, isHook: bool): bool =
|
||||||
let isCustomTask = isCustomTask(actionName, options)
|
let isCustomTask = isCustomTask(actionName, options)
|
||||||
return isCustomTask or isHook or actionName == ""
|
return isCustomTask or isHook or actionName == ""
|
||||||
|
|
||||||
proc writeExecutionOutput(data: string) =
|
|
||||||
# TODO: in the future we will likely want this to be live, users will
|
|
||||||
# undoubtedly be doing loops and other crazy things in their top-level
|
|
||||||
# Nimble files.
|
|
||||||
display("Info", data)
|
|
||||||
|
|
||||||
proc execNimscript(
|
proc execNimscript(
|
||||||
nimsFile, projectDir, actionName: string, options: Options, isHook: bool
|
nimsFile, projectDir, actionName: string, options: Options, isHook: bool
|
||||||
): tuple[output: string, exitCode: int, stdout: string] =
|
): tuple[output: string, exitCode: int, stdout: string] =
|
||||||
|
|
@ -141,7 +135,6 @@ proc getIniFile*(scriptName: string, options: Options): string =
|
||||||
|
|
||||||
if exitCode == 0 and output.len != 0:
|
if exitCode == 0 and output.len != 0:
|
||||||
result.writeFile(output)
|
result.writeFile(output)
|
||||||
stdout.writeExecutionOutput()
|
|
||||||
else:
|
else:
|
||||||
raise newException(NimbleError, stdout & "\nprintPkgInfo() failed")
|
raise newException(NimbleError, stdout & "\nprintPkgInfo() failed")
|
||||||
|
|
||||||
|
|
@ -182,8 +175,6 @@ proc execScript(
|
||||||
result.flags[flag].add val.getStr()
|
result.flags[flag].add val.getStr()
|
||||||
result.retVal = j{"retVal"}.getBool()
|
result.retVal = j{"retVal"}.getBool()
|
||||||
|
|
||||||
stdout.writeExecutionOutput()
|
|
||||||
|
|
||||||
proc execTask*(scriptName, taskName: string,
|
proc execTask*(scriptName, taskName: string,
|
||||||
options: Options): ExecutionResult[bool] =
|
options: Options): ExecutionResult[bool] =
|
||||||
## Executes the specified task in the specified script.
|
## Executes the specified task in the specified script.
|
||||||
|
|
|
||||||
|
|
@ -51,13 +51,12 @@ type
|
||||||
search*: seq[string] # Search string.
|
search*: seq[string] # Search string.
|
||||||
of actionInit, actionDump:
|
of actionInit, actionDump:
|
||||||
projName*: string
|
projName*: string
|
||||||
vcsOption*: string
|
|
||||||
of actionCompile, actionDoc, actionBuild:
|
of actionCompile, actionDoc, actionBuild:
|
||||||
file*: string
|
file*: string
|
||||||
backend*: string
|
backend*: string
|
||||||
compileOptions: seq[string]
|
compileOptions: seq[string]
|
||||||
of actionRun:
|
of actionRun:
|
||||||
runFile: Option[string]
|
runFile: string
|
||||||
compileFlags: seq[string]
|
compileFlags: seq[string]
|
||||||
runFlags*: seq[string]
|
runFlags*: seq[string]
|
||||||
of actionCustom:
|
of actionCustom:
|
||||||
|
|
@ -81,19 +80,13 @@ Commands:
|
||||||
init [pkgname] Initializes a new Nimble project in the
|
init [pkgname] Initializes a new Nimble project in the
|
||||||
current directory or if a name is provided a
|
current directory or if a name is provided a
|
||||||
new directory of the same name.
|
new directory of the same name.
|
||||||
--git
|
|
||||||
--hg Create a git or hg repo in the new nimble project.
|
|
||||||
publish Publishes a package on nim-lang/packages.
|
publish Publishes a package on nim-lang/packages.
|
||||||
The current working directory needs to be the
|
The current working directory needs to be the
|
||||||
toplevel directory of the Nimble package.
|
toplevel directory of the Nimble package.
|
||||||
uninstall [pkgname, ...] Uninstalls a list of packages.
|
uninstall [pkgname, ...] Uninstalls a list of packages.
|
||||||
[-i, --inclDeps] Uninstall package and dependent package(s).
|
[-i, --inclDeps] Uninstall package and dependent package(s).
|
||||||
build [opts, ...] [bin] Builds a package.
|
build [opts, ...] Builds a package.
|
||||||
run [opts, ...] [bin] Builds and runs a package.
|
run [opts, ...] bin Builds and runs a package.
|
||||||
Binary needs to be specified after any
|
|
||||||
compilation options if there are several
|
|
||||||
binaries defined, any flags after the binary
|
|
||||||
or -- arg are passed to the binary when it is run.
|
|
||||||
c, cc, js [opts, ...] f.nim Builds a file inside a package. Passes options
|
c, cc, js [opts, ...] f.nim Builds a file inside a package. Passes options
|
||||||
to the Nim compiler.
|
to the Nim compiler.
|
||||||
test Compiles and executes tests
|
test Compiles and executes tests
|
||||||
|
|
@ -204,10 +197,8 @@ proc initAction*(options: var Options, key: string) =
|
||||||
else: options.action.backend = keyNorm
|
else: options.action.backend = keyNorm
|
||||||
of actionInit:
|
of actionInit:
|
||||||
options.action.projName = ""
|
options.action.projName = ""
|
||||||
options.action.vcsOption = ""
|
|
||||||
of actionDump:
|
of actionDump:
|
||||||
options.action.projName = ""
|
options.action.projName = ""
|
||||||
options.action.vcsOption = ""
|
|
||||||
options.forcePrompts = forcePromptYes
|
options.forcePrompts = forcePromptYes
|
||||||
of actionRefresh:
|
of actionRefresh:
|
||||||
options.action.optionalURL = ""
|
options.action.optionalURL = ""
|
||||||
|
|
@ -266,12 +257,6 @@ proc parseCommand*(key: string, result: var Options) =
|
||||||
result.action = Action(typ: parseActionType(key))
|
result.action = Action(typ: parseActionType(key))
|
||||||
initAction(result, key)
|
initAction(result, key)
|
||||||
|
|
||||||
proc setRunOptions(result: var Options, key, val: string, isArg: bool) =
|
|
||||||
if result.action.runFile.isNone() and (isArg or val == "--"):
|
|
||||||
result.action.runFile = some(key)
|
|
||||||
else:
|
|
||||||
result.action.runFlags.add(val)
|
|
||||||
|
|
||||||
proc parseArgument*(key: string, result: var Options) =
|
proc parseArgument*(key: string, result: var Options) =
|
||||||
case result.action.typ
|
case result.action.typ
|
||||||
of actionNil:
|
of actionNil:
|
||||||
|
|
@ -303,7 +288,10 @@ proc parseArgument*(key: string, result: var Options) =
|
||||||
of actionBuild:
|
of actionBuild:
|
||||||
result.action.file = key
|
result.action.file = key
|
||||||
of actionRun:
|
of actionRun:
|
||||||
result.setRunOptions(key, key, true)
|
if result.action.runFile.len == 0:
|
||||||
|
result.action.runFile = key
|
||||||
|
else:
|
||||||
|
result.action.runFlags.add(key)
|
||||||
of actionCustom:
|
of actionCustom:
|
||||||
result.action.arguments.add(key)
|
result.action.arguments.add(key)
|
||||||
else:
|
else:
|
||||||
|
|
@ -357,12 +345,6 @@ proc parseFlag*(flag, val: string, result: var Options, kind = cmdLongOption) =
|
||||||
result.action.passNimFlags.add(val)
|
result.action.passNimFlags.add(val)
|
||||||
else:
|
else:
|
||||||
wasFlagHandled = false
|
wasFlagHandled = false
|
||||||
of actionInit:
|
|
||||||
case f
|
|
||||||
of "git", "hg":
|
|
||||||
result.action.vcsOption = f
|
|
||||||
else:
|
|
||||||
wasFlagHandled = false
|
|
||||||
of actionUninstall:
|
of actionUninstall:
|
||||||
case f
|
case f
|
||||||
of "incldeps", "i":
|
of "incldeps", "i":
|
||||||
|
|
@ -373,8 +355,7 @@ proc parseFlag*(flag, val: string, result: var Options, kind = cmdLongOption) =
|
||||||
if not isGlobalFlag:
|
if not isGlobalFlag:
|
||||||
result.action.compileOptions.add(getFlagString(kind, flag, val))
|
result.action.compileOptions.add(getFlagString(kind, flag, val))
|
||||||
of actionRun:
|
of actionRun:
|
||||||
result.showHelp = false
|
result.action.runFlags.add(getFlagString(kind, flag, val))
|
||||||
result.setRunOptions(flag, getFlagString(kind, flag, val), false)
|
|
||||||
of actionCustom:
|
of actionCustom:
|
||||||
if result.action.command.normalize == "test":
|
if result.action.command.normalize == "test":
|
||||||
if f == "continue" or f == "c":
|
if f == "continue" or f == "c":
|
||||||
|
|
@ -386,8 +367,7 @@ proc parseFlag*(flag, val: string, result: var Options, kind = cmdLongOption) =
|
||||||
if not wasFlagHandled and not isGlobalFlag:
|
if not wasFlagHandled and not isGlobalFlag:
|
||||||
result.unknownFlags.add((kind, flag, val))
|
result.unknownFlags.add((kind, flag, val))
|
||||||
|
|
||||||
proc initOptions*(): Options =
|
proc initOptions(): Options =
|
||||||
# Exported for choosenim
|
|
||||||
Options(
|
Options(
|
||||||
action: Action(typ: actionNil),
|
action: Action(typ: actionNil),
|
||||||
pkgInfoCache: newTable[string, PackageInfo](),
|
pkgInfoCache: newTable[string, PackageInfo](),
|
||||||
|
|
@ -444,7 +424,7 @@ proc parseCmdLine*(): Options =
|
||||||
else:
|
else:
|
||||||
parseArgument(key, result)
|
parseArgument(key, result)
|
||||||
of cmdLongOption, cmdShortOption:
|
of cmdLongOption, cmdShortOption:
|
||||||
parseFlag(key, val, result, kind)
|
parseFlag(key, val, result, kind)
|
||||||
of cmdEnd: assert(false) # cannot happen
|
of cmdEnd: assert(false) # cannot happen
|
||||||
|
|
||||||
handleUnknownFlags(result)
|
handleUnknownFlags(result)
|
||||||
|
|
@ -529,23 +509,15 @@ proc getCompilationFlags*(options: Options): seq[string] =
|
||||||
var opt = options
|
var opt = options
|
||||||
return opt.getCompilationFlags()
|
return opt.getCompilationFlags()
|
||||||
|
|
||||||
proc getCompilationBinary*(options: Options, pkgInfo: PackageInfo): Option[string] =
|
proc getCompilationBinary*(options: Options): Option[string] =
|
||||||
case options.action.typ
|
case options.action.typ
|
||||||
of actionBuild, actionDoc, actionCompile:
|
of actionBuild, actionDoc, actionCompile:
|
||||||
let file = options.action.file.changeFileExt("")
|
let file = options.action.file.changeFileExt("")
|
||||||
if file.len > 0:
|
if file.len > 0:
|
||||||
return some(file)
|
return some(file)
|
||||||
of actionRun:
|
of actionRun:
|
||||||
let optRunFile = options.action.runFile
|
let runFile = options.action.runFile.changeFileExt("")
|
||||||
let runFile =
|
|
||||||
if optRunFile.get("").len > 0:
|
|
||||||
optRunFile.get()
|
|
||||||
elif pkgInfo.bin.len == 1:
|
|
||||||
pkgInfo.bin[0]
|
|
||||||
else:
|
|
||||||
""
|
|
||||||
|
|
||||||
if runFile.len > 0:
|
if runFile.len > 0:
|
||||||
return some(runFile.changeFileExt(ExeExt))
|
return some(runFile)
|
||||||
else:
|
else:
|
||||||
discard
|
discard
|
||||||
|
|
@ -487,15 +487,6 @@ proc toFullInfo*(pkg: PackageInfo, options: Options): PackageInfo =
|
||||||
else:
|
else:
|
||||||
return pkg
|
return pkg
|
||||||
|
|
||||||
proc getConcreteVersion*(pkgInfo: PackageInfo, options: Options): string =
|
|
||||||
## Returns a non-special version from the specified ``pkgInfo``. If the
|
|
||||||
## ``pkgInfo`` is minimal it looks it up and retrieves the concrete version.
|
|
||||||
result = pkgInfo.version
|
|
||||||
if pkgInfo.isMinimal:
|
|
||||||
let pkgInfo = pkgInfo.toFullInfo(options)
|
|
||||||
result = pkgInfo.version
|
|
||||||
assert(not newVersion(result).isSpecial)
|
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
validatePackageName("foo_bar")
|
validatePackageName("foo_bar")
|
||||||
validatePackageName("f_oo_b_a_r")
|
validatePackageName("f_oo_b_a_r")
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ proc extractBin(cmd: string): string =
|
||||||
else:
|
else:
|
||||||
return cmd.split(' ')[0]
|
return cmd.split(' ')[0]
|
||||||
|
|
||||||
proc doCmd*(cmd: string, showOutput = false, showCmd = false) =
|
proc doCmd*(cmd: string, showOutput = false) =
|
||||||
let bin = extractBin(cmd)
|
let bin = extractBin(cmd)
|
||||||
if findExe(bin) == "":
|
if findExe(bin) == "":
|
||||||
raise newException(NimbleError, "'" & bin & "' not in PATH.")
|
raise newException(NimbleError, "'" & bin & "' not in PATH.")
|
||||||
|
|
@ -20,10 +20,7 @@ proc doCmd*(cmd: string, showOutput = false, showCmd = false) =
|
||||||
stdout.flushFile()
|
stdout.flushFile()
|
||||||
stderr.flushFile()
|
stderr.flushFile()
|
||||||
|
|
||||||
if showCmd:
|
displayDebug("Executing", cmd)
|
||||||
display("Executing", cmd, priority = MediumPriority)
|
|
||||||
else:
|
|
||||||
displayDebug("Executing", cmd)
|
|
||||||
if showOutput:
|
if showOutput:
|
||||||
let exitCode = execCmd(cmd)
|
let exitCode = execCmd(cmd)
|
||||||
displayDebug("Finished", "with exit code " & $exitCode)
|
displayDebug("Finished", "with exit code " & $exitCode)
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ proc makeRange*(version: string, op: string): VersionRange =
|
||||||
result = VersionRange(kind: verEqLater)
|
result = VersionRange(kind: verEqLater)
|
||||||
of "<=":
|
of "<=":
|
||||||
result = VersionRange(kind: verEqEarlier)
|
result = VersionRange(kind: verEqEarlier)
|
||||||
of "", "==":
|
of "":
|
||||||
result = VersionRange(kind: verEq)
|
result = VersionRange(kind: verEq)
|
||||||
else:
|
else:
|
||||||
raise newException(ParseVersionError, "Invalid operator: " & op)
|
raise newException(ParseVersionError, "Invalid operator: " & op)
|
||||||
|
|
@ -298,10 +298,9 @@ when isMainModule:
|
||||||
doAssert(newVersion("0.1.0") <= newVersion("0.1"))
|
doAssert(newVersion("0.1.0") <= newVersion("0.1"))
|
||||||
|
|
||||||
var inter1 = parseVersionRange(">= 1.0 & <= 1.5")
|
var inter1 = parseVersionRange(">= 1.0 & <= 1.5")
|
||||||
doAssert(inter1.kind == verIntersect)
|
doAssert inter1.kind == verIntersect
|
||||||
var inter2 = parseVersionRange("1.0")
|
var inter2 = parseVersionRange("1.0")
|
||||||
doAssert(inter2.kind == verEq)
|
doAssert(inter2.kind == verEq)
|
||||||
doAssert(parseVersionRange("== 3.4.2") == parseVersionRange("3.4.2"))
|
|
||||||
|
|
||||||
doAssert(not withinRange(newVersion("1.5.1"), inter1))
|
doAssert(not withinRange(newVersion("1.5.1"), inter1))
|
||||||
doAssert(withinRange(newVersion("1.0.2.3.4.5.6.7.8.9.10.11.12"), inter1))
|
doAssert(withinRange(newVersion("1.0.2.3.4.5.6.7.8.9.10.11.12"), inter1))
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
# Package
|
|
||||||
|
|
||||||
version = "0.1.0"
|
|
||||||
author = "Dominik Picheta"
|
|
||||||
description = "A new awesome nimble package"
|
|
||||||
license = "MIT"
|
|
||||||
srcDir = "src"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Dependencies
|
|
||||||
|
|
||||||
requires "nim >= 0.16.0"
|
|
||||||
requires "https://github.com/nimble-test/packagea#head",
|
|
||||||
"https://github.com/nimble-test/packagebin2"
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
# This is just an example to get you started. A typical library package
|
|
||||||
# exports the main API in this file. Note that you cannot rename this file
|
|
||||||
# but you can remove it if you wish.
|
|
||||||
|
|
||||||
proc add*(x, y: int): int =
|
|
||||||
## Adds two files together.
|
|
||||||
return x + y
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
# Package
|
|
||||||
|
|
||||||
version = "0.1.0"
|
|
||||||
author = "Dominik Picheta"
|
|
||||||
description = "A new awesome nimble package"
|
|
||||||
license = "MIT"
|
|
||||||
srcDir = "src"
|
|
||||||
bin = @["issue564/issue564build"]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Dependencies
|
|
||||||
|
|
||||||
requires "nim >= 0.16.0"
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
# This is just an example to get you started. A typical binary package
|
|
||||||
# uses this file as the main entry point of the application.
|
|
||||||
|
|
||||||
when isMainModule:
|
|
||||||
echo("Hello, World!")
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
# Package
|
|
||||||
|
|
||||||
version = "0.1.0"
|
|
||||||
author = "Dominik Picheta"
|
|
||||||
description = "A new awesome nimble package"
|
|
||||||
license = "MIT"
|
|
||||||
srcDir = "src"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Dependencies
|
|
||||||
|
|
||||||
requires "nim >= 0.16.0"
|
|
||||||
|
|
||||||
|
|
||||||
echo "hello"
|
|
||||||
echo "hello2"
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
# This is just an example to get you started. A typical library package
|
|
||||||
# exports the main API in this file. Note that you cannot rename this file
|
|
||||||
# but you can remove it if you wish.
|
|
||||||
|
|
||||||
proc add*(x, y: int): int =
|
|
||||||
## Adds two files together.
|
|
||||||
return x + y
|
|
||||||
Binary file not shown.
|
|
@ -9,9 +9,10 @@ license = "BSD"
|
||||||
|
|
||||||
requires "nim >= 0.12.1"
|
requires "nim >= 0.12.1"
|
||||||
|
|
||||||
let
|
when defined(windows):
|
||||||
callNimble = getEnv("NIMBLE_TEST_BINARY_PATH")
|
let callNimble = "..\\..\\src\\nimble.exe"
|
||||||
doAssert callNimble.len != 0, "NIMBLE_TEST_BINARY_PATH not set"
|
else:
|
||||||
|
let callNimble = "../../src/nimble"
|
||||||
|
|
||||||
task recurse, "Level 1":
|
task recurse, "Level 1":
|
||||||
echo 1
|
echo 1
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,6 @@ var installDir = rootDir / "tests" / "nimbleDir"
|
||||||
const path = "../src/nimble"
|
const path = "../src/nimble"
|
||||||
const stringNotFound = -1
|
const stringNotFound = -1
|
||||||
|
|
||||||
# Set env var to propagate nimble binary path
|
|
||||||
putEnv("NIMBLE_TEST_BINARY_PATH", nimblePath)
|
|
||||||
|
|
||||||
# Clear nimble dir.
|
# Clear nimble dir.
|
||||||
removeDir(installDir)
|
removeDir(installDir)
|
||||||
createDir(installDir)
|
createDir(installDir)
|
||||||
|
|
@ -38,7 +35,7 @@ proc execNimble(args: varargs[string]): tuple[output: string, exitCode: int] =
|
||||||
var quotedArgs = @args
|
var quotedArgs = @args
|
||||||
quotedArgs.insert("--nimbleDir:" & installDir)
|
quotedArgs.insert("--nimbleDir:" & installDir)
|
||||||
quotedArgs.insert(nimblePath)
|
quotedArgs.insert(nimblePath)
|
||||||
quotedArgs = quotedArgs.map((x: string) => x.quoteShell)
|
quotedArgs = quotedArgs.map((x: string) => ("\"" & x & "\""))
|
||||||
|
|
||||||
let path {.used.} = getCurrentDir().parentDir() / "src"
|
let path {.used.} = getCurrentDir().parentDir() / "src"
|
||||||
|
|
||||||
|
|
@ -82,21 +79,6 @@ proc hasLineStartingWith(lines: seq[string], prefix: string): bool =
|
||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
|
|
||||||
test "issue 708":
|
|
||||||
cd "issue708":
|
|
||||||
# TODO: We need a way to filter out compiler messages from the messages
|
|
||||||
# written by our nimble scripts.
|
|
||||||
var (output, exitCode) = execNimble("install", "-y", "--verbose")
|
|
||||||
check exitCode == QuitSuccess
|
|
||||||
let lines = output.strip.processOutput()
|
|
||||||
check(inLines(lines, "hello"))
|
|
||||||
check(inLines(lines, "hello2"))
|
|
||||||
|
|
||||||
test "issue 564":
|
|
||||||
cd "issue564":
|
|
||||||
var (_, exitCode) = execNimble("build")
|
|
||||||
check exitCode == QuitSuccess
|
|
||||||
|
|
||||||
test "depsOnly + flag order test":
|
test "depsOnly + flag order test":
|
||||||
var (output, exitCode) = execNimble(
|
var (output, exitCode) = execNimble(
|
||||||
"--depsOnly", "install", "-y", "https://github.com/nimble-test/packagebin2"
|
"--depsOnly", "install", "-y", "https://github.com/nimble-test/packagebin2"
|
||||||
|
|
@ -483,17 +465,17 @@ test "issue #349":
|
||||||
]
|
]
|
||||||
|
|
||||||
proc checkName(name: string) =
|
proc checkName(name: string) =
|
||||||
|
when defined(windows):
|
||||||
|
if name.toLowerAscii() in @["con", "nul"]:
|
||||||
|
return
|
||||||
let (outp, code) = execNimble("init", "-y", name)
|
let (outp, code) = execNimble("init", "-y", name)
|
||||||
let msg = outp.strip.processOutput()
|
let msg = outp.strip.processOutput()
|
||||||
check code == QuitFailure
|
check code == QuitFailure
|
||||||
check inLines(msg,
|
check inLines(msg,
|
||||||
"\"$1\" is an invalid package name: reserved name" % name)
|
"\"$1\" is an invalid package name: reserved name" % name)
|
||||||
try:
|
removeFile(name.changeFileExt("nimble"))
|
||||||
removeFile(name.changeFileExt("nimble"))
|
removeDir("src")
|
||||||
removeDir("src")
|
removeDir("tests")
|
||||||
removeDir("tests")
|
|
||||||
except OSError:
|
|
||||||
discard
|
|
||||||
|
|
||||||
for reserved in reservedNames:
|
for reserved in reservedNames:
|
||||||
checkName(reserved.toUpperAscii())
|
checkName(reserved.toUpperAscii())
|
||||||
|
|
@ -933,8 +915,7 @@ suite "nimble run":
|
||||||
"blahblah", # The command to run
|
"blahblah", # The command to run
|
||||||
)
|
)
|
||||||
check exitCode == QuitFailure
|
check exitCode == QuitFailure
|
||||||
check output.contains("Binary '$1' is not defined in 'run' package." %
|
check output.contains("Binary 'blahblah' is not defined in 'run' package.")
|
||||||
"blahblah".changeFileExt(ExeExt))
|
|
||||||
|
|
||||||
test "Parameters passed to executable":
|
test "Parameters passed to executable":
|
||||||
cd "run":
|
cd "run":
|
||||||
|
|
@ -946,54 +927,9 @@ suite "nimble run":
|
||||||
"check" # Second argument passed to the executed command.
|
"check" # Second argument passed to the executed command.
|
||||||
)
|
)
|
||||||
check exitCode == QuitSuccess
|
check exitCode == QuitSuccess
|
||||||
check output.contains("tests$1run$1$2 --debug check" %
|
check output.contains("tests/run/run --debug check")
|
||||||
[$DirSep, "run".changeFileExt(ExeExt)])
|
|
||||||
check output.contains("""Testing `nimble run`: @["--debug", "check"]""")
|
check output.contains("""Testing `nimble run`: @["--debug", "check"]""")
|
||||||
|
|
||||||
test "Parameters not passed to single executable":
|
|
||||||
cd "run":
|
|
||||||
var (output, exitCode) = execNimble(
|
|
||||||
"--debug", # Flag to enable debug verbosity in Nimble
|
|
||||||
"run", # Run command invokation
|
|
||||||
"--debug" # First argument passed to the executed command
|
|
||||||
)
|
|
||||||
check exitCode == QuitSuccess
|
|
||||||
check output.contains("tests$1run$1$2 --debug" %
|
|
||||||
[$DirSep, "run".changeFileExt(ExeExt)])
|
|
||||||
check output.contains("""Testing `nimble run`: @["--debug"]""")
|
|
||||||
|
|
||||||
test "Parameters passed to single executable":
|
|
||||||
cd "run":
|
|
||||||
var (output, exitCode) = execNimble(
|
|
||||||
"--debug", # Flag to enable debug verbosity in Nimble
|
|
||||||
"run", # Run command invokation
|
|
||||||
"--", # Flag to set run file to "" before next argument
|
|
||||||
"--debug", # First argument passed to the executed command
|
|
||||||
"check" # Second argument passed to the executed command.
|
|
||||||
)
|
|
||||||
check exitCode == QuitSuccess
|
|
||||||
check output.contains("tests$1run$1$2 --debug check" %
|
|
||||||
[$DirSep, "run".changeFileExt(ExeExt)])
|
|
||||||
check output.contains("""Testing `nimble run`: @["--debug", "check"]""")
|
|
||||||
|
|
||||||
test "Executable output is shown even when not debugging":
|
|
||||||
cd "run":
|
|
||||||
var (output, exitCode) =
|
|
||||||
execNimble("run", "run", "--option1", "arg1")
|
|
||||||
check exitCode == QuitSuccess
|
|
||||||
check output.contains("""Testing `nimble run`: @["--option1", "arg1"]""")
|
|
||||||
|
|
||||||
test "Quotes and whitespace are well handled":
|
|
||||||
cd "run":
|
|
||||||
var (output, exitCode) = execNimble(
|
|
||||||
"run", "run", "\"", "\'", "\t", "arg with spaces"
|
|
||||||
)
|
|
||||||
check exitCode == QuitSuccess
|
|
||||||
check output.contains(
|
|
||||||
"""Testing `nimble run`: @["\"", "\'", "\t", "arg with spaces"]"""
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
test "NimbleVersion is defined":
|
test "NimbleVersion is defined":
|
||||||
cd "nimbleVersionDefine":
|
cd "nimbleVersionDefine":
|
||||||
var (output, exitCode) = execNimble("c", "-r", "src/nimbleVersionDefine.nim")
|
var (output, exitCode) = execNimble("c", "-r", "src/nimbleVersionDefine.nim")
|
||||||
|
|
@ -1004,11 +940,6 @@ test "NimbleVersion is defined":
|
||||||
check output2.contains("0.1.0")
|
check output2.contains("0.1.0")
|
||||||
check exitCode2 == QuitSuccess
|
check exitCode2 == QuitSuccess
|
||||||
|
|
||||||
test "issue 432":
|
|
||||||
cd "issue432":
|
|
||||||
check execNimble("install", "-y", "--depsOnly").exitCode == QuitSuccess
|
|
||||||
check execNimble("install", "-y", "--depsOnly").exitCode == QuitSuccess
|
|
||||||
|
|
||||||
test "compilation without warnings":
|
test "compilation without warnings":
|
||||||
const buildDir = "./buildDir/"
|
const buildDir = "./buildDir/"
|
||||||
const filesToBuild = [
|
const filesToBuild = [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue