diff options
author | Éric Larivière <elarivie@users.noreply.github.com> | 2021-01-30 17:55:11 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-30 17:55:11 -0500 |
commit | a0f6692f5cc9344ae790300dcc0cf743ac9abbd3 (patch) | |
tree | 9884b4de9221850ffe5a10f919322d2ffeabdcef /coverage/data.py | |
parent | 0143891b04c0c800fe1a508ab424cbe825f4210b (diff) | |
download | python-coveragepy-git-a0f6692f5cc9344ae790300dcc0cf743ac9abbd3.tar.gz |
Add combine --keep (#1110)
* Add combine --keep
Related to https://github.com/nedbat/coveragepy/issues/1108
* Fix unit tests
* Fix line too long
* Fix line too long
Diffstat (limited to 'coverage/data.py')
-rw-r--r-- | coverage/data.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/coverage/data.py b/coverage/data.py index 82bf1d41..5dd1dfe3 100644 --- a/coverage/data.py +++ b/coverage/data.py @@ -52,7 +52,7 @@ def add_data_to_hash(data, filename, hasher): hasher.update(data.file_tracer(filename)) -def combine_parallel_data(data, aliases=None, data_paths=None, strict=False): +def combine_parallel_data(data, aliases=None, data_paths=None, strict=False, keep=False): """Combine a number of data files together. Treat `data.filename` as a file prefix, and combine the data from all @@ -68,7 +68,7 @@ def combine_parallel_data(data, aliases=None, data_paths=None, strict=False): If `data_paths` is not provided, then the directory portion of `data.filename` is used as the directory to search for data files. - Every data file found and combined is then deleted from disk. If a file + Unless `keep` is True every data file found and combined is then deleted from disk. If a file cannot be read, a warning will be issued, and the file will not be deleted. @@ -116,9 +116,10 @@ def combine_parallel_data(data, aliases=None, data_paths=None, strict=False): else: data.update(new_data, aliases=aliases) files_combined += 1 - if data._debug.should('dataio'): - data._debug.write("Deleting combined data file %r" % (f,)) - file_be_gone(f) + if not keep: + if data._debug.should('dataio'): + data._debug.write("Deleting combined data file %r" % (f,)) + file_be_gone(f) if strict and not files_combined: raise CoverageException("No usable data files") |