Feature request: A new [run] source_dirs configuration option · Issue #1942 · nedbat/coveragepy (original) (raw)

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.