Skip to content

feat(rust): export the raw lcov report of rust_test targets - #51

Merged
walterjgsp merged 1 commit into
rustfrom
feat/rust-lcov-export
Oct 3, 2026
Merged

walterjgsp merged 1 commit into
rustfrom
feat/rust-lcov-export

Conversation

@walterjgsp

Copy link
Copy Markdown
Contributor

Summary

Phase 2 of #46, Rust. Each rust_test keeps the llvm-cov report as lcov, with the function (FN/FNDA) and branch (BRDA) records that Please's merged coverage.xml / coverage.json drop:

  • Declared as a test output: plz-out/bin/<package>/<name>.lcov, repository-relative paths, toolchain and registry sources excluded. Uses the shared tools/common/lcov package (feat(common): add shared lcov package #47).
  • Partial lines: stable rustc emits no branch regions, so BRDA records are synthesized from llvm-cov export -format=text sub-line regions with lcov.AddRegionBranches (feat(common): derive partial-line branches from llvm-cov regions #50). Only lines that ran but contain a never-run sub-line region get one (e.g. the right side of a && b). If the JSON export fails the report is still written, without them.
  • Created empty up front, so it exists (and is empty) without coverage; the report Please reads is unchanged.
  • Fix found on the way: under Please TMP_DIR is the working directory, so the raw profiles were listed twice and merged twice, doubling every execution count. Line coverage was unaffected; the exported counts would have been wrong. They are now listed once (test added).
  • New please_rust test-runner --lcov-file flag; docs; changelog. The [Unreleased] section (LLVM tool fix, docs) becomes 0.6.0 together with this new feature; VERSION is bumped by the release workflow.

Heuristic limits (documented)

A multi-line if/else is not a partial line: the untaken side shows up as an uncovered line. FN names are rustc v0-mangled.

Test plan

  • plz test //... (96 tests): export built from real llvm-cov lcov and JSON (toolchain file dropped, paths normalized, line 12 partial, uncalled function uncovered), no-JSON fallback, invalid input, empty reset, single listing of profiles
  • New fixture test/rust/branches:branches_test: under plz cover FNDA:2 for classify and FNDA:0 for unused (counts correct after the profile fix), BRDA:12,0,0,0; a plain plz test leaves the file empty
  • CI smoke step asserting those records

🤖 Generated with Claude Code

Keep the llvm-cov report as a declared test output, <name>.lcov: repository-relative paths, function records and, from the JSON export's sub-line regions, synthesized branch records for partly executed lines. Also stop merging raw profiles twice under Please, which doubled every execution count. Phase 2 of #46 for Rust. Adds a branchy fixture, unit tests, docs, a changelog entry for 0.6.0 and a CI smoke test.

Refs #46

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@walterjgsp
walterjgsp merged commit 934e2a2 into rust Oct 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant