tcbrindle / flux

A C++20 library for sequence-orientated programming
https://tristanbrindle.com/flux/
Boost Software License 1.0
476 stars 29 forks source link

Move tests from Catch to Doctest #197

Closed tcbrindle closed 1 month ago

tcbrindle commented 1 month ago

Catch2 v3 is no longer a header-only library, and requires a build step. If it was just a single file taking a couple of seconds this would be no problem, but instead it's annoyingly slow -- building Catch takes far longer than actually building our own tests.

Even this might be worth it if we used all of Catch's advanced functionality, but really we barely scratch the surface of what it can do, just using the basic macros.

Instead of using Catch, this PR migrates to using Doctest instead, hopefully leading to faster build times.

Because Doctest uses (mostly) the same macro names as Catch, migration is pretty easy -- most of the diff is just changing headers. The only other difference is changing Catch's SECTION(...) to Doctest's SUBCASE(...)

It's worth noting that Doctest may be unmaintained. I don't consider this a huge risk at the moment because the library seems very stable, and it's well used within the C++ community. But if things start to bit-rot in future we can always move back to Catch, or some other test framework.

Some numbers on my system...

With Clang 18, using Flux module:

With GCC 14:

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 98.22%. Comparing base (c957fc3) to head (ffac8f3).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #197 +/- ## ======================================= Coverage 98.22% 98.22% ======================================= Files 69 69 Lines 2360 2360 ======================================= Hits 2318 2318 Misses 42 42 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.