Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests/ExtraTests
diff options
context:
space:
mode:
authorBen Dunkin2021-07-11 12:46:05 -0700
committerMartin Hořeňovský2021-10-27 17:24:30 +0200
commit3087e19cc72ccb6caddc42ec2f39eebc56160754 (patch)
tree36d3adb84f1876a7136c169b219637343055a44d /tests/ExtraTests
parent6456ee8b01c6133e553b99da2f7420e7b20da7ec (diff)
downloadcatch3-3087e19cc72ccb6caddc42ec2f39eebc56160754.tar.gz
Allow test sharding for e.g. Bazel test sharding feature
This greatly simplifies running Catch2 tests in single binary in parallel from external test runners. Instead of having to shard the tests by tags/test names, an external test runner can now just ask for test shard 2 (out of X), and execute that in single process, without having to know what tests are actually in the shard. Note that sharding also applies to test listing, and happens after tests were ordered according to the `--order` feature.
Diffstat (limited to 'tests/ExtraTests')
-rw-r--r--tests/ExtraTests/CMakeLists.txt16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/ExtraTests/CMakeLists.txt b/tests/ExtraTests/CMakeLists.txt
index bce10df5..f2add6d6 100644
--- a/tests/ExtraTests/CMakeLists.txt
+++ b/tests/ExtraTests/CMakeLists.txt
@@ -8,6 +8,22 @@ project( Catch2ExtraTests LANGUAGES CXX )
message( STATUS "Extra tests included" )
+
+add_test(
+ NAME TestShardingIntegration
+ COMMAND ${PYTHON_EXECUTABLE} ${CATCH_DIR}/tests/TestScripts/testSharding.py $<TARGET_FILE:SelfTest>
+)
+
+add_test(
+ NAME TestSharding::OverlyLargeShardIndex
+ COMMAND $<TARGET_FILE:SelfTest> --shard-index 5 --shard-count 5
+)
+set_tests_properties(
+ TestSharding::OverlyLargeShardIndex
+ PROPERTIES
+ PASS_REGULAR_EXPRESSION "The shard count \\(5\\) must be greater than the shard index \\(5\\)"
+)
+
# The MinDuration reporting tests do not need separate compilation, but
# they have non-trivial execution time, so they are categorized as
# extra tests, so that they are run less.