-
-
Notifications
You must be signed in to change notification settings - Fork 652
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
Properly strip source root prefixes for V2 Pytest runner #8185
Properly strip source root prefixes for V2 Pytest runner #8185
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot!
3725188
to
a42ed86
Compare
a42ed86
to
8d1e46b
Compare
8d1e46b
to
ce918da
Compare
Your bootstrap shards raced another PR landing. Have rebased. |
There appear to be some actual failures in CI. |
ce918da
to
b464557
Compare
b464557 fixes the unit test failure. Test discovery was failing for Very unclear why this was not happening with V1 test runner or V2 before this change..not going to spend more time trying to answer that, though. |
Problem
#7696 introduced support for source roots to V2 Pytest for the first time, but it did not support loose files. #8063 tried to fix this by no longer stripping the source root from source files. However, this caused two issues:
repr()
now shows the full path, not the relativized path: Properly handle source roots and resources with V2 Pytest runner #8063 (comment)pants
, but may not within the same actual folder.PYTHONPATH
had two entries referring topants
:src/python/pants
andcontrib/mypy/src/python/pants
. Python would use whichever entry came first and ignore the other, which does not work. Instead, we want those two to merge into one namespace package.Solution
Follow the V1 Pytest approach of stripping the source root, like we used to, but only for source files. Loose files (i.e.
files()
) are not stripped so that the file system APIs work as expected. This approach comes from:pants/src/python/pants/backend/python/subsystems/pex_build_util.py
Lines 101 to 110 in d048fd2
Result
V2 Pytest now supports both source roots and loose files! This allows us to run most contrib unit tests with V2 and unblocks #8113.
Because over 95% of unit tests are now remoted, we go back to only one CI shard for unit tests.