Remove boost as a unit test runner

bitcoin/bitcoin: PR #35713

1 minor finding · 7 suggestions

Earlier concerns neither republished nor resolved: 3 minor findings · 4 suggestions. See the Run archive for their assessments.

Findings

Link

[minor] · Exception-check macros swallow REQUIRE's abort sentinel

Exception-check macros swallow a failing nested REQUIRE and continue the test, although it remains failed; no current caller producing this nesting was found.

Location: src/test/util/framework.h:629 (head).

Details and suggested fix

If an expression evaluated by CHECK_THROWS, CHECK_NOTHROW, CHECK_THROWS_AS, or CHECK_EXCEPTION calls a helper whose owner-thread REQUIRE fails, the macro catches ::framework::RequireFailed instead of letting it reach run(). This also affects their Boost compatibility shims. CHECK_THROWS treats the sentinel as an expected exception; the other macros normally record another failure. Either way, subsequent test code runs on state the requirement was supposed to guard. The case remains failed because REQUIRE already recorded its failure. Add catch (const ::framework::RequireFailed&) { throw; } before the ordinary exception handlers in these macros. REQUIRE_NOTHROW already preserves abortion by throwing a fresh sentinel.


Optional improvements

Link

[suggestion] · TEST_SUITE_BEGIN is invisible to CTest discovery and naming lint

No suite uses TEST_SUITE_BEGIN directly yet, but migrating to the new macro would silently remove its CTest entry and naming checks.

Location: src/test/util/framework.h:494 (head).

Details and suggested fix

add_boost_test() reads each source file and creates CTest entries only for BOOST_FIXTURE_TEST_SUITE and BOOST_AUTO_TEST_SUITE. A suite declared with TEST_SUITE_BEGIN still registers its cases and runs under a bare test_bitcoin, but CMake never discovers it for ctest --test-dir build. lint-tests.py also omits the new spelling from both discovery and name validation. Extend the suite-matching expressions in CMake and the lint to recognize TEST_SUITE_BEGIN, so the advertised migration preserves test discovery.


Link

[suggestion] · Legacy assertion failures print an unrelated << hint

Every failed BOOST_CHECK, BOOST_CHECK_MESSAGE, or BOOST_REQUIRE prints formatting advice even though its shim never attempts value formatting.

Location: src/test/util/framework.h:758 (head).

Details and suggested fix

These shims expand to CHECK_NO_DISPLAY or REQUIRE_NO_DISPLAY, which attach the fixed “Unable to produce an expression” message and advice to implement <<. record_check() then prints that text below the failed assertion. An ordinary false condition therefore receives the same advice even when all relevant types are printable. Use a neutral diagnostic such as “expression evaluated to false” on the compatibility-shim path, reserving the formatting hint for explicit use of the no-display macros. Pass/fail behavior can remain unchanged.


Link

[suggestion] · Runner selection and failure exits lack dedicated self-tests

Passing migrated suites do not verify failure accounting or selection edge cases, including the empty-selection output that CTest treats as SKIP.

Location: src/test/util/framework.cpp:403 (head).

Details and suggested fix

matches_filter() and parse_args() have no direct tests. If matching regressed to select nothing, the runner would print no test cases matching filter, which the per-suite CTest entries treat as SKIP. Failure accounting also needs negative coverage: run() silently catches RequireFailed and relies on the assertion having already recorded failure. Add table-driven tests for suite/case filters, wildcard and list handling, option abbreviations, and missing values. Also add a small executable linked to test_framework with deliberately failing CHECK, REQUIRE, and throwing cases, then have a harness verify its exit status and output. Exercise colon normalization through the runner, where it occurs, and keep intentional failures outside test_bitcoin.


Link

[suggestion] · src/test/README.md still describes the Boost runner's error interception

The README's runner description and core-dump instructions no longer match the in-tree test runner.

Location: src/test/util/framework.cpp:311 (head).

Details and suggested fix

The README identifies Boost as the runner, describes its command-line interface, and says system errors are intercepted unless users pass --catch_system_errors=no. The replacement supports only its implemented Boost-compatible options, accepts --catch_system_errors=no as a no-op, and rejects --catch_system_errors=yes. It catches C++ exceptions but does not intercept segmentation faults, so core-dump availability depends on operating-system settings and limits rather than that flag. Update the runner description and debugging paragraph accordingly. The existing --log_level=all --run_test=getarg_tests and short-option examples remain valid.


Link

[suggestion] · CTest's bare suite filters also select matching case names

A cross-suite name collision would duplicate execution under an unrelated CTest entry, although no current collision was identified.

Location: src/test/util/framework.cpp:181 (head).

Details and suggested fix

matches_filter() accepts a slash-free token when either the suite or the case name matches. CTest passes --run_test=${test_suite_name} for each suite, so a case in suite A named like suite B would also run in B's entry. Its actual A/name context and fixture remain correct, but execution is duplicated and any failure appears under an unrelated CTest name. Have CMake pass --run_test=${test_suite_name}/* to express suite-only selection while retaining the documented manual bare-case filters.


Link

[suggestion] · Duplicate test names register without a uniqueness guard

The registry accepts duplicate suite/name labels without warning; no current duplicate was identified.

Location: src/test/util/framework.h:488 (head).

Details and suggested fix

FIXTURE_TEST_CASE derives its implementation namespace from __LINE__ and only stringifies the supplied case name. BOOST_AUTO_TEST_CASE uses that macro directly, and Registrar appends without checking uniqueness. Two declarations on different lines can therefore produce identical labels, making filters select both and their output indistinguishable. With -testdatadir, both also resolve to the same retained directory: after the first fixture releases its lock, the second fixture's setup removes that directory. Reject duplicate suite/name pairs in run() before executing any case.


Link

[suggestion] · Child-thread support omits the context lifetime limit

The thread-aware API omits its context lifetime limit; no escaping worker was found, so this is a documentation suggestion, not a demonstrated regression.

Location: src/test/util/framework.h:196 (head).

Details and suggested fix

TestContext is described as shared with child threads, but run() owns it on the stack and destroys it after the registered test function returns. CHECK acquires a context reference before evaluating its expression, and InfoScopeGuard retains one. Clearing the global pointer cannot revoke those references; an escaping worker can access an expired context or obtain the next test's context. Document in the TestContext and assertion comments that framework-using workers must finish before the test returns. Fixture-owned workers joined during fixture teardown are safe because that teardown completes inside the registered runner.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.