mirror of
https://github.com/status-im/nim-codex.git
synced 2025-02-08 00:44:53 +00:00
print start/finish stderr/stdout markers
# Conflicts: # tests/testIntegration.nim
This commit is contained in:
parent
9407c487ff
commit
2c31818f39
@ -1,7 +1,7 @@
|
|||||||
import std/os
|
import std/os
|
||||||
import std/strformat
|
import std/strformat
|
||||||
import std/strutils
|
|
||||||
import std/terminal
|
import std/terminal
|
||||||
|
from std/unicode import toUpper
|
||||||
import std/unittest
|
import std/unittest
|
||||||
import pkg/chronos
|
import pkg/chronos
|
||||||
import pkg/chronos/asyncproc
|
import pkg/chronos/asyncproc
|
||||||
@ -56,6 +56,10 @@ type
|
|||||||
Align {.pure.} = enum
|
Align {.pure.} = enum
|
||||||
Left, Right
|
Left, Right
|
||||||
|
|
||||||
|
MarkerPosition {.pure.} = enum
|
||||||
|
Start,
|
||||||
|
Finish
|
||||||
|
|
||||||
{.push raises: [].}
|
{.push raises: [].}
|
||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
@ -145,6 +149,17 @@ proc printResult(
|
|||||||
resetStyle, test.config.name,
|
resetStyle, test.config.name,
|
||||||
resetStyle, styleDim, &" ({test.duration})"
|
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(
|
proc printResult(
|
||||||
test: IntegrationTest,
|
test: IntegrationTest,
|
||||||
processOutput = false,
|
processOutput = false,
|
||||||
@ -154,15 +169,25 @@ proc printResult(
|
|||||||
error =? test.output.errorOption:
|
error =? test.output.errorOption:
|
||||||
test.printResult(fgRed)
|
test.printResult(fgRed)
|
||||||
if testHarnessErrors:
|
if testHarnessErrors:
|
||||||
|
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")
|
||||||
|
|
||||||
elif test.status == IntegrationTestStatus.Failed:
|
elif test.status == IntegrationTestStatus.Failed:
|
||||||
if output =? test.output:
|
if output =? test.output:
|
||||||
if testHarnessErrors: #manager.debugTestHarness
|
if testHarnessErrors: #manager.debugTestHarness
|
||||||
|
test.printOutputMarker(MarkerPosition.Start,
|
||||||
|
"test harness errors (stderr)")
|
||||||
echo output.stdError
|
echo output.stdError
|
||||||
|
test.printOutputMarker(MarkerPosition.Finish,
|
||||||
|
"test harness errors (stderr)")
|
||||||
if processOutput:
|
if processOutput:
|
||||||
|
test.printOutputMarker(MarkerPosition.Start,
|
||||||
|
"codex node output (stdout)")
|
||||||
echo output.stdOutput
|
echo output.stdOutput
|
||||||
|
test.printOutputMarker(MarkerPosition.Finish,
|
||||||
|
"codex node output (stdout)")
|
||||||
test.printResult(fgRed)
|
test.printResult(fgRed)
|
||||||
|
|
||||||
elif test.status == IntegrationTestStatus.Timeout:
|
elif test.status == IntegrationTestStatus.Timeout:
|
||||||
@ -171,7 +196,11 @@ proc printResult(
|
|||||||
elif test.status == IntegrationTestStatus.Ok:
|
elif test.status == IntegrationTestStatus.Ok:
|
||||||
if processOutput and
|
if processOutput and
|
||||||
output =? test.output:
|
output =? test.output:
|
||||||
|
test.printOutputMarker(MarkerPosition.Start,
|
||||||
|
"codex node output (stdout)")
|
||||||
echo output.stdOutput
|
echo output.stdOutput
|
||||||
|
test.printOutputMarker(MarkerPosition.Finish,
|
||||||
|
"codex node output (stdout)")
|
||||||
test.printResult(fgGreen)
|
test.printResult(fgGreen)
|
||||||
|
|
||||||
proc printSummary(test: IntegrationTest) {.raises: [TestManagerError].} =
|
proc printSummary(test: IntegrationTest) {.raises: [TestManagerError].} =
|
||||||
|
@ -41,8 +41,9 @@ proc run() {.async.} =
|
|||||||
let manager = TestManager.new(
|
let manager = TestManager.new(
|
||||||
configs = TestConfigs,
|
configs = TestConfigs,
|
||||||
debugTestHarness = true,
|
debugTestHarness = true,
|
||||||
debugCodexNodes = false,
|
# Echos stderr if there's a test failure or error (error in running the test)
|
||||||
# requires CodexConfig.debug to be enabled in the test file (on the marketplacesuite)
|
debugCodexNodes = true,
|
||||||
|
# Echos stdout from the Codex process (chronicles logs). If test uses a multinodesuite, requires CodexConfig.debug to be enabled
|
||||||
debugHardhat = false,
|
debugHardhat = false,
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user