From fabbdfcf2bfe468a7b98bcd3afae5e725fa0bdb7 Mon Sep 17 00:00:00 2001 From: Walter Pinto Date: Sat, 3 Oct 2026 08:52:44 +0100 Subject: [PATCH 1/8] docs(rust): document coverage report output and add smoke test Document report location, format and contents, and add a CI coverage smoke test. Refs #41 Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/ci-rust.yml | 7 +++++++ docs/rust/usage.md | 13 ++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-rust.yml b/.github/workflows/ci-rust.yml index 70490c8..1b6a0a2 100644 --- a/.github/workflows/ci-rust.yml +++ b/.github/workflows/ci-rust.yml @@ -66,3 +66,10 @@ jobs: run: ./pleasew --plain_output test //... env: VERITAS_NO_HOOK: "1" + + - name: Coverage smoke test (lib_test) + run: | + ./pleasew --plain_output cover //test/rust/lib:lib_test | tee cover.log + grep -Eq '^\s+lib\.rs [1-9][0-9]*/' cover.log + env: + VERITAS_NO_HOOK: "1" diff --git a/docs/rust/usage.md b/docs/rust/usage.md index 23c4116..e8cd5ab 100644 --- a/docs/rust/usage.md +++ b/docs/rust/usage.md @@ -308,7 +308,18 @@ Display detailed, line-by-line covered source listings: ./pleasew cover -l //test/lib:lib_test ``` -### 4. Per-Rule Coverage Control +### 4. Report Output + +- **Location**: Please merges the per-test results into + `plz-out/log/coverage.xml` (Cobertura XML) and `plz-out/log/coverage.json` + (per-file line markers plus per-file and per-directory percentages). +- **Contents**: line coverage only. Branch coverage and per-function data are + not emitted, so consumers cannot join coverage with per-function complexity + from this report. +- **Missing `[cover]` setting**: without `fileextension = .rs` the report is + silently `Total coverage: No data`. + +### 5. Per-Rule Coverage Control You can enable or disable coverage instrumentation on individual rules: From 779fe803c541f616345513d340a03658d8d967f8 Mon Sep 17 00:00:00 2001 From: Walter Pinto Date: Sat, 3 Oct 2026 08:56:55 +0100 Subject: [PATCH 2/8] docs(rust): add changelog entry for coverage fixes Refs #41 Co-Authored-By: Claude Sonnet 5.5 --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfa8901..90c2c2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.5.1] - 2026-10-03 + +### Documentation + +- Documented the Rust coverage report location, format and contents, and the + silent `No data` result when `[cover] fileextension = .rs` is missing. +- Added a CI coverage smoke test. + ## [0.5.0] - 2026-09-19 ### Added From 787886b5b04a8a5b08d8e558b0fd2e1e3f5f7bfb Mon Sep 17 00:00:00 2001 From: Walter Pinto Date: Sat, 3 Oct 2026 09:02:45 +0100 Subject: [PATCH 3/8] docs(rust): mark coverage docs as unreleased Co-Authored-By: Claude Sonnet 5.5 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90c2c2a..1a24311 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.5.1] - 2026-10-03 +## [Unreleased] ### Documentation From bbaa85129fc97f4715894656e07209856b77ec5e Mon Sep 17 00:00:00 2001 From: Walter Pinto Date: Sat, 3 Oct 2026 09:08:25 +0100 Subject: [PATCH 4/8] ci(rust): capture stderr in the coverage smoke test plz prints the coverage table on stderr, so tee saw nothing. Also show test output to diagnose a 0% result seen on the runner. Refs #41 Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/ci-rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-rust.yml b/.github/workflows/ci-rust.yml index 1b6a0a2..3333b33 100644 --- a/.github/workflows/ci-rust.yml +++ b/.github/workflows/ci-rust.yml @@ -69,7 +69,7 @@ jobs: - name: Coverage smoke test (lib_test) run: | - ./pleasew --plain_output cover //test/rust/lib:lib_test | tee cover.log + ./pleasew --plain_output cover //test/rust/lib:lib_test 2>&1 | tee cover.log grep -Eq '^\s+lib\.rs [1-9][0-9]*/' cover.log env: VERITAS_NO_HOOK: "1" From 2fbdb1d8c3eeff629041374bf8c502d3942d0bc0 Mon Sep 17 00:00:00 2001 From: Walter Pinto Date: Sat, 3 Oct 2026 09:08:38 +0100 Subject: [PATCH 5/8] ci(rust): show test output in the coverage smoke test Diagnose a 0% result seen only on the runner. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/ci-rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-rust.yml b/.github/workflows/ci-rust.yml index 3333b33..2cfd341 100644 --- a/.github/workflows/ci-rust.yml +++ b/.github/workflows/ci-rust.yml @@ -69,7 +69,7 @@ jobs: - name: Coverage smoke test (lib_test) run: | - ./pleasew --plain_output cover //test/rust/lib:lib_test 2>&1 | tee cover.log + ./pleasew --plain_output cover --show_all_output //test/rust/lib:lib_test 2>&1 | tee cover.log grep -Eq '^\s+lib\.rs [1-9][0-9]*/' cover.log env: VERITAS_NO_HOOK: "1" From e3ff0d860eb8e40c041fde4a8c094aa56d6cee94 Mon Sep 17 00:00:00 2001 From: Walter Pinto Date: Sat, 3 Oct 2026 09:46:24 +0100 Subject: [PATCH 6/8] fix(rust): name the llvm-profdata that failed to merge Report the resolved path and version in the coverage error to diagnose a runner-only failure; print the host rustc in the smoke step. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/ci-rust.yml | 1 + tools/please_rust/testrunner/runner.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-rust.yml b/.github/workflows/ci-rust.yml index 2cfd341..dbbdb43 100644 --- a/.github/workflows/ci-rust.yml +++ b/.github/workflows/ci-rust.yml @@ -69,6 +69,7 @@ jobs: - name: Coverage smoke test (lib_test) run: | + rustc -vV | grep -i 'release\|LLVM' || true ./pleasew --plain_output cover --show_all_output //test/rust/lib:lib_test 2>&1 | tee cover.log grep -Eq '^\s+lib\.rs [1-9][0-9]*/' cover.log env: diff --git a/tools/please_rust/testrunner/runner.go b/tools/please_rust/testrunner/runner.go index f104b6f..28cfcf9 100644 --- a/tools/please_rust/testrunner/runner.go +++ b/tools/please_rust/testrunner/runner.go @@ -133,7 +133,8 @@ func mergeProfdata(profdataPath, tmpDir string, profrawFiles []string) (string, cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { - return "", fmt.Errorf("llvm-profdata merge failed: %w", err) + version, _ := exec.Command(resolved, "--version").CombinedOutput() + return "", fmt.Errorf("llvm-profdata merge failed using %s (%s): %w", resolved, strings.Join(strings.Fields(string(version)), " "), err) } return mergedPath, nil } From 8b6383cd5ffb385b2ff37ffafc10f4fe57457267 Mon Sep 17 00:00:00 2001 From: Walter Pinto Date: Sat, 3 Oct 2026 09:48:33 +0100 Subject: [PATCH 7/8] fix(rust): pass the configured llvm tools to rust_test CONFIG.get("RUST.X") does not read plugin config, so LlvmProfdataTool, LlvmCovTool and Coverage were ignored: test_tools held only the runner and llvm-profdata was found on the host. On a runner with an older host LLVM the merge failed ("unsupported instrumentation profile format version") and coverage was 0%. Read the keys as CONFIG.RUST.. Refs #41 Co-Authored-By: Claude Sonnet 5.5 --- build_defs/rust/rust.build_defs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build_defs/rust/rust.build_defs b/build_defs/rust/rust.build_defs index fe0a648..2792b1e 100644 --- a/build_defs/rust/rust.build_defs +++ b/build_defs/rust/rust.build_defs @@ -61,13 +61,13 @@ def _is_coverage_enabled(rule_coverage=None): """Determines whether coverage instrumentation is enabled for a target.""" if rule_coverage is not None: return rule_coverage - return CONFIG.get("RUST.COVERAGE", "true").lower() in ("true", "1", "yes", "on") + return (CONFIG.RUST.COVERAGE or "true").lower() in ("true", "1", "yes", "on") def _test_tools(profdata_override=None, cov_override=None): """Returns test_tools dictionary for rust_test.""" tools = {"TOOL": [_rust_tool()]} - profdata = profdata_override or CONFIG.get("RUST.LLVM_PROFDATA_TOOL", "") - cov = cov_override or CONFIG.get("RUST.LLVM_COV_TOOL", "") + profdata = profdata_override or CONFIG.RUST.LLVM_PROFDATA_TOOL + cov = cov_override or CONFIG.RUST.LLVM_COV_TOOL if profdata and (profdata.startswith("//") or profdata.startswith("///") or profdata.startswith(":")): tools["LLVM_PROFDATA"] = [profdata] if cov and (cov.startswith("//") or cov.startswith("///") or cov.startswith(":")): From 52fd5c141e83c52c41e5856657d678a3a3ccbdec Mon Sep 17 00:00:00 2001 From: Walter Pinto Date: Sat, 3 Oct 2026 09:49:45 +0100 Subject: [PATCH 8/8] docs(rust): changelog for the llvm tool fix; drop CI diagnostics Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/ci-rust.yml | 3 +-- CHANGELOG.md | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-rust.yml b/.github/workflows/ci-rust.yml index dbbdb43..3c664bb 100644 --- a/.github/workflows/ci-rust.yml +++ b/.github/workflows/ci-rust.yml @@ -69,8 +69,7 @@ jobs: - name: Coverage smoke test (lib_test) run: | - rustc -vV | grep -i 'release\|LLVM' || true - ./pleasew --plain_output cover --show_all_output //test/rust/lib:lib_test 2>&1 | tee cover.log + ./pleasew --plain_output cover //test/rust/lib:lib_test 2>&1 | tee cover.log grep -Eq '^\s+lib\.rs [1-9][0-9]*/' cover.log env: VERITAS_NO_HOOK: "1" diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a24311..76c6ab7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,15 @@ and this project adheres to ## [Unreleased] +### Fixed + +- `rust_test` ignored `LlvmProfdataTool`, `LlvmCovTool` and `Coverage` (plugin + config was read with `CONFIG.get`, which does not see it), so `llvm-profdata` + was taken from the host. With an older host LLVM the merge failed + (`unsupported instrumentation profile format version`) and `plz cover` + reported 0%. The configured tools are now passed to the test. +- The coverage error now names the `llvm-profdata` that failed. + ### Documentation - Documented the Rust coverage report location, format and contents, and the