Skip to content

Commit

Permalink
fix: don't combine journal files. #1605
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Sep 30, 2023
1 parent 346b23d commit 7c25ba0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ Unreleased
``[report] exclude_also`` settings (`issue 1684`_). This is now fixed,
thanks `Jacqueline Lee <pull 1685_>`_.

- Sometimes SQLite will create journal files alongside the coverage.py database
files. These are ephemeral, but could be mistakenly included when combining
data files. Now they are always ignored, fixing `issue 1605`_. Thanks to
Brad Smith for suggesting fixes and providing detailed debugging.

.. _issue 1605: https://github.com/nedbat/coveragepy/pull/1605
.. _issue 1684: https://github.com/nedbat/coveragepy/issues/1684
.. _pull 1685: https://github.com/nedbat/coveragepy/pull/1685

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Benjamin Parzella
Benjamin Schubert
Bernát Gábor
Bill Hart
Brad Smith
Bradley Burns
Brandon Rhodes
Brett Cannon
Expand Down
5 changes: 5 additions & 0 deletions coverage/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ def combinable_files(data_file: str, data_paths: Optional[Iterable[str]] = None)
files_to_combine.extend(glob.glob(pattern))
else:
raise NoDataError(f"Couldn't combine from non-existent path '{p}'")

# SQLite might have made journal files alongside our database files.
# We never want to combine those.
files_to_combine = [fnm for fnm in files_to_combine if not fnm.endswith("-journal")]

return files_to_combine


Expand Down
3 changes: 3 additions & 0 deletions tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,9 @@ def test_combining_from_files(self) -> None:
covdata1.add_lines(LINES_1)
covdata1.write()

# Journal files should never be included in the combining.
self.make_file("cov1/.coverage.1-journal", "xyzzy")

os.makedirs('cov2')
covdata2 = DebugCoverageData('cov2/.coverage.2')
covdata2.add_lines(LINES_2)
Expand Down

0 comments on commit 7c25ba0

Please sign in to comment.