feat(coverage): warn when bundled coverage tool has no wheel for requested python_version/platform#3766
feat(coverage): warn when bundled coverage tool has no wheel for requested python_version/platform#3766Syndic wants to merge 1 commit 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.
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.
| if url == None: | ||
| # Some wheels are not present for some builds, so let's silently ignore those. | ||
| # buildifier: disable=print | ||
| print(( |
There was a problem hiding this comment.
Use logger.warn with an optional logger passed in.
There was a problem hiding this comment.
Please also take a look how to pass that from the layers above. For bzlmod we'll have the module extension context, so it should be relatively easy. For macros for WORKSPACE we should pass in a mock context because we are executing it in a macro if I remember correctly.
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.