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
Preserve source roots with Pytest output #10165
Conversation
# Delete this line to force CI to run the JVM tests. [ci skip-jvm-tests] [ci skip-rust-tests]
@@ -251,9 +245,10 @@ async def run_python_test( | |||
if use_coverage: | |||
output_files.append(".coverage") | |||
|
|||
# We explicitly add the CWD to the PEX runtime sys.path. Some pytest plugins |
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.
I'm not sure the django example will still work, but if not I'll fix it, so this is fine for now.
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.
Okay, thank you! If it turns out this breaks, it would be good to add a unit test.
# Delete this line to force CI to run Clippy and the Rust tests. [ci skip-rust-tests] # Delete this line to force CI to run the JVM tests. [ci skip-jvm-tests]
…-strip [ci skip-rust-tests] [ci skip-jvm-tests]
…-strip [ci skip-rust-tests]
…how up in the result We must use `python_sources.py` to properly inject any missing `__init__.py` files at the report time. This allows us to remove `--ignore-errors`, which is good to make it more likely for us to discover issues with the project. [ci skip-rust-tests] # Conflicts: # src/python/pants/backend/python/rules/coverage.py # src/python/pants/backend/python/rules/coverage_integration_test.py
# Rust tests will be skipped. Delete if not intended. [ci skip-rust-tests]
…-strip [ci skip-rust-tests] # Conflicts: # src/python/pants/backend/python/rules/coverage.py # src/python/pants/backend/python/rules/coverage_plugin/BUILD # src/python/pants/backend/python/rules/pytest_runner_integration_test.py
… the instance of pants that we are testing. # Rust tests will be skipped. Delete if not intended. [ci skip-rust-tests]
The issue was never fixed with #10064 (IOW the random.py file is still not expected in the |
Previously, the combination of collecting relative_paths and passing `--cov=.` to pytest-cov could lead to coverage collection of invalid paths (namely: "(builtin)") which would cause coverage report generation to fail. Fix this by restricting coverage to the source roots of the code under test. This also solves a regression introduced by pantsbuild#10165. Fixes pantsbuild#12390 [ci skip-rust] [ci skip-build-wheels]
Previously, the combination of collecting relative_paths and passing `--cov=.` to pytest-cov could lead to coverage collection of invalid paths (namely: "(builtin)") which would cause coverage report generation to fail. Fix this by restricting coverage to the source roots of the code under test. This also solves a regression introduced by #10165. Fixes #12390
Before:
After
This also allows us to remove the custom Pants Coverage plugin, which greatly simplifies the code path and improves performance (8s to run coverage on
pants_test/util:objects
before, and only 4 seconds after). This does introduce a regression that we no longer report on files never touched by the test, but this was a similar issue before that we already had to solve. We will fix this problem as part of #10064.[ci skip-jvm-tests]
[ci skip-rust-tests]