Skip to content

Commit 52afd6b

Browse files
HanpuLinedbat
andauthored
Document parallel tox coverage data files (#2284)
* Document parallel tox coverage data files * Mention automatic combine for tox data files * clarify parallel test running and combining --------- Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
1 parent f653aae commit 52afd6b

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

‎doc/commands/cmd_combine.rst‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ so that every data file is distinct::
3737

3838
You can also define a new data file name with the ``[run] data_file`` option.
3939

40-
Once you have created a number of these files, you can copy them all to a
41-
single directory, and use the **combine** command to combine them into one
42-
.coverage data file::
40+
Once you have created a number of separate data files, you can also copy them
41+
all to a single directory, and use the **combine** command to combine them into
42+
one .coverage data file::
4343

4444
$ coverage combine
4545

@@ -99,6 +99,28 @@ want to keep those files, use the ``--keep`` command-line option.
9999
.. [[[end]]] (sum: ARyg8KB1fE)
100100
101101
102+
Parallel test runners
103+
.....................
104+
105+
If independent test runners use coverage.py concurrently in the same working
106+
directory, give each runner a different *base* data file name. This is
107+
important with tools such as ``tox --parallel``: coverage's parallel mode makes
108+
the individual measurement files unique, but separate tox environments can
109+
still combine or erase files using the same base name at the same time.
110+
111+
You can use tox settings to give each tox environment a distinct base coverage
112+
data file name so their combine steps won't collide::
113+
114+
[testenv]
115+
setenv =
116+
COVERAGE_FILE = {toxinidir}/.coverage.{envname}
117+
118+
Each environment can run coverage in parallel, and combine their data files
119+
into a distinct data file. After the test-running tox environments have
120+
finished, a final second-level combining environment can combine those files
121+
using their common ``.coverage`` prefix, as described above.
122+
123+
102124
.. _cmd_combine_remapping:
103125

104126
Re-mapping paths

0 commit comments

Comments
 (0)