feat(coverage): warn when bundled coverage tool has no wheel for requested python_version/platform#3766
Open
Syndic wants to merge 3 commits into
Open
feat(coverage): warn when bundled coverage tool has no wheel for requested python_version/platform#3766Syndic wants to merge 3 commits into
Syndic wants to merge 3 commits into
Conversation
…ested python_version/platform Previously, when `configure_coverage_tool = True` was set but the bundled `coverage.py` wheel set had no entry for the requested (python_version, platform), `coverage_dep` returned None silently. The result was that `bazel coverage` produced empty per-test lcov files for `py_test` targets with no signal to the user that coverage was unconfigured. Print a WARNING in that path so the misconfiguration is visible. Preserve the existing silent return for the windows branch, which is intentionally quiet because the upstream coverage wrapper does not support windows.
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates coverage_deps.bzl to issue a warning when a bundled coverage wheel is unavailable for a specific Python version and platform, replacing the previous silent failure. The warning includes instructions for manual configuration or version pinning to resolve the issue. The CHANGELOG.md was also updated to reflect this change. I have no feedback to provide as there were no review comments.
This was referenced May 10, 2026
aignas
requested changes
May 11, 2026
Per review on bazel-contrib#3766, replace the raw `print(...)` warning with `logger.warn(...)` from `repo_utils.logger`, with the logger threaded in from the caller. - `coverage_dep` takes an optional `logger` parameter and falls back to a default-constructed logger if none is supplied. - `python_register_toolchains` accepts a private `_internal_module_ctx` kwarg (mirroring the existing `_internal_bzlmod_toolchain_call` pattern). When invoked from the bzlmod path, it builds the logger with the real `module_ctx` so module-root filtering applies (see bazel-contrib#3760). For the WORKSPACE/macro path it constructs a minimal stand-in struct, which is all the logger needs. - `python.bzl` passes `module_ctx` through. Adds tests/coverage_deps/ with two cases (unsupported version warns, windows stays silent) using the captured-printer pattern already established in tests/pypi/hub_builder/hub_builder_tests.bzl.
aignas
approved these changes
May 13, 2026
Add a comment explaining that the supported-wheel path of coverage_dep calls maybe(http_archive, ...) which calls native.existing_rule(), which is only valid during BUILD/macro/finalizer evaluation, not during rule analysis where rules_testing analysis tests run. The path is covered end-to-end by real bazel coverage runs.
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.
Addresses review feedback on #3764:
NOTE: Starlark unit tests have no way to capture stdout/stderr, so we can't directly assert that the warning is printed. I am not sure if the refactoring-for-testability I have considered would be appreciated, so this PR is a minimal approach. (I will also prepare an alternative PR that includes a small refactor and some tests, in case that is preferred.)
Previously, when
configure_coverage_tool = Truewas set but the bundledcoverage.pywheel set had no entry for the requested (python_version, platform),coverage_depreturned None silently. The result was thatbazel coverageproduced empty per-test lcov files forpy_testtargets with no signal to the user that coverage was unconfigured.Print a WARNING in that path so the misconfiguration is visible. Preserves the existing silent return for the windows branch, which is intentionally quiet because the upstream coverage wrapper does not support windows.