Don't store hardhat logs in memory and do not print to term even if DebugHardhat=true

Hardhat output is logged to file in hardhat.log for each test, and printing to screen is not necessarily needed as it is already logged to file and can create clutter in the output, so stop writing logging output to memory and writing to screen.
This commit is contained in:
Eric 2025-03-24 15:40:13 +11:00
parent f09c4357c9
commit 67ebe0b3e3
No known key found for this signature in database

View File

@ -18,7 +18,6 @@ import ../examples
type
Hardhat = ref object
process: HardhatProcess
output: seq[string]
port: int
TestManagerConfig* = object # Echoes stdout from Hardhat process
@ -199,9 +198,6 @@ proc startHardhat(
let hardhat = Hardhat.new()
proc onOutputLineCaptured(line: string) {.raises: [].} =
hardhat.output.add line
withLock(test.manager.hardhatPortLock):
port = await nextFreePort(test.manager.lastHardhatPort + 1)
test.manager.lastHardhatPort = port
@ -215,7 +211,7 @@ proc startHardhat(
try:
withLock(test.manager.hardhatProcessLock):
let node = await HardhatProcess.startNode(
args, false, "hardhat for '" & test.config.name & "'", onOutputLineCaptured
args, false, "hardhat for '" & test.config.name & "'"
)
hardhat.process = node
hardhat.port = port
@ -224,11 +220,6 @@ 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(test: IntegrationTest, colour: ForegroundColor) =
@ -396,12 +387,6 @@ proc teardownHardhat(test: IntegrationTest, hardhat: Hardhat) {.async: (raises:
warn "Failed to stop hardhat node, continuing",
error = e.msg, test = test.config.name
if test.manager.config.debugHardhat:
test.printOutputMarker(MarkerPosition.Start, "Hardhat stdout")
for line in hardhat.output:
echo line
test.printOutputMarker(MarkerPosition.Finish, "Hardhat stdout")
test.manager.hardhats.keepItIf(it != hardhat)
proc teardownTest(test: IntegrationTest) {.async: (raises: []).} =