From 0ff416d6d2f078bbc65eb8bd2f272b35a998d58d Mon Sep 17 00:00:00 2001 From: rustaceanrob Date: Tue, 23 Jun 2026 09:22:29 +0100 Subject: [PATCH] test: Small touchups to the framework - Makes the exception bool atomic - Changes the pass/fail method to `passed`, since the only callsite was negating it with `!` --- src/test/util/framework.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/util/framework.hpp b/src/test/util/framework.hpp index 9e8e79de4807..4b39dac53333 100644 --- a/src/test/util/framework.hpp +++ b/src/test/util/framework.hpp @@ -155,7 +155,7 @@ class TestContext private: std::atomic m_checks{0}; std::atomic m_failed{0}; - bool m_did_throw{false}; + std::atomic m_did_throw{false}; const std::string m_full_name; const std::thread::id m_owner_thread{std::this_thread::get_id()}; @@ -185,12 +185,12 @@ class TestContext void exception_occured() { - m_did_throw = true; + m_did_throw.store(true, std::memory_order_relaxed); } - bool did_fail() + bool passed() { - return m_did_throw || m_failed.load(std::memory_order_relaxed) > 0; + return !m_did_throw.load(std::memory_order_relaxed) || m_failed.load(std::memory_order_relaxed) == 0; } TestStats stats() const noexcept @@ -514,7 +514,7 @@ inline int run(int argc, char** argv) } const auto stats = ctx.stats(); summary.total_checks += stats.checks; - if (!ctx.did_fail()) { + if (ctx.passed()) { ++summary.passed; log(LogLevel::Info, "[ OK ] %s (%d checks)\n", test_case.name, stats.checks); } else {