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 29, 2023
1 parent 346b23d commit 3becb6d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ 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`_.

.. _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
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 3becb6d

Please sign in to comment.