print hardhat testmanager errors and hardhat stdout when there is an error starting hardhat

This commit is contained in:
Eric 2025-01-15 10:39:41 +11:00
parent 84fb99189e
commit efcbcc7237
No known key found for this signature in database

View File

@ -71,6 +71,8 @@ type
logScope: logScope:
topics = "testing integration testmanager" topics = "testing integration testmanager"
proc printOutputMarker(test: IntegrationTest, position: MarkerPosition, msg: string) {.gcsafe, raises: [].}
proc raiseTestManagerError(msg: string, parent: ref CatchableError = nil) {.raises: [TestManagerError].} = proc raiseTestManagerError(msg: string, parent: ref CatchableError = nil) {.raises: [TestManagerError].} =
raise newException(TestManagerError, msg, parent) raise newException(TestManagerError, msg, parent)
@ -188,6 +190,11 @@ proc startHardhat(
except CancelledError as e: except CancelledError as e:
raise e raise e
except CatchableError as 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 raiseTestManagerError "hardhat node failed to start: " & e.msg, e
proc printResult( proc printResult(
@ -220,11 +227,10 @@ proc printResult(
if test.status == IntegrationTestStatus.Error and if test.status == IntegrationTestStatus.Error and
error =? test.output.errorOption: error =? test.output.errorOption:
test.printResult(fgRed) test.printResult(fgRed)
if printStdErr: test.printOutputMarker(MarkerPosition.Start, "test harness errors")
test.printOutputMarker(MarkerPosition.Start, "test harness errors") echo "Error during test execution: ", error.msg
echo "Error during test execution: ", error.msg echo "Stacktrace: ", error.getStackTrace()
echo "Stacktrace: ", error.getStackTrace() test.printOutputMarker(MarkerPosition.Finish, "test harness errors")
test.printOutputMarker(MarkerPosition.Finish, "test harness errors")
elif test.status == IntegrationTestStatus.Failed: elif test.status == IntegrationTestStatus.Failed:
if output =? test.output: if output =? test.output:
@ -352,10 +358,11 @@ proc runTest(
test.timeEnd = Moment.now() test.timeEnd = Moment.now()
test.status = IntegrationTestStatus.Error test.status = IntegrationTestStatus.Error
test.output = CommandExResponse.failure(e) test.output = CommandExResponse.failure(e)
test.printResult(printStdOut = manager.debugCodexNodes, test.printResult(printStdOut = manager.debugHardhat or manager.debugCodexNodes,
printStdErr = manager.debugTestHarness) printStdErr = manager.debugTestHarness)
return return
trace "Starting parallel integration test", command trace "Starting parallel integration test", command
test.printStart() test.printStart()
test.process = execCommandEx( test.process = execCommandEx(