Skip to content

Coverage: make plz cover work and be documented for every language rule set #41

Closed

Description

@walterjgsp

Summary

plz cover does not reliably produce usable coverage across the language rule sets. Depending on the language, it fails outright, reports "No data", or reports numbers for the wrong files, and the requirements are only documented for Rust. Consumers of coverage reports (CI gates, dashboards such as Veritas) cannot trust the output today.

This was found while trying to ingest Please coverage into a quality dashboard (see the downstream issue linked below), but the problems are in the rule sets and their documentation and affect any user of plz cover.

Findings

Verified with ./pleasew cover on this repository's own test fixtures (test/rust/lib, test/ts/lib):

Rule set Result Cause
Rust Works: lib.rs 3/3 lines, 100.0% Needs [cover] fileextension = .rs in .plzconfig (documented in docs/rust/usage.md). Without it the report is silently Total coverage: No data.
TypeScript, Deno runner Works: calculator.ts 6/6 lines, 100.0% Needs .ts under [cover] fileextension, which the ts branch's .plzconfig does not set and docs/ts does not mention. Without it the report lists other languages' files instead (tools/please_ts/commands.go 0/251, total 0.2%), which is misleading.
TypeScript, Vitest runner Fails: the ts_test passes under plz test but fails under plz cover Startup Error: You cannot set "coverage.reportsDirectory" as <test run dir>. Vitest needs to be able to remove this directory before test run. The runner passes --coverage.reportsDirectory=<dir of the coverage file> (tools/please_ts/testrunner/vitest.go), and that directory is the test's working directory. The reported coverage is then 0/7 lines, 0.0%.
Kotlin, Swift, WIT Not verified

Reproduction (from a checkout of the ts branch):

./pleasew cover //test/ts/lib:calculator_test -o cover.fileextension:.ts          # works
./pleasew cover //test/ts/lib:calculator_vitest_test -o cover.fileextension:.ts --show_all_output   # fails

Not covered here: the Go rules come from the upstream please-build/go-rules plugin, not this repository.

Proposed work

  • TypeScript, Vitest runner: point --coverage.reportsDirectory at a subdirectory (for example <dir>/coverage), then copy or merge the generated lcov to the file Please expects, with a unit test in vitest_test.go. Check that a coverage provider (@vitest/coverage-v8 or istanbul) is available in the hermetic, offline vitest cache; if not, add it to the vitest_toolchain and document it.
  • Make a missing [cover] fileextension visible: document the required setting for every rule set (ts, kotlin, swift, and wit if applicable) as is done for Rust, and consider a plugin-level check or warning when a language's test targets run under cover without its extension configured, instead of a silent "No data" or a report of unrelated files.
  • Verify and fix Kotlin, Swift and WIT, and record the result for each.
  • Add a coverage smoke test per language (a fixture whose coverage must come out non-zero under plz cover) to the test suite or CI, so regressions like the Vitest one are caught.
  • Document the output of each rule set: where the report is written (plz-out/log/coverage.xml and coverage.json), its format (Cobertura or lcov), and what it contains (line coverage, branch coverage, and per-function data where available; per-function data is what lets consumers join coverage with complexity to find untested complex code).

Acceptance criteria

  • ./pleasew cover on each language's fixture reports plausible, non-zero coverage for the right files, including ts_test with runner = "vitest"
  • The [cover] requirement is documented for every rule set, and a missing setting is no longer silent
  • A coverage smoke test per language guards against regressions
  • Each rule set documents its report location, format and contents

Related

  • Downstream consumer: walterjgsp/veritas#64 (coverage prerequisite) and walterjgsp/veritas#20 (coverage tab)

Activity

  1. added
    bugSomething isn't working
    documentationImprovements or additions to documentation
    on Oct 3, 2026
  2. walterjgsp commented on Oct 3, 2026

    @walterjgsp
    ContributorAuthor

    Done in #42 (ts), #43 (kotlin), #44 (swift) and #45 (rust), all merged into their language branches.

    Fixed

    • TypeScript: plz cover now works with the Vitest runner, and [cover] fileextension = .ts is set.
    • Kotlin: JaCoCo failed on third-party classes in the merged test jar (0%); only project classes are reported now.
    • Swift: the coverage rebuild linked toolchain archives (0%), and transitive library chains failed to link on Linux; both fixed.
    • Rust: rust_test ignored its configured LLVM tools and used the host's, so coverage was 0% on a runner with an older LLVM; fixed.
    • A coverage smoke test now runs in each language's CI, and every rule set documents the required [cover] setting, the report location and format.

    Verified for upstream rules

    • Go (go-rules): works with .go in [cover] fileextension.
    • Python (python-rules): coverage support exists upstream; not run here.

    Not done

    • No plugin-level warning for a missing [cover] fileextension: Please has no hook for it, so it is documented instead.
    • Branch and per-function data: the reports are line-only. Per-function coverage can be derived from line data plus function ranges; keeping the raw lcov is tracked in Coverage: export raw lcov (functions, branches) for annotated source views #46.
    • WIT has no test rule, so there is nothing to cover.

    Releases (ts 0.5.3, kotlin 0.3.6, swift 0.2.1) are not cut yet; Rust is under Unreleased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions