From a6214d693bc80c6a77e62bb82527720c4f62f6cf Mon Sep 17 00:00:00 2001 From: Eric <5089238+emizzle@users.noreply.github.com> Date: Tue, 28 Jan 2025 18:58:43 +1100 Subject: [PATCH] indicate with exit code 1 if the tests failed --- tests/integration/testmanager.nim | 10 ++++++++++ tests/testIntegration.nim | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/tests/integration/testmanager.nim b/tests/integration/testmanager.nim index 4d5097f3..08822523 100644 --- a/tests/integration/testmanager.nim +++ b/tests/integration/testmanager.nim @@ -157,6 +157,16 @@ proc duration(manager: TestManager): Duration = let now = Moment.now() (manager.timeEnd |? now) - (manager.timeStart |? now) +proc testsStatus*(manager: TestManager): ?!bool = + for test in manager.tests: + if test.status in {IntegrationTestStatus.New, IntegrationTestStatus.Running}: + return failure "Integration tests not complete" + + if test.status != IntegrationTestStatus.Ok: + return success true + + return success false + proc duration(test: IntegrationTest): Duration = let now = Moment.now() (test.timeEnd |? now) - (test.timeStart |? now) diff --git a/tests/testIntegration.nim b/tests/testIntegration.nim index 275e8ea5..862ce0a1 100644 --- a/tests/testIntegration.nim +++ b/tests/testIntegration.nim @@ -75,4 +75,10 @@ proc run() {.async.} = trace "stopping test manager" await manager.stop() + without wasSuccessful =? manager.testsStatus, error: + raiseAssert "Failed to get test status: " & error.msg + + if not wasSuccessful: + quit(1) # indicate with a non-zero exit code that the tests failed + waitFor run()