-
-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: A new [run] source_dirs
configuration option
#1942
Labels
enhancement
New feature or request
Comments
jfly
added a commit
to jfly/pytest-cov
that referenced
this issue
Mar 27, 2025
This `COV_CORE_SOURCE` environment variable is key for making sure that child processes continue computing code coverage. However, there's no guarantee that child processes start in the same directory as their parent process, which screws up coverage reporting if you're using relative paths for coverage sources. The fix is to make sure we're dealing with absolute paths. This is a little tricky to get right, because sources can include both dirs and packages. This fixes nedbat/coveragepy#1942.
Urg, sorry. Please ignore pytest-dev/pytest-cov#681. It's a fix for a bug related to this issue, but doesn't fix this issue. |
This sounds like a reasonable idea. |
@nedbat, awesome! I'll try to put together a PR for this. |
jfly
added a commit
to jfly/coveragepy
that referenced
this issue
Mar 27, 2025
This completes nedbat#1942 (comment)
PR out for review here: #1943 |
jfly
added a commit
to jfly/coveragepy
that referenced
this issue
Mar 27, 2025
This completes nedbat#1942 (comment)
jfly
added a commit
to jfly/coveragepy
that referenced
this issue
Mar 27, 2025
This completes nedbat#1942 (comment)
nedbat
added a commit
to nedbat/coverage-reports
that referenced
this issue
Mar 28, 2025
Closing. This was implemented in #1943 |
This is now released as part of coverage 7.8.0. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
The existing
[run] source
option is ambiguous: it can contain either directories or package names, and we deduce at runtime which is which based on if they are actually a directory or not: https://github.com/nedbat/coveragepy/blob/7.7.1/coverage/inorout.py#L198-L201.This results in quirky bugs like this one for coverage.py where something treated as a directory can change into getting treated as a package in a subprocess. This particular bug is fixable without changing coveragepy, but the fix would be cleaner if we had an explicit, unambiguous mechanism for specifying source directories. Ideally coveragepy would then error out if these directories don't exist, which would make bugs like pytest-dev/pytest-cov#465 even less likely.
Describe the solution you'd like
We already have a
[run] source_pkgs
option that lets you unambiguously specify package names, I'd like a corresponding[run] source_dirs
option.Describe alternatives you've considered
The status quo: don't add this feature. Hopefully I've justified it sufficiently above.
The text was updated successfully, but these errors were encountered: