mirror of
https://github.com/catchorg/Catch2.git
synced 2025-05-19 03:08:39 +00:00
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
|
@ -149,6 +149,15 @@ namespace Catch {
|
|||
return ParserResult::runtimeError( "Unrecognized reporter, '" + reporter + "'. Check available with --list-reporters" );
|
||||
return ParserResult::ok( ParseResultType::Matched );
|
||||
};
|
||||
auto const setShardCount = [&]( std::string const& shardCount ) {
|
||||
auto result = Clara::Detail::convertInto( shardCount, config.shardCount );
|
||||
|
||||
if (config.shardCount == 0) {
|
||||
return ParserResult::runtimeError( "The shard count must be greater than 0" );
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
auto cli
|
||||
= ExeName( config.processName )
|
||||
|
@ -240,6 +249,12 @@ namespace Catch {
|
|||
| Opt( config.benchmarkWarmupTime, "benchmarkWarmupTime" )
|
||||
["--benchmark-warmup-time"]
|
||||
( "amount of time in milliseconds spent on warming up each test (default: 100)" )
|
||||
| Opt( setShardCount, "shard count" )
|
||||
["--shard-count"]
|
||||
( "split the tests to execute into this many groups" )
|
||||
| Opt( config.shardIndex, "shard index" )
|
||||
["--shard-index"]
|
||||
( "index of the group of tests to execute (see --shard-count)" )
|
||||
| Arg( config.testsOrTags, "test name|pattern|tags" )
|
||||
( "which test or tests to use" );
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue