2025-01-16 11:52:02 +11:00
|
|
|
import std/terminal
|
2024-12-20 16:23:40 +11:00
|
|
|
import pkg/chronos
|
|
|
|
|
import pkg/codex/logutils
|
|
|
|
|
import ./integration/testmanager
|
2022-05-18 14:31:45 +02:00
|
|
|
|
2023-03-09 12:23:45 +01:00
|
|
|
{.warning[UnusedImport]: off.}
|
2024-12-20 16:23:40 +11:00
|
|
|
|
|
|
|
|
const TestConfigs =
|
|
|
|
|
@[
|
2025-01-13 14:39:07 +11:00
|
|
|
IntegrationTestConfig.init("./integration/testcli", startHardhat = true),
|
2025-01-16 11:52:02 +11:00
|
|
|
IntegrationTestConfig.init("./integration/testrestapi", startHardhat = true),
|
|
|
|
|
IntegrationTestConfig.init("./integration/testupdownload", startHardhat = true),
|
|
|
|
|
IntegrationTestConfig.init("./integration/testsales", startHardhat = true),
|
|
|
|
|
IntegrationTestConfig.init("./integration/testpurchasing", startHardhat = true),
|
|
|
|
|
IntegrationTestConfig.init("./integration/testblockexpiration", startHardhat = true),
|
|
|
|
|
IntegrationTestConfig.init("./integration/testmarketplace", startHardhat = true),
|
|
|
|
|
IntegrationTestConfig.init("./integration/testproofs", startHardhat = true),
|
|
|
|
|
IntegrationTestConfig.init("./integration/testvalidator", startHardhat = true),
|
|
|
|
|
IntegrationTestConfig.init("./integration/testecbug", startHardhat = true),
|
2025-01-13 14:39:07 +11:00
|
|
|
IntegrationTestConfig.init(
|
2025-01-16 11:52:02 +11:00
|
|
|
"./integration/testrestapivalidation", startHardhat = true
|
|
|
|
|
),
|
2024-12-20 16:23:40 +11:00
|
|
|
]
|
|
|
|
|
|
2025-01-22 17:55:31 +11:00
|
|
|
# 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
|
2025-02-05 18:31:40 +11:00
|
|
|
const DebugCodexNodes {.booldefine.} = false
|
2025-01-22 17:55:31 +11:00
|
|
|
# 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
|
2025-01-16 11:52:02 +11:00
|
|
|
|
2025-02-03 19:04:24 +11:00
|
|
|
const EnableParallelTests {.booldefine.} = true
|
|
|
|
|
|
2025-02-28 22:42:01 +11:00
|
|
|
proc run(): Future[bool] {.async: (raises: []).} =
|
2024-12-20 16:23:40 +11:00
|
|
|
let manager = TestManager.new(
|
2025-01-10 23:22:34 +11:00
|
|
|
configs = TestConfigs,
|
2025-01-22 17:55:31 +11:00
|
|
|
DebugTestHarness,
|
|
|
|
|
DebugHardhat,
|
|
|
|
|
DebugCodexNodes,
|
|
|
|
|
ShowContinuousStatusUpdates,
|
|
|
|
|
TestTimeout.minutes,
|
2024-12-20 16:23:40 +11:00
|
|
|
)
|
|
|
|
|
try:
|
|
|
|
|
trace "starting test manager"
|
|
|
|
|
await manager.start()
|
2025-02-28 22:42:01 +11:00
|
|
|
except TestManagerError as e:
|
|
|
|
|
error "Failed to run test manager", error = e.msg
|
|
|
|
|
return false
|
|
|
|
|
except CancelledError:
|
|
|
|
|
return
|
2024-12-20 16:23:40 +11:00
|
|
|
finally:
|
|
|
|
|
trace "stopping test manager"
|
2025-02-28 22:42:01 +11:00
|
|
|
await noCancel manager.stop()
|
|
|
|
|
trace "test manager stopped"
|
2024-12-20 16:23:40 +11:00
|
|
|
|
2025-01-28 20:49:12 +11:00
|
|
|
without wasSuccessful =? manager.allTestsPassed, error:
|
2025-01-28 18:58:43 +11:00
|
|
|
raiseAssert "Failed to get test status: " & error.msg
|
|
|
|
|
|
2025-02-28 22:42:01 +11:00
|
|
|
return wasSuccessful
|
2025-01-28 18:58:43 +11:00
|
|
|
|
2025-02-03 19:04:24 +11:00
|
|
|
when EnableParallelTests:
|
2025-02-28 22:42:01 +11:00
|
|
|
let wasSuccessful = waitFor run()
|
|
|
|
|
trace "[testIntegration] wasSuccessful", wasSuccessful
|
|
|
|
|
trace "[testIntegration] AFTER run"
|
|
|
|
|
if not wasSuccessful:
|
|
|
|
|
quit(QuitFailure) # indicate with a non-zero exit code that the tests failed
|
2025-02-03 19:04:24 +11:00
|
|
|
else:
|
|
|
|
|
# run tests serially
|
|
|
|
|
import ./integration/testcli
|
|
|
|
|
import ./integration/testrestapi
|
|
|
|
|
import ./integration/testupdownload
|
|
|
|
|
import ./integration/testsales
|
|
|
|
|
import ./integration/testpurchasing
|
|
|
|
|
import ./integration/testblockexpiration
|
|
|
|
|
import ./integration/testmarketplace
|
|
|
|
|
import ./integration/testproofs
|
|
|
|
|
import ./integration/testvalidator
|
|
|
|
|
import ./integration/testecbug
|