From 914ab07da513daebd15c7bc65ac334cde5fbb769 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 26 May 2026 02:54:39 -0500 Subject: feat(coverage): print a terminal coverage summary from the SimpleCov report `make coverage` only reported the JSON's file size, so reading the real number meant opening the report by hand. I added a self-contained `scripts/coverage-summary.el` that parses the SimpleCov JSON and prints per-file covered/total lines with a percent, a line-weighted project figure, and a source-weighted figure. A tracked source missing from the report counts as 0% rather than dropping out silently, so a source that never got instrumented still shows up. A new `coverage-summary` target runs it against the last report, and `make coverage` chains it onto the tail of a local run (CI emits coveralls.json, not simplecov.json, so it's skipped there). Covered by `tests/test-pearl-coverage-summary.el`: parser hit/executable/merge-key semantics, the per-file records, and the error paths for a missing or malformed report. --- Makefile | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 621cf95..3c7ab82 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ ALL_TESTS = $(filter-out $(TEST_DIR)/test-bootstrap.el, \ .PHONY: help test test-all test-unit test-integration test-file test-one test-name \ count list validate lint check-deps clean \ - setup compile coverage coverage-clean + setup compile coverage coverage-summary coverage-clean help: @$(MAKE) -C $(TEST_DIR) help @@ -148,6 +148,26 @@ coverage: coverage-clean $(COVERAGE_DIR) echo "[!] No coverage file produced; check that undercover is installed"; \ exit 1; \ fi + @# Print the human-readable summary after a local run. CI emits + @# coveralls.json (not simplecov.json) and the upload action reports + @# instead, so skip the terminal summary there. + @if [ -z "$$CI" ] && [ -f $(COVERAGE_FILE) ]; then \ + $(MAKE) --no-print-directory coverage-summary; \ + fi + +# Print a human-readable summary of the SimpleCov report: per-file +# covered/total lines + percent, a line-weighted project figure, and a +# source-weighted figure where a tracked source missing from the report +# counts as 0% (so an un-instrumented source shows up rather than vanishing +# from the numbers). Run on its own against an existing report, or +# automatically at the tail of 'make coverage'. +coverage-summary: + @if [ ! -f $(COVERAGE_FILE) ]; then \ + echo "[!] No coverage report at $(COVERAGE_FILE). Run 'make coverage' first."; \ + exit 1; \ + fi + @$(EMACS_BATCH) -L scripts -l coverage-summary \ + --eval '(pearl-coverage-print-summary "$(COVERAGE_FILE)" (list "$(SOURCE_FILE)") "$(CURDIR)")' coverage-clean: @rm -f $(COVERAGE_FILE) -- cgit v1.2.3