Skip to content

Fix xdist coverage merging with custom file tracers - #775

Open
AdityaSreevatsaK wants to merge 1 commit into
pytest-dev:masterfrom
AdityaSreevatsaK:fix/xdist-custom-file-tracer-642-ready
Open

AdityaSreevatsaK wants to merge 1 commit into
pytest-dev:masterfrom
AdityaSreevatsaK:fix/xdist-custom-file-tracer-642-ready

Conversation

@AdityaSreevatsaK

Copy link
Copy Markdown

Summary

Fixes #642.

When using pytest-xdist with a custom coverage.py FileTracer, coverage merging can fail with:

coverage.exceptions.DataError: Conflicting file tracer name

The xdist master can save unexecuted source-file entries without tracer metadata, while workers record those same files with custom tracer metadata. Combining these records causes a conflict.

Changes

  • Exclude unexecuted source-file entries from the master's coverage data before merging.
  • Preserve genuine master-process coverage, including executed lines, arcs, contexts and tracer metadata.
  • Avoid deleting worker coverage files when the master has no executed source.
  • Add regression tests covering custom file tracers, empty and active master processes, and coverage-data preservation.
  • Update the changelog and contributor list.

Validation

  • Reproduced the original coverage merge failure.
  • Verified successful merging after the fix.
  • Added integration and unit regression tests.
  • GitHub Actions: 60/60 checks passed across push and PR workflows.
  • Tested on Linux, Windows and macOS, covering Python 3.10–3.15 and PyPy.

The custom FileTracer integration test runs only where coverage.py's CTracer supports it. The coverage-data regression tests remain available across the supported Python versions.

CI results:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error combining coverage when running with pytest-xdist and a custom coverage plugin

1 participant