aboutsummaryrefslogtreecommitdiff
path: root/tests/run-coverage-file.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-04-22 19:58:00 -0500
committerCraig Jennings <c@cjennings.net>2026-04-22 19:58:00 -0500
commita97266c0e89ef8560824789063512d2613849fc9 (patch)
treeba320ed3d2dfedebade1fa79ece01baaa4750bd3 /tests/run-coverage-file.el
parentecca6c5809aa2945d593baae10308c0dcfe6ec17 (diff)
downloaddotemacs-a97266c0e89ef8560824789063512d2613849fc9.tar.gz
dotemacs-a97266c0e89ef8560824789063512d2613849fc9.zip
feat(coverage): wire make coverage target + simplecov pipeline
Completes the coverage v1 pipeline by adding the Makefile target, the undercover driver script, the exclusion list, and the .gitignore entry. Uses simplecov JSON rather than LCOV as the collection format. The LCOV vs simplecov choice: Undercover's :merge-report t option only supports simplecov. Since the pipeline runs tests per-file (matching test-unit's isolation pattern) and accumulates coverage across runs, merge-report is required. LCOV is better-supported by external coverage viewers, but for a primarily interactive workflow the on-disk format is an internal detail. Other moves in this commit: - Renamed cj/--coverage-parse-lcov to cj/--coverage-parse-simplecov and rewrote its tests for the JSON schema. Same signature, same semantics (file to set of covered lines), different parser. - Renamed the backend protocol's :lcov-path key to :report-path, format-neutral and matching the renamed cj/--coverage-elisp-report-path function. - The coverage target deletes modules/*.elc before running so undercover can instrument the .el sources. Without this, byte-compiled versions shadow the instrumentation and only a handful of pre-loaded modules end up with coverage data. - Excluded tests/test-all-comp-errors.el from make coverage runs. That test byte-compiles every module, which fails under undercover's instrumentation. Excluded only from coverage. Normal make test still runs it. - Updated docs/design/coverage.org to reflect the simplecov pivot with a historical note on why we moved off LCOV. Verified end-to-end: make coverage produces .coverage/simplecov.json with 2717 of 4559 executable lines hit across 44 tracked modules.
Diffstat (limited to 'tests/run-coverage-file.el')
-rw-r--r--tests/run-coverage-file.el40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/run-coverage-file.el b/tests/run-coverage-file.el
new file mode 100644
index 00000000..eeae5de9
--- /dev/null
+++ b/tests/run-coverage-file.el
@@ -0,0 +1,40 @@
+;;; run-coverage-file.el --- Undercover setup for per-file coverage runs -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; Loaded via `-l tests/run-coverage-file.el' by the Makefile's coverage
+;; target before each test file runs. Ensures undercover is active and
+;; configured to merge into the shared LCOV output so coverage data
+;; accumulates across all test-file invocations.
+;;
+;; Per-file isolation matches the project's `make test-unit' pattern:
+;; each test file runs in its own Emacs process, so tests that work
+;; under `make test' will also work under `make coverage'. See
+;; docs/design/coverage.org for the rationale.
+
+;;; Code:
+
+(require 'package)
+(setq package-user-dir (expand-file-name "elpa" user-emacs-directory))
+(package-initialize)
+
+(unless (require 'undercover nil t)
+ (message "")
+ (message "ERROR: undercover not installed.")
+ (message "Start Emacs interactively to install it via use-package,")
+ (message "or run: emacs --batch --eval \"(progn (package-refresh-contents) (package-install 'undercover))\"")
+ (message "")
+ (kill-emacs 1))
+
+;; Force coverage collection even when not in CI. Must happen AFTER
+;; `(require 'undercover)' because undercover.el's top-level
+;; `(setq undercover-force-coverage (getenv "UNDERCOVER_FORCE"))'
+;; would otherwise overwrite our value.
+(setq undercover-force-coverage t)
+
+(undercover "modules/*.el"
+ (:report-format 'simplecov)
+ (:report-file ".coverage/simplecov.json")
+ (:merge-report t)
+ (:send-report nil))
+
+;;; run-coverage-file.el ends here