mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 21:05:39 +02: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:

committed by
Martin Hořeňovský

parent
6456ee8b01
commit
3087e19cc7
@@ -29,6 +29,7 @@
|
||||
[Specify the section to run](#specify-the-section-to-run)<br>
|
||||
[Filenames as tags](#filenames-as-tags)<br>
|
||||
[Override output colouring](#override-output-colouring)<br>
|
||||
[Test Sharding](#test-sharding)<br>
|
||||
|
||||
Catch works quite nicely without any command line options at all - but for those times when you want greater control the following options are available.
|
||||
Click one of the following links to take you straight to that option - or scroll on to browse the available options.
|
||||
@@ -67,6 +68,8 @@ Click one of the following links to take you straight to that option - or scroll
|
||||
<a href="#benchmark-no-analysis"> ` --benchmark-no-analysis`</a><br />
|
||||
<a href="#benchmark-warmup-time"> ` --benchmark-warmup-time`</a><br />
|
||||
<a href="#use-colour"> ` --use-colour`</a><br />
|
||||
<a href="#test-sharding"> ` --shard-count`</a><br />
|
||||
<a href="#test-sharding"> ` --shard-index`</a><br />
|
||||
|
||||
</br>
|
||||
|
||||
@@ -425,6 +428,20 @@ processing of output.
|
||||
`--use-colour yes` forces coloured output, `--use-colour no` disables coloured
|
||||
output. The default behaviour is `--use-colour auto`.
|
||||
|
||||
<a id="test-sharding"></a>
|
||||
## Test Sharding
|
||||
<pre>--shard-count <#number of shards>, --shard-index <#shard index to run></pre>
|
||||
|
||||
> [Introduced](https://github.com/catchorg/Catch2/pull/2257) in Catch2 X.Y.Z.
|
||||
|
||||
When `--shard-count <#number of shards>` is used, the tests to execute will be split evenly in to the given number of sets,
|
||||
identified by indicies starting at 0. The tests in the set given by `--shard-index <#shard index to run>` will be executed.
|
||||
The default shard count is `1`, and the default index to run is `0`. It is an error to specify a shard index greater than
|
||||
the number of shards.
|
||||
|
||||
This is useful when you want to split test execution across multiple processes, as is done with [Bazel test sharding](https://docs.bazel.build/versions/main/test-encyclopedia.html#test-sharding).
|
||||
|
||||
|
||||
---
|
||||
|
||||
[Home](Readme.md#top)
|
||||
|
Reference in New Issue
Block a user