#!/usr/bin/env bash # Line coverage for the crate of the CURRENT directory (run from a crate # dir): prints nothing extra and writes coverage/lcov.info (git-ignored) — # the same artifact the CI coverage reporter consumes for the TypeScript # packages. # # cargo-llvm-cov is bootstrapped on demand so CI runners (which only get # rustup) can run the turbo `test:coverage` task unmodified. # # Note for fluent-iterable-rs: the `FluentIter` bodies are spliced into # src/fluent_iter.rs (generated by build.rs, git-ignored) precisely so they # are measured — cargo-llvm-cov skips everything under target/. # # Test binaries are excluded from the report: the number must # describe the library, not the test code that runs it. set -euo pipefail if ! command -v cargo-llvm-cov >/dev/null 2>&1; then echo "installing cargo-llvm-cov (one-off)..." >&2 cargo install cargo-llvm-cov --locked fi mkdir -p coverage cargo llvm-cov --all-targets \ --ignore-filename-regex '(\.cargo/registry|/rustc/|(^|/)tests/)' \ --lcov --output-path coverage/lcov.info