From efd960fc7e93712e89c568e7eb8d117d98a59335 Mon Sep 17 00:00:00 2001 From: Eric <5089238+emizzle@users.noreply.github.com> Date: Wed, 22 Jan 2025 17:55:31 +1100 Subject: [PATCH] allow test parameters to be set from make testIntegration command --- Makefile | 20 +++++++++++++++++- tests/testIntegration.nim | 44 +++++++++++++++++++-------------------- 2 files changed, 41 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 3dfe8e7e..032d7ae2 100644 --- a/Makefile +++ b/Makefile @@ -141,10 +141,28 @@ testContracts: | build deps echo -e $(BUILD_MSG) "build/$@" && \ $(ENV_SCRIPT) nim testContracts $(NIM_PARAMS) build.nims +TEST_PARAMS := +ifdef DEBUG_TESTHARNESS + TEST_PARAMS := $(TEST_PARAMS) -d:DebugTestHarness=$(DEBUG_TESTHARNESS) +endif +ifdef DEBUG_HARDHAT + TEST_PARAMS := $(TEST_PARAMS) -d:DebugHardhat=$(DEBUG_HARDHAT) +endif +ifdef DEBUG_CODEXNODES + TEST_PARAMS := $(TEST_PARAMS) -d:DebugCodexNodes=$(DEBUG_CODEXNODES) +endif +ifdef DEBUG_UPDATES + TEST_PARAMS := $(TEST_PARAMS) -d:ShowContinuousStatusUpdates=$(DEBUG_UPDATES) +endif +ifdef TEST_TIMEOUT + TEST_PARAMS := $(TEST_PARAMS) -d:TestTimeout=$(TEST_TIMEOUT) +endif + # Builds and runs the integration tests testIntegration: | build deps + echo TEST PARAMS: $(TEST_PARAMS) echo -e $(BUILD_MSG) "build/$@" && \ - $(ENV_SCRIPT) nim testIntegration $(NIM_PARAMS) build.nims + $(ENV_SCRIPT) nim testIntegration $(TEST_PARAMS) $(NIM_PARAMS) build.nims # Builds and runs all tests (except for Taiko L2 tests) testAll: | build deps diff --git a/tests/testIntegration.nim b/tests/testIntegration.nim index e4ce404b..b0b579a6 100644 --- a/tests/testIntegration.nim +++ b/tests/testIntegration.nim @@ -30,23 +30,23 @@ const TestConfigs = IntegrationTestConfig.init("./integration/testecbug", startHardhat = true) ] -proc run() {.async.} = - # Echoes stderr if there's a test failure (eg test failed, compilation error) - # or error (eg test manager error) - const debugTestHarness = false - # Echoes stdout from Hardhat process - const debugHardhat = false - # Echoes stdout from the integration test file process. Codex process logs can - # also be output if a test uses a multinodesuite, requires CodexConfig.debug - # to be enabled - const debugCodexNodes = true - # Shows test status updates at time intervals. Useful for running locally with - # active terminal interaction. Set to false for unattended runs, eg CI. - const showContinuousStatusUpdates = false - # Timeout duration for EACH integration test file. - const testTimeout = 60.minutes +# Echoes stderr if there's a test failure (eg test failed, compilation error) +# or error (eg test manager error) +const DebugTestHarness {.booldefine.} = false +# Echoes stdout from Hardhat process +const DebugHardhat {.booldefine.} = false +# Echoes stdout from the integration test file process. Codex process logs can +# also be output if a test uses a multinodesuite, requires CodexConfig.debug +# to be enabled +const DebugCodexNodes {.booldefine.} = true +# Shows test status updates at time intervals. Useful for running locally with +# active terminal interaction. Set to false for unattended runs, eg CI. +const ShowContinuousStatusUpdates {.booldefine.} = false +# Timeout duration (in mimutes) for EACH integration test file. +const TestTimeout {.intdefine.} = 60 - when debugTestHarness and enabledLogLevel != LogLevel.TRACE: +proc run() {.async.} = + when DebugTestHarness and enabledLogLevel != LogLevel.TRACE: styledEcho bgWhite, fgBlack, styleBright, "\n\n ", styleUnderscore, "ADDITIONAL LOGGING AVAILABILE\n\n", resetStyle, bgWhite, fgBlack, styleBright, @@ -56,7 +56,7 @@ proc run() {.async.} = resetStyle, bgWhite, fgBlack, "\n\n nim c -d:chronicles_log_level=TRACE -r ./testIntegration.nim\n\n" - when debugCodexNodes: + when DebugCodexNodes: styledEcho bgWhite, fgBlack, styleBright, "\n\n ", styleUnderscore, "ENABLE CODEX LOGGING\n\n", resetStyle, bgWhite, fgBlack, styleBright, @@ -68,11 +68,11 @@ proc run() {.async.} = let manager = TestManager.new( configs = TestConfigs, - debugTestHarness, - debugHardhat, - debugCodexNodes, - showContinuousStatusUpdates, - testTimeout, + DebugTestHarness, + DebugHardhat, + DebugCodexNodes, + ShowContinuousStatusUpdates, + TestTimeout.minutes, ) try: trace "starting test manager"