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.
This commit is contained in:
parent
6456ee8b01
commit
3087e19cc7
21 changed files with 415 additions and 6 deletions
|
@ -569,6 +569,27 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]"
|
|||
REQUIRE(config.benchmarkWarmupTime == 10);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("Sharding options") {
|
||||
SECTION("shard-count") {
|
||||
CHECK(cli.parse({ "test", "--shard-count=8"}));
|
||||
|
||||
REQUIRE(config.shardCount == 8);
|
||||
}
|
||||
|
||||
SECTION("shard-index") {
|
||||
CHECK(cli.parse({ "test", "--shard-index=2"}));
|
||||
|
||||
REQUIRE(config.shardIndex == 2);
|
||||
}
|
||||
|
||||
SECTION("Zero shard-count") {
|
||||
auto result = cli.parse({ "test", "--shard-count=0"});
|
||||
|
||||
CHECK( !result );
|
||||
CHECK_THAT( result.errorMessage(), ContainsSubstring( "The shard count must be greater than 0" ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Test with special, characters \"in name", "[cli][regression]") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue