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

Use doctest instead of Catch2 for tests #1064

Merged
merged 5 commits into from
Jan 16, 2025
Merged

Use doctest instead of Catch2 for tests #1064

merged 5 commits into from
Jan 16, 2025

Conversation

azrogers
Copy link
Contributor

Closes #69. We've been intending for quite a while to switch to doctest for tests instead of our current test framework, Catch2. Not only is doctest the test framework that other Cesium projects use, but the compile times are also quite a bit faster. It would be good to get this out of the way while we have the chance - as @kring mentioned, it will only get more difficult as time goes on.

@azrogers
Copy link
Contributor Author

I'll note that while the point of this is mostly to improve test build times, the test builds seem slower on CI. Subjectively, they're faster on my machine now, so maybe this is just an artifact of doctest not yet being cached? Not sure. A larger sample size is probably needed.

@kring
Copy link
Member

kring commented Jan 16, 2025

the test builds seem slower on CI

cesium-native aggressively uses ccache on CI, so it won't even compile source files at all if they don't change. It makes our CI builds really fast, but also makes it impossible to compare build performance on CI. So I wouldn't worry about that, but if you have any doubts about the local performance actually improving, it might be worth doing a quick measurement just to make sure.

Copy link
Member

@kring kring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this @azrogers! Minor comments...

@@ -15,6 +13,24 @@
#include <string>
#include <vector>

using namespace doctest;

bool compareVectors(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in the anonymous namespace. Or maybe moved to CesiumNativeTests?


#include <bitset>
#include <climits>
#include <cstddef>
#include <cstring>
#include <ostream>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this header needed?

@@ -21,13 +21,14 @@
#include <glm/fwd.hpp>

#include <cstdint>
#include <ostream>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why ostream is needed here, either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think I could really tell you either, but it is apparently needed: https://github.com/CesiumGS/cesium-native/actions/runs/12797730812/job/35680280884

@azrogers
Copy link
Contributor Author

Ran though this script on this branch and the current main:

rm benchmark.log
for i in $(seq 1 10);
do
    cmake -B build_benchmark -S .
    /usr/bin/time -f "%e" -o benchmark.log -a cmake --build build_benchmark -j22
    rm -rf build_benchmark
done

awk '{s+=$1}END{print "average time:", s/NR}' RS="\n" benchmark.log

Average time per build on this branch (doctest): 210.464 seconds
Average time per build on main (Catch2): 230.288 seconds

So doctest does speed up the build, but only by around 20 seconds. That probably indicates our main slowdowns while building lie outside of the tests. I discovered ClangBuildAnalyzer while looking for how to benchmark this which could be worth trying out in the future to save build time elsewhere (#1066). But I think a 20 second speedup is good enough to make this change worthwhile.

@kring
Copy link
Member

kring commented Jan 16, 2025

That's a nice improvement from just changing the test framework! Thanks for doing the test. Merging!

@kring kring merged commit 017d133 into main Jan 16, 2025
22 checks passed
@kring kring deleted the doctest branch January 16, 2025 22:52
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.

Evaluate doctest instead of Catch2 for unit tests
2 participants