Visitar URL original
TST: Collect coverage from subprocesses by greglucas · Pull Request #32366 · matplotlib/matplotlib · GitHub
Skip to content

TST: Collect coverage from subprocesses - #32366

Merged
iccir merged 1 commit into
matplotlib:mainfrom
greglucas:subprocess-coverage
Sep 18, 2026
Merged

iccir merged 1 commit into
matplotlib:mainfrom
greglucas:subprocess-coverage

Conversation

@greglucas

Copy link
Copy Markdown
Contributor

PR summary

While working on the timers which use subprocesses I noticed that the tests I was adding were failing coverage.
#29062

coverage.py has added a new subprocess patch argument we can add to the configuration: https://coverage.readthedocs.io/en/latest/subprocess.html

Pulling this commit out so it can be reviewed separately. (7.10 was released in July 2025, but that should be fine for testing dependencies IMO)

AI Disclosure

Used for research and initial investigation. I reviewed coverage docs and version myself.

@github-actions github-actions Bot added the CI: Run cibuildwheel Run wheel building tests on a PR label Sep 17, 2026
@tacaswell

Copy link
Copy Markdown
Member

I thought we were collecting from subprocess already (we went through a big thing with coverage when we moved the sub-process tests to be import-like rather than "giant-string-via--c like) but looking at the coverage results that clearly was not the case and this fixes it!

@iccir iccir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I was researching this earlier, the docs state:

You will also need the parallel option to collect separate data for each process, and the coverage combine command to combine them together before reporting.

Do we need to do this?

@greglucas

Copy link
Copy Markdown
Contributor Author

I thought we were collecting from subprocess already (we went through a big thing with coverage when we moved the sub-process tests to be import-like rather than "giant-string-via--c like) but looking at the coverage results that clearly was not the case and this fixes it!

I had the same recollection, so I'm not sure what we previously fixed or what has happened since. 🤷

When I was researching this earlier, the docs state:

You will also need the parallel option to collect separate data for each process, and the coverage combine command to combine them together before reporting.

Do we need to do this?

I don't think so. This is handled by codecoverage I believe, each of the runners uploads to codecoverage independently and gets merged upstream there by them (hence how we can have windows, macos, linux coverage all additive in the final result)

@iccir

iccir commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

From my (limited) understanding, there needs to be two merges:

  1. Each subprocess generates a data file. This gets merged into a combined data file for the runner.
  2. The combined data file is sent upstream and then merged by codecoverage.

coverage.py's parallel and combine affect Merge 1. After more digging, per the docs:

The subprocess patch sets parallel = True and will require combining data files before reporting. See Combining data files: coverage combine for more details.

However, combining isn't automatic until 7.14:

As of version 7.14.0, files are combined by the reporting commands, so there is less need to use an explicit combine command.


It sounds like 7.10-7.13 required an explicit combine command; however, the 🤖 told me that pytest-cov is doing this for us.

I think all of my concerns are alleviated now.

@iccir
iccir merged commit 97981b8 into matplotlib:main Sep 18, 2026
44 checks passed
@QuLogic QuLogic added this to the v3.11.3 milestone Sep 18, 2026
@QuLogic

QuLogic commented Sep 18, 2026

Copy link
Copy Markdown
Member

@meeseeksdev backport to v3.11.x

QuLogic added a commit that referenced this pull request Sep 19, 2026
…366-on-v3.11.x

Backport PR #32366 on branch v3.11.x (TST: Collect coverage from subprocesses)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI: Run cibuildwheel Run wheel building tests on a PR topic: testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants