Skip to content

[rfc] Replacing Boost Unit Test Framework? #34666

Open

Description

@maflcko

As this has comes up sometimes, I wanted to create a thread for this.

However, when replacing the current unit test framework, it is unclear what alternative could be suitable. It doesn't really make sense to drop one dependency and add a random other one.

When it comes to features that are currently missing, I recall only those so far:

Are there any other missing features?

If not, it may be easier to just implement our own thread-safe check macros, which abort to provide the fail-fast behavior? (I guess that catch_system_errors will have to be disabled for that somehow, not sure how to do that)

Activity

  1. hodlinator commented on Feb 25, 2026

    @hodlinator
    Contributor

    Note that in the case of #33878 (comment) the tests are being run directly through:

    ./bin/test_bitcoin.exe -l test_suite
    Running 725 test cases...
    Entering test module "Bitcoin Core Test Suite"
    

    If we were instead to run test_bitcoin indirectly through CTest there is --stop-on-failure which will prevent that worker thread from picking up additional tests after one fails, and make the other CTest worker threads stop after completing their current test.

  2. maflcko commented on Feb 25, 2026

    @maflcko
    MemberAuthor

    CTest

    Sure, but ctest is not available after the guix (or any other) cross-build, so I don't think this is a solution here. Also, ctest isn't going to offer a way to fail fast inside a test case, so that gdb can be attached on the first failure.

  3. hodlinator commented on Feb 25, 2026

    @hodlinator
    Contributor

    Sure, but ctest is not available after the guix (or any other) cross-build

    The relevant parts of the build-tree would need to be copied across for CTest to work.

    Tangent: I also just noticed DIR_UNIT_TEST_DATA isn't set by ci-windows-cross.py like it is by 03_test_script.sh, so script_assets_tests becomes a no-op.

  4. maflcko commented on Feb 25, 2026

    @maflcko
    MemberAuthor

    The relevant parts of the build-tree would need to be copied across for CTest to work.

    I don't think it is so easy. Usually, cross-compilation happens on a different storage device, or even OS (Linux->Windows), so all paths would have to re-written, at a minimum.

  5. brunoerg commented on Mar 4, 2026

    @brunoerg
    Contributor

    There is no --fail-fast option, possibly even attaching gdb automatically (#8670 (comment))

    A --fail-fast option would be super valuable for mutation testing.

  6. maflcko commented on Apr 21, 2026

    @maflcko
    MemberAuthor

    Another thing that is annoying is that in large tests, when a boost check failure occurs, the test will continue in CI, and produce log output, making it harder to see the actual failure. We don't tolerate check failures anyway, so they may as well be fatal (aka boost require checks).

    I guess this is the third reason to prefer a faster failing macro.

  7. hebasto commented on Apr 21, 2026

    @hebasto
    Member

    FWIW, libsecp256k1 now has its own test framework.

  8. maflcko commented on Apr 22, 2026

    @maflcko
    MemberAuthor

    FWIW, libsecp256k1 now has its own test framework.

    Ah, interesting. I think after fixing up the check macro behavior to what we want (done in #35139), we can probably stick with boost for now.

    I think the only remaining downside would be that boost is too slow to compile. The smallest C++ unit test framework would be doctest? But if we go the effort to replace boost with doctest, we may as well come up with a minimal unit test framework to match our needs. Or is there some other motivation other than compile time for the unit test framework after fixing the macros?

  9. maflcko commented on May 7, 2026

    @maflcko
    MemberAuthor

    If we keep boost test framework, we may want to use an iwyu mapping: #33966 (comment)

  10. fanquake commented on Sep 8, 2026

    @fanquake
    Member

    Maybe another (weak) reason to drop Boost Test, see ad71957 from #36193.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions