Skip to content
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

cacheprovider: fix some files in packages getting lost from --lf #7915

Merged
merged 1 commit into from Oct 21, 2020

Conversation

bluetech
Copy link
Member

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.

--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.

--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.
@bluetech bluetech added the needs backport applied to PRs, indicates that it should be ported to the current bug-fix branch label Oct 19, 2020
Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

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

Thanks @bluetech!

@bluetech bluetech merged commit a66b6b8 into pytest-dev:master Oct 21, 2020
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.
@bluetech bluetech deleted the fix-lf-package branch November 6, 2020 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs backport applied to PRs, indicates that it should be ported to the current bug-fix branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: --lf running only a subset of last-failed tests
2 participants