cacheprovider: fix some files in packages getting lost from --lf #7915
Conversation
--lf has an optimization where it skips collecting Modules (python files) which don't contain failing tests. The optimization works by getting the paths of all cached failed tests and skipping the collection of Modules whose path is not included in that list. In pytest, Package nodes are Module nodes with the fspath being the file `<package dir>/__init__.py`. Since it's a Module the logic above triggered for it, and because it's an `__init__.py` file which is unlikely to have any failing tests in it, it is skipped, which causes its entire directory to be skipped, including any Modules inside it with failing tests. Fix by special-casing Packages to never filter. This means entire Packages are never filtered, the Modules themselves are always checked. It is reasonable to consider an optimization which does filter entire packages bases on parent paths etc. but this wouldn't actually save any real work so is really not worth it.
|
Thanks @bluetech! |
a66b6b8
into
pytest-dev:master
18 of 19 checks passed
18 of 19 checks passed
bluetech
added a commit
to bluetech/pytest
that referenced
this pull request
Oct 21, 2020
cacheprovider: fix some files in packages getting lost from --lf (cherry picked from commit a66b6b8)
bluetech
added a commit
to bluetech/pytest
that referenced
this pull request
Oct 21, 2020
cacheprovider: fix some files in packages getting lost from --lf (cherry picked from commit a66b6b8) with some needed adjustments to 6.1.x.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Fixes #7758. There are several reports in there, I only checked the one from #7894, but let's hope it also fixes the pandas report.
--lfhas an optimization where it skips collecting Modules (python files) which don't contain failing tests. The optimization works by getting the paths of all cached failed tests and skipping the collection of Modules whose path is not included in that list.In pytest, Package nodes are Module nodes with the fspath being the file
<package dir>/__init__.py. Since it's a Module the logic above triggered for it, and because it's an__init__.pyfile which is unlikely to have any failing tests in it, it is skipped, which causes its entire directory to be skipped, including any Modules inside it with failing tests.Fix by special-casing Packages to never filter. This means entire Packages are never filtered, the Modules themselves are always checked. It is reasonable to consider an optimization which does filter entire packages bases on parent paths etc. but this wouldn't actually save any real work so is really not worth it.