From efcbcc723771ceb59a99fcba01816ba4cbb36434 Mon Sep 17 00:00:00 2001 From: Eric <5089238+emizzle@users.noreply.github.com> Date: Wed, 15 Jan 2025 10:39:41 +1100 Subject: [PATCH] print hardhat testmanager errors and hardhat stdout when there is an error starting hardhat --- tests/integration/testmanager.nim | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/integration/testmanager.nim b/tests/integration/testmanager.nim index c232ba64..1048abbe 100644 --- a/tests/integration/testmanager.nim +++ b/tests/integration/testmanager.nim @@ -71,6 +71,8 @@ type logScope: topics = "testing integration testmanager" +proc printOutputMarker(test: IntegrationTest, position: MarkerPosition, msg: string) {.gcsafe, raises: [].} + proc raiseTestManagerError(msg: string, parent: ref CatchableError = nil) {.raises: [TestManagerError].} = raise newException(TestManagerError, msg, parent) @@ -188,6 +190,11 @@ proc startHardhat( except CancelledError as e: raise e except CatchableError as e: + if not hardhat.isNil: + test.printOutputMarker(MarkerPosition.Start, "hardhat stdout") + for line in hardhat.output: + echo line + test.printOutputMarker(MarkerPosition.Finish, "hardhat stdout") raiseTestManagerError "hardhat node failed to start: " & e.msg, e proc printResult( @@ -220,11 +227,10 @@ proc printResult( if test.status == IntegrationTestStatus.Error and error =? test.output.errorOption: test.printResult(fgRed) - if printStdErr: - test.printOutputMarker(MarkerPosition.Start, "test harness errors") - echo "Error during test execution: ", error.msg - echo "Stacktrace: ", error.getStackTrace() - test.printOutputMarker(MarkerPosition.Finish, "test harness errors") + test.printOutputMarker(MarkerPosition.Start, "test harness errors") + echo "Error during test execution: ", error.msg + echo "Stacktrace: ", error.getStackTrace() + test.printOutputMarker(MarkerPosition.Finish, "test harness errors") elif test.status == IntegrationTestStatus.Failed: if output =? test.output: @@ -352,10 +358,11 @@ proc runTest( test.timeEnd = Moment.now() test.status = IntegrationTestStatus.Error test.output = CommandExResponse.failure(e) - test.printResult(printStdOut = manager.debugCodexNodes, + test.printResult(printStdOut = manager.debugHardhat or manager.debugCodexNodes, printStdErr = manager.debugTestHarness) return + trace "Starting parallel integration test", command test.printStart() test.process = execCommandEx(