diff --git a/src/nimble.nim b/src/nimble.nim index 3017d55..ce88e67 100644 --- a/src/nimble.nim +++ b/src/nimble.nim @@ -1105,9 +1105,10 @@ proc doAction(options: Options) = of actionCustom: # Custom command. Attempt to call a NimScript task. let nimbleFile = findNimbleFile(getCurrentDir(), true) + let oldCmd = getNimScriptCommand() if not nimbleFile.isNimScript(): writeHelp() - let oldCmd = getNimScriptCommand() + if not execTask(nimbleFile, oldCmd): echo("FAILURE: Could not find task ", oldCmd, " in ", nimbleFile) writeHelp() diff --git a/tests/tester.nim b/tests/tester.nim index 42864ad..d9deea6 100644 --- a/tests/tester.nim +++ b/tests/tester.nim @@ -18,6 +18,23 @@ template cd*(dir: string, body: stmt) = proc processOutput(output: string): seq[string] = output.strip.splitLines().filter((x: string) => (x.len > 0)) +test "can install nimscript package": + cd "nimscript": + check execCmdEx("../" & path & " install -y").exitCode == QuitSuccess + +test "can execute nimscript tasks": + cd "nimscript": + let (output, exitCode) = execCmdEx("../" & path & " test") + let lines = output.strip.splitLines() + check exitCode == QuitSuccess + check lines[^1] == "10" + +test "can list nimscript tasks": + cd "nimscript": + let (output, exitCode) = execCmdEx("../" & path & " tasks") + check output.strip == "test test description" + check exitCode == QuitSuccess + test "can install packagebin2": check execCmdEx(path & " install -y https://github.com/nimble-test/packagebin2.git").exitCode == @@ -48,6 +65,11 @@ test "issue #27": cd "issue27": check execCmdEx("../" & path & " install -y").exitCode == QuitSuccess +test "can list": + check execCmdEx(path & " list").exitCode == QuitSuccess + + check execCmdEx(path & " list -i").exitCode == QuitSuccess + test "can uninstall": block: let (outp, exitCode) = execCmdEx(path & " uninstall -y issue27b") @@ -80,3 +102,5 @@ test "can uninstall": check execCmdEx(path & " uninstall -y PackageA@0.2 issue27b").exitCode == QuitSuccess check (not dirExists(getHomeDir() / ".nimble" / "pkgs" / "PackageA-0.2.0")) + + check execCmdEx(path & " uninstall -y nimscript").exitCode == QuitSuccess