From 281a1d129afad7acc0226cdd28d3e3d5cd104d34 Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Sun, 22 Sep 2019 14:39:22 +0100 Subject: [PATCH] Fixes #708. Refs #571. Output from Nimble scripts' top-level statements is now only visible with --verbose. --- src/nimblepkg/nimscriptwrapper.nim | 9 +++++++++ tests/issue708/issue708.nimble | 17 +++++++++++++++++ tests/issue708/src/issue708.nim | 7 +++++++ tests/tester.nim | 12 +++++++++++- 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 tests/issue708/issue708.nimble create mode 100644 tests/issue708/src/issue708.nim diff --git a/src/nimblepkg/nimscriptwrapper.nim b/src/nimblepkg/nimscriptwrapper.nim index baad4e7..4cfe6ec 100644 --- a/src/nimblepkg/nimscriptwrapper.nim +++ b/src/nimblepkg/nimscriptwrapper.nim @@ -30,6 +30,12 @@ proc needsLiveOutput(actionName: string, options: Options, isHook: bool): bool = let isCustomTask = isCustomTask(actionName, options) 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( nimsFile, projectDir, actionName: string, options: Options, isHook: bool ): tuple[output: string, exitCode: int, stdout: string] = @@ -135,6 +141,7 @@ proc getIniFile*(scriptName: string, options: Options): string = if exitCode == 0 and output.len != 0: result.writeFile(output) + stdout.writeExecutionOutput() else: raise newException(NimbleError, stdout & "\nprintPkgInfo() failed") @@ -175,6 +182,8 @@ proc execScript( result.flags[flag].add val.getStr() result.retVal = j{"retVal"}.getBool() + stdout.writeExecutionOutput() + proc execTask*(scriptName, taskName: string, options: Options): ExecutionResult[bool] = ## Executes the specified task in the specified script. diff --git a/tests/issue708/issue708.nimble b/tests/issue708/issue708.nimble new file mode 100644 index 0000000..ebb079d --- /dev/null +++ b/tests/issue708/issue708.nimble @@ -0,0 +1,17 @@ +# 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" diff --git a/tests/issue708/src/issue708.nim b/tests/issue708/src/issue708.nim new file mode 100644 index 0000000..4b2a270 --- /dev/null +++ b/tests/issue708/src/issue708.nim @@ -0,0 +1,7 @@ +# 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 diff --git a/tests/tester.nim b/tests/tester.nim index 5065606..c2d2a59 100644 --- a/tests/tester.nim +++ b/tests/tester.nim @@ -79,9 +79,19 @@ proc hasLineStartingWith(lines: seq[string], prefix: string): bool = return true 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 (output, exitCode) = execNimble("build") + var (_, exitCode) = execNimble("build") check exitCode == QuitSuccess test "depsOnly + flag order test":