aboutsummaryrefslogtreecommitdiff
path: root/tests/run-coverage-file.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-05 04:57:14 -0500
committerCraig Jennings <c@cjennings.net>2026-05-05 04:57:14 -0500
commite54041ac630fe31a9968cf41c452feee317a4049 (patch)
treea59db424efd5d842106383a71e3fdaf2f9ac0b48 /tests/run-coverage-file.el
parentd8fd744b0669c6a4b3fb08fb4d75ab421c3a0416 (diff)
downloadchime-e54041ac630fe31a9968cf41c452feee317a4049.tar.gz
chime-e54041ac630fe31a9968cf41c452feee317a4049.zip
build: add eask manifest and setup/compile/coverage targets
I switched the test runner from `~/.emacs.d/elpa`-grep to eask. With this, `make setup` installs every dep into a project-local `.eask/`, so test runs don't depend on whatever's in my global elpa. It also lets us catch missing Package-Requires entries before MELPA submission. New targets: - `make setup` — runs `eask install-deps --dev` - `make compile` — byte-compiles chime.el and surfaces warnings that checkdoc and elisp-lint don't catch - `make coverage` — runs the unit suite under undercover and writes a simplecov JSON to `.coverage/simplecov.json` - `make test-all` — runs every test, including `:slow` tagged - `-include makefile-local` in both Makefiles, for per-machine knobs I added `ERT_FAST_SELECTOR` so `make test`, `test-unit`, `test-integration`, and `test-file` exclude tests tagged `:slow`. When we tag end-to-end integration tests as `:slow`, they'll stay out of the fast feedback loop until someone explicitly asks for them via `make test-all`. Eask treats CWD as its workspace. So all eask invocations now run from project root, with `(cd "tests/")' as the first `--eval' to restore Emacs's default-directory. That preserves the relative loads the existing test files and test-bootstrap.el rely on, without touching either. I updated `.gitignore` for `.eask/`, `.coverage/`, and the optional `makefile-local` files.
Diffstat (limited to 'tests/run-coverage-file.el')
-rw-r--r--tests/run-coverage-file.el44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/run-coverage-file.el b/tests/run-coverage-file.el
new file mode 100644
index 0000000..0a07696
--- /dev/null
+++ b/tests/run-coverage-file.el
@@ -0,0 +1,44 @@
+;;; run-coverage-file.el --- Undercover setup for per-file coverage runs -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; Loaded by `make coverage' before each test file runs, BEFORE
+;; chime.el is loaded. Instrumenting must happen first so the
+;; subsequent load picks up the instrumented source.
+;;
+;; Coverage data is merged across per-file invocations into a single
+;; simplecov JSON at .coverage/simplecov.json (under the project root).
+
+;;; Code:
+
+(unless (require 'undercover nil t)
+ (message "")
+ (message "ERROR: undercover not installed.")
+ (message "Run 'make setup' to install development dependencies.")
+ (message "")
+ (kill-emacs 1))
+
+;; Resolve project root from this file's location so undercover patterns
+;; and the report-file path don't depend on default-directory at load time.
+(defvar run-coverage--project-root
+ (file-name-directory
+ (directory-file-name
+ (file-name-directory (or load-file-name buffer-file-name))))
+ "Absolute path to the chime project root.")
+
+;; Force coverage collection in non-CI environments. Must be set after
+;; loading undercover because the library's top-level form
+;; `(setq undercover-force-coverage (getenv "UNDERCOVER_FORCE"))' would
+;; otherwise overwrite the value.
+(setq undercover-force-coverage t)
+
+;; The `undercover' macro splices each configuration list into `(list ,@it)',
+;; which evaluates the elements. Wildcard strings have to stay atoms — using
+;; `(:files ...)' form lets us evaluate `expand-file-name' to an absolute path.
+(undercover (:files (expand-file-name "chime.el" run-coverage--project-root))
+ (:report-format 'simplecov)
+ (:report-file (expand-file-name ".coverage/simplecov.json"
+ run-coverage--project-root))
+ (:merge-report t)
+ (:send-report nil))
+
+;;; run-coverage-file.el ends here