Skip to content

Commit

Permalink
debug: dataop2 logs the actual data being added to CoverageData objects
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Oct 10, 2023
1 parent fffe2c4 commit a3d915e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
7 changes: 5 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ development at the same time, such as 4.5.x and 5.0.
Unreleased
----------

- Added a new :ref:`debug option <cmd_run_debug>` ``pytest`` to write the
pytest test name into the debug output.
- Added new :ref:`debug options <cmd_run_debug>`:

- ``pytest`` writes the pytest test name into the debug output.

- ``dataop2`` writes the full data being added to CoverageData objects.


.. scriv-start-here
Expand Down
6 changes: 6 additions & 0 deletions coverage/sqldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ def add_lines(self, line_data: Mapping[str, Collection[TLineNo]]) -> None:
self._debug.write("Adding lines: %d files, %d lines total" % (
len(line_data), sum(len(lines) for lines in line_data.values())
))
if self._debug.should("dataop2"):
for filename, linenos in sorted(line_data.items()):
self._debug.write(f" {filename}: {linenos}")
self._start_using()
self._choose_lines_or_arcs(lines=True)
if not line_data:
Expand Down Expand Up @@ -524,6 +527,9 @@ def add_arcs(self, arc_data: Mapping[str, Collection[TArc]]) -> None:
self._debug.write("Adding arcs: %d files, %d arcs total" % (
len(arc_data), sum(len(arcs) for arcs in arc_data.values())
))
if self._debug.should("dataop2"):
for filename, arcs in sorted(arc_data.items()):
self._debug.write(f" {filename}: {arcs}")
self._start_using()
self._choose_lines_or_arcs(arcs=True)
if not arc_data:
Expand Down
5 changes: 4 additions & 1 deletion doc/cmd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,10 @@ of operation to log:

* ``dataio``: log when reading or writing any data file.

* ``dataop``: log when data is added to the CoverageData object.
* ``dataop``: log a summary of data being added to CoverageData objects.

* ``dataop2``: when used with ``debug=dataop``, log the actual data being added
to CoverageData objects.

* ``lock``: log operations acquiring locks in the data layer.

Expand Down
2 changes: 1 addition & 1 deletion tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def DebugCoverageData(*args: Any, **kwargs: Any) -> CoverageData:
if kwargs:
# There's no logical reason kwargs should imply sqldata debugging.
# This is just a way to get a mix of debug options across the tests.
options.append("sqldata")
options.extend(["dataop2", "sqldata"])
debug = DebugControlString(options=options)
return CoverageData(*args, debug=debug, **kwargs) # type: ignore[misc]

Expand Down

0 comments on commit a3d915e

Please sign in to comment.