Skip to content

Commit a3d915e

Browse files
committed
debug: dataop2 logs the actual data being added to CoverageData objects
1 parent fffe2c4 commit a3d915e

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

CHANGES.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ development at the same time, such as 4.5.x and 5.0.
2020
Unreleased
2121
----------
2222

23-
- Added a new :ref:`debug option <cmd_run_debug>` ``pytest`` to write the
24-
pytest test name into the debug output.
23+
- Added new :ref:`debug options <cmd_run_debug>`:
24+
25+
- ``pytest`` writes the pytest test name into the debug output.
26+
27+
- ``dataop2`` writes the full data being added to CoverageData objects.
2528

2629

2730
.. scriv-start-here

coverage/sqldata.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,9 @@ def add_lines(self, line_data: Mapping[str, Collection[TLineNo]]) -> None:
489489
self._debug.write("Adding lines: %d files, %d lines total" % (
490490
len(line_data), sum(len(lines) for lines in line_data.values())
491491
))
492+
if self._debug.should("dataop2"):
493+
for filename, linenos in sorted(line_data.items()):
494+
self._debug.write(f" {filename}: {linenos}")
492495
self._start_using()
493496
self._choose_lines_or_arcs(lines=True)
494497
if not line_data:
@@ -524,6 +527,9 @@ def add_arcs(self, arc_data: Mapping[str, Collection[TArc]]) -> None:
524527
self._debug.write("Adding arcs: %d files, %d arcs total" % (
525528
len(arc_data), sum(len(arcs) for arcs in arc_data.values())
526529
))
530+
if self._debug.should("dataop2"):
531+
for filename, arcs in sorted(arc_data.items()):
532+
self._debug.write(f" {filename}: {arcs}")
527533
self._start_using()
528534
self._choose_lines_or_arcs(arcs=True)
529535
if not arc_data:

doc/cmd.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,10 @@ of operation to log:
10221022

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

1025-
* ``dataop``: log when data is added to the CoverageData object.
1025+
* ``dataop``: log a summary of data being added to CoverageData objects.
1026+
1027+
* ``dataop2``: when used with ``debug=dataop``, log the actual data being added
1028+
to CoverageData objects.
10261029

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

tests/test_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def DebugCoverageData(*args: Any, **kwargs: Any) -> CoverageData:
8282
if kwargs:
8383
# There's no logical reason kwargs should imply sqldata debugging.
8484
# This is just a way to get a mix of debug options across the tests.
85-
options.append("sqldata")
85+
options.extend(["dataop2", "sqldata"])
8686
debug = DebugControlString(options=options)
8787
return CoverageData(*args, debug=debug, **kwargs) # type: ignore[misc]
8888

0 commit comments

Comments
 (0)