print start/finish stderr/stdout markers

# Conflicts:
#	tests/testIntegration.nim
This commit is contained in:
Eric 2025-01-13 14:38:26 +11:00
parent 9407c487ff
commit 2c31818f39
No known key found for this signature in database
2 changed files with 33 additions and 3 deletions

View File

@ -1,7 +1,7 @@
import std/os
import std/strformat
import std/strutils
import std/terminal
from std/unicode import toUpper
import std/unittest
import pkg/chronos
import pkg/chronos/asyncproc
@ -56,6 +56,10 @@ type
Align {.pure.} = enum
Left, Right
MarkerPosition {.pure.} = enum
Start,
Finish
{.push raises: [].}
logScope:
@ -145,6 +149,17 @@ proc printResult(
resetStyle, test.config.name,
resetStyle, styleDim, &" ({test.duration})"
proc printOutputMarker(
test: IntegrationTest,
position: MarkerPosition,
msg: string) {.raises: [TestManagerError].} =
let newLine = if position == MarkerPosition.Start: "\n"
else: ""
styledEcho styleBright, bgWhite, fgBlack,
&"{newLine}----- {toUpper $position} {test.config.name} {msg} -----"
proc printResult(
test: IntegrationTest,
processOutput = false,
@ -154,15 +169,25 @@ proc printResult(
error =? test.output.errorOption:
test.printResult(fgRed)
if testHarnessErrors:
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:
if testHarnessErrors: #manager.debugTestHarness
test.printOutputMarker(MarkerPosition.Start,
"test harness errors (stderr)")
echo output.stdError
test.printOutputMarker(MarkerPosition.Finish,
"test harness errors (stderr)")
if processOutput:
test.printOutputMarker(MarkerPosition.Start,
"codex node output (stdout)")
echo output.stdOutput
test.printOutputMarker(MarkerPosition.Finish,
"codex node output (stdout)")
test.printResult(fgRed)
elif test.status == IntegrationTestStatus.Timeout:
@ -171,7 +196,11 @@ proc printResult(
elif test.status == IntegrationTestStatus.Ok:
if processOutput and
output =? test.output:
test.printOutputMarker(MarkerPosition.Start,
"codex node output (stdout)")
echo output.stdOutput
test.printOutputMarker(MarkerPosition.Finish,
"codex node output (stdout)")
test.printResult(fgGreen)
proc printSummary(test: IntegrationTest) {.raises: [TestManagerError].} =

View File

@ -41,8 +41,9 @@ proc run() {.async.} =
let manager = TestManager.new(
configs = TestConfigs,
debugTestHarness = true,
debugCodexNodes = false,
# requires CodexConfig.debug to be enabled in the test file (on the marketplacesuite)
# Echos stderr if there's a test failure or error (error in running the test)
debugCodexNodes = true,
# Echos stdout from the Codex process (chronicles logs). If test uses a multinodesuite, requires CodexConfig.debug to be enabled
debugHardhat = false,
)
try: