Repository navigation
Conversation
…ge tool Before this change the coverage collection was only exercised by running `bazel coverage` on a few targets in CI and the collected data was not checked. This adds a test that runs as part of `bazel test`. A `py_reconfig_test` is built with `--collect_code_coverage` for a Python 3.12 toolchain that has the bundled coverage tool configured, and `coverage_collection_test` runs it with the same environment variables that `bazel coverage` sets and checks the line coverage in the produced lcov file. * Adds the `collect_code_coverage` attribute to `py_reconfig_*` rules. * Configures the bundled coverage tool for the Python 3.12 dev toolchain. Stacked on bazel-contrib#4415. Work towards bazel-contrib#3902
Registering the toolchain with the `3.12` minor version made it take precedence over the `3.12.16` toolchain that //tests/toolchains expects.
…ests Run the instrumented program once and check the line and branch coverage of particular lines in separate tests.
Allow py_runtime.coverage_tool to be a py_library of coverage.py, such as @pypi//coverage, by using its coverage/__main__.py file as the entry point. This allows users to use the coverage version that is locked in their requirements.
Add python.single_version_override.coverage_tool and the coverage_tool argument to python_register_toolchains so that the coverage tool can be set once for all platforms of a Python version instead of once per platform via single_version_platform_override.
Collaborator
Author
|
This PR was drafted by an AI coding agent (Claude Code) working for @aignas as part of the plan in #3902. It stays a draft until @aignas has reviewed it. Review comments will be handled by @aignas, possibly with the help of the agent; any agent-written replies will be marked as such. Agent-generated comment, posted automatically on behalf of the user. |
…s no urls When single_version_override was used without urls, e.g. to only set libpython or distutils, the strip_prefix of all platforms was reset to the tag default. The archives of the full flavor, which are used for the freethreaded builds of some versions, need a different strip_prefix, so keep the existing strip_prefix when the archives are not overridden.
A py_library depends on the Python toolchain, so using @pypi//coverage as the coverage_tool of the toolchain creates a dependency cycle. Instead find the coverage/__main__.py entry point in the files of the target, so that @pypi//coverage:extracted_whl_files can be used.
This was referenced Nov 8, 2026
… into aignas.feat.coverage-tool-py-library
It is used to test the coverage collection with the coverage tool from a PyPI hub.
…p hub Configure a 3.13 toolchain with the extracted coverage wheel from the dev_pip hub as the coverage tool and run the same coverage collection checks as for the bundled coverage tool.
…rary' into aignas.feat.toolchain-coverage-tool
Use the new single_version_override.coverage_tool instead of overriding the coverage tool for each platform.
Use TEST_TMPDIR directly and rely on the test working directory being the workspace runfiles directory.
Also drop the lib.py data dependency, which is already in the runfiles via the instrumented target.
… into aignas.feat.coverage-tool-py-library
…toolchain-coverage-tool
Also test the error for a coverage_tool without coverage/__main__.py and name the news entry after the PR.
…toolchain-coverage-tool
…gnas.feat.toolchain-coverage-tool # Conflicts: # tests/python/python_tests.bzl
Also test that the version and the platform coverage_tool settings are both kept and name the news entry after the PR.
…age-tool-py-library
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allow setting the coverage tool once for all platforms of a Python version.
Before this change the only way to set a custom coverage tool with bzlmod was
python.single_version_platform_override(coverage_tool = ...), which has to berepeated for every platform. Now
python.single_version_override(coverage_tool = ...)sets it for all platforms of the version, and the per-platform overridestill takes precedence. In
WORKSPACE,python_register_toolchainsaccepts thesame
coverage_toolargument. A custom tool takes precedence over the bundledone enabled by
configure_coverage_tool/register_coverage_tool.The
//tests/coverage:coverage_from_pypi_testtoolchain from #4433 is nowconfigured this way, so the new attribute is tested end to end.
Stacked on #4433 and #4435; the latter keeps the
strip_prefixof theexisting archives when
single_version_overridedoes not override theurls.Work towards #3902