Skip to content

Commit 7c25ba0

Browse files
committed
fix: don't combine journal files. #1605
1 parent 346b23d commit 7c25ba0

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ Unreleased
2424
``[report] exclude_also`` settings (`issue 1684`_). This is now fixed,
2525
thanks `Jacqueline Lee <pull 1685_>`_.
2626

27+
- Sometimes SQLite will create journal files alongside the coverage.py database
28+
files. These are ephemeral, but could be mistakenly included when combining
29+
data files. Now they are always ignored, fixing `issue 1605`_. Thanks to
30+
Brad Smith for suggesting fixes and providing detailed debugging.
31+
32+
.. _issue 1605: https://github.com/nedbat/coveragepy/pull/1605
2733
.. _issue 1684: https://github.com/nedbat/coveragepy/issues/1684
2834
.. _pull 1685: https://github.com/nedbat/coveragepy/pull/1685
2935

CONTRIBUTORS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Benjamin Parzella
3131
Benjamin Schubert
3232
Bernát Gábor
3333
Bill Hart
34+
Brad Smith
3435
Bradley Burns
3536
Brandon Rhodes
3637
Brett Cannon

coverage/data.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ def combinable_files(data_file: str, data_paths: Optional[Iterable[str]] = None)
8383
files_to_combine.extend(glob.glob(pattern))
8484
else:
8585
raise NoDataError(f"Couldn't combine from non-existent path '{p}'")
86+
87+
# SQLite might have made journal files alongside our database files.
88+
# We never want to combine those.
89+
files_to_combine = [fnm for fnm in files_to_combine if not fnm.endswith("-journal")]
90+
8691
return files_to_combine
8792

8893

tests/test_data.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,9 @@ def test_combining_from_files(self) -> None:
887887
covdata1.add_lines(LINES_1)
888888
covdata1.write()
889889

890+
# Journal files should never be included in the combining.
891+
self.make_file("cov1/.coverage.1-journal", "xyzzy")
892+
890893
os.makedirs('cov2')
891894
covdata2 = DebugCoverageData('cov2/.coverage.2')
892895
covdata2.add_lines(LINES_2)

0 commit comments

Comments
 (0)