Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Catch2 v3 #147

Merged
merged 3 commits into from
Jan 10, 2024
Merged

Migrate to Catch2 v3 #147

merged 3 commits into from
Jan 10, 2024

Conversation

tcbrindle
Copy link
Owner

Most of our tests are done at constexpr time, but we also use Catch2 to run the same tests at runtime.

Until now, we've bundled an old version of the Catch2 v2 header for this purpose. Meanwhile, Catch2 v3 has been released, which is no longer header-only, and is now a "proper" library.

This commit migrates us to using Catch2 v3, downloading it via CMake's "FetchContent" if it's not already available on the system. This has the benefit that it will be much easier to update Catch in the future (by just updating the commit id in tests/CMakeLists.txt), and also means that we no longer need to keep copies of Catch.cmake and CatchAddTests.cmake (as these can now be found via the downloaded library).

Unfortunately, the latest Catch includes a macro called STATIC_CHECK, which clashes with our own macro of the same name defined in test_utils.hpp. Because this macro is used literally thousands of times in our tests, this commit takes the easy route of #undef-ing the Catch version instead of changing our macro name.

The stated goal of Catch moving away from a single header is to improve compile times: however, since now we'll need to download and build the Catch library for every single CI run, I'm a bit worried our CI times might go through the roof. Let's see what happens...

Most of our tests are done at constexpr time, but we also use Catch2 to run the same tests at runtime.

Until now, we've bundled an old version of the Catch2 v2 header for this purpose. Meanwhile, Catch2 v3 has been released, which is no longer header-only, and is now a "proper" library.

This commit migrates us to using Catch2 v3, downloading it via CMake's "FetchContent" if it's not already available on the system. This has the benefit that it will be much easier to update Catch in the future (by just updating the commit id in tests/CMakeLists.txt), and also means that we no longer need to keep copies of Catch.cmake and CatchAddTests.cmake (as these can now be found via the downloaded library).

Unfortunately, the latest Catch includes a macro called STATIC_CHECK, which clashes with our own macro of the same name defined in test_utils.hpp. Because this macro is used literally thousands of times in our tests, this commit takes the easy route of #undef-ing the Catch version instead.

The stated goal of Catch moving away from a single header is to improve compile times: however, since now we'll need to download and build the Catch library for every single CI run, I'm a bit worried our CI times might go through the roof. Let's see what happens...
Copy link

codecov bot commented Jan 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (654a553) 97.98% compared to head (d53fe96) 97.98%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #147   +/-   ##
=======================================
  Coverage   97.98%   97.98%           
=======================================
  Files          66       66           
  Lines        2383     2383           
=======================================
  Hits         2335     2335           
  Misses         48       48           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

The MacOS CI runs are already the bottleneck, and it will only get worse when we (hopefully, one day) add AppleClang into the mix.

To try to make things a bit quicker, we'll only test with the latest GCC on MacOS, since GCC 12 is already covered by the Linux CI.
@tcbrindle
Copy link
Owner Author

...and the results are in. CI times are a little slower, but not dramatically so, and I think the trade-off of making it easier to keep up with the latest Catch development is probably worth it.

@tcbrindle tcbrindle merged commit c687a3c into main Jan 10, 2024
25 checks passed
@tcbrindle tcbrindle deleted the pr/catch2_v3 branch January 20, 2024 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant