Skip to content

build: include only used Catch2 v3 headers instead of catch_all.hpp - #1062

Open
ahans wants to merge 1 commit into
mainfrom
catch2-v3-granular-includes
Open

ahans wants to merge 1 commit into
mainfrom
catch2-v3-granular-includes

Conversation

@ahans

@ahans ahans commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

The test runner has been using Catch2 v3 for a while, so individual headers are available. Using those instead of catch_all.hpp is best practice and speeds up compilation.

The test runner has been using Catch2 v3 for a while, so individual headers are
available. Using those instead of catch_all.hpp is best practice and speeds up
compilation.
@github-actions

Copy link
Copy Markdown
Contributor

This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested.

If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos.

[no important files changed]

For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping @exercism/maintainers-admin in a comment. Thank you!

@ahans

ahans commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

@exercism-bot @exercism-agent Test this change on a few recent student solutions with the cpp-test-runner and report any failures and changes in runtime. I'm interested in runtimes of current main, runtimes with changes of this PR, and this PR in combination with exercism/cpp-test-runner#115

@exercism-agent

Copy link
Copy Markdown
Contributor

@ahans I ran this on recent published community solutions to 11 exercises: two-fer, log-levels, freelancer-rates, interest-is-interesting, vehicle-purchase, space-age, complex-numbers, clock, triangle, kindergarten-garden and word-count. These include the exercises that now use the floating-point matchers, catch_message.hpp and catch_tostring.hpp. The runs were on an x86 t3.medium, the same as production. Each solution was run cold (page cache dropped first) and then warm, with each runner image on each version of the track.

Times are for the whole docker run, in seconds.

Runner Track Cold median Cold p95 Warm median Warm p95
main main 4.31 4.91 2.50 3.13
main #1062 3.51 4.14 1.85 2.45
#115 main 3.86 4.30 2.14 2.63
#115 #1062 3.04 3.57 1.47 1.93

With the current runner, this PR cuts the warm median by 26%. Together with exercism/cpp-test-runner#115, the warm median drops by 41%.

No solution changed its overall status or any test's status between track main and this PR, on either runner. Three solutions (all kindergarten-garden) fail on every combination. Two of them fail the same way each time: one crashes at runtime, and one is missing #include <algorithm> in its own code.

The third one shows different compiler output. Its header uses std::array without including <array>. On track main, catch_all.hpp included <array> for the test file, so the only errors came from the solution's own .cpp file. With this PR, the test file doesn't get <array> either, so with the current runner (make) the first errors come from the test file. With #115 the error text is the same as on track main. The solution failed to compile before this change as well.

@ahans
ahans marked this pull request as ready for review November 30, 2026 14:04
@ahans

ahans commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

I think this would be better than the precompiled header. It's best practice and helps students working locally. Also, the solutions that now fail due to missing includes that before relied on transitive includes from catch_all.hpp were already broken before IMHO and only accidentally worked. It's good to flag them. While I hadn't considered that, I think it's actually another win. @vaeng @siebenschlaefer Wdty?

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