coverage: return InstrumentedFilesInfo from haskell_library/binary/test#2434
Open
briantopping wants to merge 1 commit into
Open
coverage: return InstrumentedFilesInfo from haskell_library/binary/test#2434briantopping wants to merge 1 commit into
briantopping wants to merge 1 commit into
Conversation
rules_haskell ships HPC coverage support, but its rule implementations
never return Bazel's InstrumentedFilesInfo. As a result `bazel coverage`
cannot deterministically instrument the transitive Haskell libraries in a
test's closure: a library can be realized in both instrumented and
non-instrumented configurations within a single `coverage //...` run, and
a test that links the non-instrumented variant produces no `<lib>_.hpc`,
so its covered modules silently score 0%.
Return `coverage_common.instrumented_files_info` at the provider sites:
* _haskell_binary_common_impl (haskell_binary + haskell_test):
source_attributes = ["srcs"], dependency_attributes =
["deps", "narrowed_deps"] (these rules have no `exports`).
* haskell_library_impl: dependency_attributes additionally includes
"exports".
haskell_library_impl is also reused by haskell_proto_aspect through a
patched-ctx struct (the existing `real_ctx` indirection), which is not a
genuine rule ctx and which `coverage_common.instrumented_files_info`
rejects. Attach the provider only when invoked with a real rule ctx (no
`real_ctx` attribute), preserving the aspect's provider contract.
Member
|
Thank you! Does this have any effect on the tests in rules_haskell_tests, e.g. the two-libs one ? |
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.
Problem
rules_haskell ships HPC coverage, but its rule implementations never return Bazel's
InstrumentedFilesInfo. Without it,bazel coveragecan't deterministically instrument the transitive Haskell libraries in a test's closure: a library is realized in both instrumented and non-instrumented configurations within onecoverage //...run, and a test linking the non-instrumented variant produces no<lib>_.hpc— so its covered modules silently score 0%.Fix
Return
coverage_common.instrumented_files_infoat the provider sites:_haskell_binary_common_impl(haskell_binary + haskell_test):source_attributes = ["srcs"],dependency_attributes = ["deps", "narrowed_deps"].haskell_library_impl:dependency_attributesadditionally includes"exports".haskell_library_implis reused byhaskell_proto_aspectvia a patched-ctx struct (the existingreal_ctxindirection), which isn't a genuine rule ctx and whichcoverage_common.instrumented_files_inforejects — so the provider is attached only for a real rule ctx (noreal_ctxattribute), preserving the aspect's provider contract.Why upstream
Generic coverage-correctness fix, nothing project-specific — any user running
bazel coverageover a multi-library Haskell target gets non-deterministic transitive-library coverage today.Verification
buildifier clean; cherry-picks cleanly onto current master. Carried in a downstream fork where it makes HPC→lcov scoring deterministic. Not yet exercised with a fresh
bazel coverageon master here — happy to confirm if a maintainer prefers.