Repository navigation
scope: a cc_binary executable is the baseline object of its sources - #44
Conversation
License Check Results🚀 The license check job ran with the Bazel command: bazel run //:license-checkStatus: Click to expand output |
b3b5398 to
754b117
Compare
A cc_binary links its own translation units straight into the executable; they sit in no archive, so an untested main.cpp had no object carrying its coverage mapping, was absent from the report and listed as no-data in unmapped_files.txt (lifecycle launch_manager, #40). The aspect now adds the coverage-built executable to the baseline objects, as it does for rust_binary. The gcov baseline notes of untested files are built in the exec configuration and take the host options; the consumer config gains --host_cxxopt=-O0 next to --cxxopt=-O0 so their line tables match the test builds (GCC folds a constant return into the entry line when optimising). Analysis test for the executable in the objects manifest; the end-to-end workspace gets an untested cc_binary whose main.cpp is checked at exact 0 % on both backends (hand-derived goldens, cross-checked with gcov on the gcno). Manual, release notes 0.4.2, verification report counts. Closes #40 Signed-off-by: Dan Calavrezo <195309321+dcalavrezo-qorix@users.noreply.github.com>
754b117 to
6dce2fe
Compare
|
Validated on lifecycle with this branch via
|
|
Documentation preview for this pull request is available at: |
The HTML came from one llvm-cov show over the test binaries plus the baseline objects with the merged test profile. An executable among the baseline objects carries a main like every test binary: with the same structural hash llvm-cov attributed a test's counts to it (lifecycle's untested main.cpp at 100 %), with a different hash it dropped the file (no row in the end-to-end index). The LCOV was right, it already took baseline-only files from a separate --empty-profile run. The HTML now does the same: baseline-only files are rendered with --empty-profile over the baseline objects, their pages and index rows are spliced into the report, and the Totals row the effective-coverage gate reads is recomputed over all rows. Unit tests for the splice; end-to-end checks of the index rows of the untested C++ sources, the binary's main.cpp and the Rust binary's main.rs at 0 %. Signed-off-by: Dan Calavrezo <195309321+dcalavrezo-qorix@users.noreply.github.com>
919455e to
7d21540
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The focused baseline and HTML changes have supporting regression coverage, with no unresolved review findings.
0 open findings
What changed in this PR
Fixes #40 by including untested cc_binary sources in coverage reports at 0%, rather than leaving them unmapped.
Changes:
- Collects binary executables as baseline coverage objects.
- Renders baseline-only HTML separately, merging pages and recalculating index totals.
- Adds regression coverage, gcov host compilation settings, and documentation.
| File | Description |
|---|---|
| tests/unit/starlark/fixtures/BUILD | Adds a C++ binary fixture. |
| tests/unit/starlark/fixtures/bin_main.cpp | Supplies the fixture entry point. |
| tests/unit/starlark/coverage_scope_tests.bzl | Checks binary sources and executable collection. |
| tests/unit/score_coverage/reporter_test.py | Tests HTML merging and totals. |
| tests/end_to_end/testcases/test_summary.py | Checks the additional zero-coverage source. |
| tests/end_to_end/run_end_to_end_test.sh | Checks binary coverage and HTML rows. |
| tests/end_to_end/expected/expected_lcov.dat | Adds LLVM baseline expectations. |
| tests/end_to_end/expected/expected_lcov_gcov.dat | Adds gcov baseline expectations. |
| tests/end_to_end/consumer/tools/coverage/BUILD | Includes the untested binary in scope. |
| tests/end_to_end/consumer/src/main.cpp | Adds an untested entry point. |
| tests/end_to_end/consumer/src/BUILD | Defines the consumer binary. |
| tests/end_to_end/consumer/.bazelrc | Disables host C++ optimization for gcov. |
| score_coverage/reporter.py | Separately renders and merges baseline HTML. |
| score_coverage/coverage_scope.bzl | Collects C++ executables as baseline objects. |
| docs/verification/verification_report.rst | Updates test inventory counts. |
| docs/release/release_notes.rst | Documents the fix and integration settings. |
| docs/manual/user_manual.rst | Explains binary scope handling and gcov settings. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Closes #40.
Why
A
cc_binarylinks its own translation units straight into the executable; they sit in no archive. The aspect took the zero-coverage baseline objects from the.aarchives inCcInfoonly, so an untested binary's own sources (lifecycle'slaunch_managermain.cpp) had no object carrying their mapping: absent from the report, listed inunmapped_files.txtasno-data. Library sources were never affected.Changes
coverage_scope.bzl: for acc_binary, the coverage-built executable joins the baseline objects, as already done forrust_binary. The reporter passes all baseline objects to onellvm-cov --empty-profilecall, which merges a file seen in both the executable and an archive, so no duplicate rows.test_cc_binary_collects_main_and_executable(fixturecbin); 18 analysis tests.cc_binary //src:toolin the scope;main.cppchecked at exact 0 % on both backends; hand-derived golden records (LLVM: brace line through closing brace; gcov: signature and statement lines), cross-checked with GCC 12.2'sgcovon the gcno..gcnobaseline notes are built in the exec configuration, which takes the host options, so GCC optimised them and foldedreturn 0into the entry line.--host_cxxopt=-O0added to the consumer gcov config and documented in step 4b; the LLVM backend is unaffected (front-end mapping). baselibs' QNX config should get the same line.Validation
bazel test //tests/unit/...: 26 pass.tests/end_to_end/run_end_to_end_test.sh: 25 checks pass, LLVM and gcov goldens match.