From ac2d81c375330b12c7aec83a53ca659fb801a9f0 Mon Sep 17 00:00:00 2001 From: shawn Date: Mon, 1 Jun 2026 14:52:51 +0800 Subject: [PATCH 1/2] chore: add local test coverage via cargo-llvm-cov MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add `make coverage` / `coverage-html` / `coverage-lcov` targets backed by cargo-llvm-cov. Coverage is a local-only, on-demand tool — it is not wired into CI and is not part of `make check`. Document the targets and one-time setup in CLAUDE.md, and git-ignore the generated lcov.info. Co-Authored-By: Claude Opus 4.8 (1M context) --- .gitignore | 4 ++++ CLAUDE.md | 10 ++++++++++ Makefile | 14 +++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fb20ffa..26cf977 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,8 @@ /target + +# Coverage artifacts (cargo-llvm-cov) +/lcov.info + *.swp *.swo *~ diff --git a/CLAUDE.md b/CLAUDE.md index 690894d..5ea7ae8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -16,6 +16,16 @@ This project uses a `Makefile` as the **single source of truth** for build, form - `make check` — `fmt-check` + `lint` + `test` (run this before declaring work done or pushing) - `make all` — `fmt` + `check` + `build` +### Coverage (local-only, optional) + +Test coverage is measured with [`cargo-llvm-cov`](https://github.com/taiki-e/cargo-llvm-cov). It is **not** a CI gate and is **not** part of `make check` — use it on demand to see what the test suite exercises. + +- `make coverage` — print a per-file coverage summary in the terminal +- `make coverage-html` — generate an HTML report under `target/llvm-cov/html/index.html` +- `make coverage-lcov` — emit `lcov.info` (git-ignored) for external tooling + +One-time setup: `cargo install cargo-llvm-cov` and `rustup component add llvm-tools-preview`. The first run does an instrumented rebuild, so it is slower than a normal `make test`. + ### Required workflow before finishing any code change 1. Make your edits. diff --git a/Makefile b/Makefile index 991f5b3..de4a84c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: help fmt fmt-check lint test build build-release check all +.PHONY: help fmt fmt-check lint test build build-release check all coverage coverage-html coverage-lcov CARGO ?= cargo @@ -12,6 +12,9 @@ help: @echo " build-release - cargo build --release" @echo " check - fmt-check + lint + test (run before pushing)" @echo " all - fmt + check + build" + @echo " coverage - test coverage summary in the terminal (cargo-llvm-cov)" + @echo " coverage-html - generate an HTML coverage report under target/llvm-cov/html" + @echo " coverage-lcov - emit lcov.info for external tooling" fmt: $(CARGO) fmt --all @@ -34,3 +37,12 @@ build-release: check: fmt-check lint test all: fmt check build + +coverage: + $(CARGO) llvm-cov --all-targets + +coverage-html: + $(CARGO) llvm-cov --all-targets --html + +coverage-lcov: + $(CARGO) llvm-cov --all-targets --lcov --output-path lcov.info From 8785e7600e2c9d7b592f4df1a6abfa1f723b912f Mon Sep 17 00:00:00 2001 From: shawn Date: Mon, 1 Jun 2026 14:54:38 +0800 Subject: [PATCH 2/2] docs: condense coverage note into the Targets list Drop the standalone Coverage section; mention the targets in one line alongside the other make targets, matching how `test` is listed. Co-Authored-By: Claude Opus 4.8 (1M context) --- CLAUDE.md | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 5ea7ae8..4a6668e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -15,16 +15,7 @@ This project uses a `Makefile` as the **single source of truth** for build, form - `make build` — `cargo build --all-targets` - `make check` — `fmt-check` + `lint` + `test` (run this before declaring work done or pushing) - `make all` — `fmt` + `check` + `build` - -### Coverage (local-only, optional) - -Test coverage is measured with [`cargo-llvm-cov`](https://github.com/taiki-e/cargo-llvm-cov). It is **not** a CI gate and is **not** part of `make check` — use it on demand to see what the test suite exercises. - -- `make coverage` — print a per-file coverage summary in the terminal -- `make coverage-html` — generate an HTML report under `target/llvm-cov/html/index.html` -- `make coverage-lcov` — emit `lcov.info` (git-ignored) for external tooling - -One-time setup: `cargo install cargo-llvm-cov` and `rustup component add llvm-tools-preview`. The first run does an instrumented rebuild, so it is slower than a normal `make test`. +- `make coverage` — local test-coverage summary via `cargo-llvm-cov` (also `coverage-html` / `coverage-lcov`; on-demand, not a CI gate, not part of `make check`) ### Required workflow before finishing any code change