aboutsummaryrefslogtreecommitdiff
path: root/Makefile
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 /Makefile
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 'Makefile')
-rw-r--r--Makefile100
1 files changed, 97 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 092de0f..0f952b2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,18 +1,43 @@
# Makefile for chime.el
-# Delegates all test targets to tests/Makefile.
+# Test targets delegate to tests/Makefile.
+# setup / compile / coverage operate at project root.
# Run 'make help' for available commands.
+EASK ?= eask
+EMACS_BATCH = $(EASK) emacs --batch
+# Coverage / test loops need default-directory = tests/ so test files'
+# relative paths (../chime.el, sibling test files) resolve as they do
+# under tests/Makefile.
+EMACS_BATCH_TESTS = $(EASK) emacs --batch --eval '(cd "tests/")'
+
TEST_DIR = tests
+SOURCE_FILE = chime.el
+
+# Coverage configuration
+COVERAGE_DIR = .coverage
+COVERAGE_FILE = $(COVERAGE_DIR)/simplecov.json
+
+# Unit-test files (used by coverage loop, mirroring tests/Makefile)
+UNIT_TESTS = $(filter-out $(TEST_DIR)/test-bootstrap.el $(TEST_DIR)/test-integration-%.el, \
+ $(wildcard $(TEST_DIR)/test-*.el))
-.PHONY: help test test-unit test-integration test-file test-one test-name \
- count list validate lint check-deps clean
+# Include local overrides if present (per-machine knobs, not committed)
+-include makefile-local
+
+.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
help:
@$(MAKE) -C $(TEST_DIR) help
+# Test target delegations
test:
@$(MAKE) -C $(TEST_DIR) test
+test-all:
+ @$(MAKE) -C $(TEST_DIR) test-all
+
test-unit:
@$(MAKE) -C $(TEST_DIR) test-unit
@@ -45,3 +70,72 @@ check-deps:
clean:
@$(MAKE) -C $(TEST_DIR) clean
+ @rm -rf $(COVERAGE_DIR)
+
+#
+# Project-root targets — operate on chime.el at root level
+#
+
+# Install runtime + development dependencies via eask
+setup:
+ @if ! command -v $(EASK) >/dev/null 2>&1; then \
+ echo "[✗] eask not found on PATH"; \
+ echo " Install: npm install -g @emacs-eask/cli"; \
+ echo " Or: https://emacs-eask.github.io/Getting-Started/Install-Eask/"; \
+ exit 1; \
+ fi
+ @echo "[i] Installing dependencies via eask..."
+ @$(EASK) install-deps --dev
+ @echo "[✓] Dependencies installed in .eask/"
+
+# Byte-compile chime.el — surfaces free-variable / unused-let / suspicious-call
+# warnings that checkdoc and elisp-lint don't catch. byte-compile-error-on-warn
+# stays nil for now to match `make build' permissiveness; tighten once the
+# warning backlog is clear.
+compile:
+ @echo "[i] Byte-compiling $(SOURCE_FILE)..."
+ @$(EMACS_BATCH) \
+ --eval "(progn \
+ (setq byte-compile-error-on-warn nil) \
+ (batch-byte-compile))" $(SOURCE_FILE)
+ @echo "[✓] Compilation complete"
+
+#
+# Coverage (undercover + simplecov JSON)
+#
+# Each unit-test file runs in its own Emacs process (matching test-unit);
+# tests/run-coverage-file.el instruments chime.el before the source is
+# loaded, and undercover merges per-file results into a single simplecov JSON.
+
+coverage: coverage-clean $(COVERAGE_DIR)
+ @echo "[i] Cleaning .elc files so undercover can instrument source..."
+ @find . -name "*.elc" -delete
+ @echo "[i] Running coverage across $(words $(UNIT_TESTS)) unit-test file(s)..."
+ @echo " (slower than 'make test-unit' — each file runs in its own Emacs)"
+ @failed=0; \
+ for test in $(UNIT_TESTS); do \
+ echo " Coverage: $$test..."; \
+ testfile=$$(basename $$test); \
+ $(EMACS_BATCH_TESTS) \
+ -l ert \
+ -l run-coverage-file.el \
+ -l ../$(SOURCE_FILE) \
+ -l $$testfile \
+ --eval "(ert-run-tests-batch-and-exit '(not (tag :slow)))" || failed=$$((failed + 1)); \
+ done; \
+ if [ $$failed -gt 0 ]; then \
+ echo "[!] $$failed test file(s) failed during coverage run"; \
+ exit 1; \
+ fi
+ @if [ -f $(COVERAGE_FILE) ]; then \
+ echo "[✓] Coverage report: $(COVERAGE_FILE) ($$(du -h $(COVERAGE_FILE) | cut -f1))"; \
+ else \
+ echo "[!] No coverage file produced; check that undercover is installed"; \
+ exit 1; \
+ fi
+
+coverage-clean:
+ @rm -f $(COVERAGE_FILE)
+
+$(COVERAGE_DIR):
+ @mkdir -p $(COVERAGE_DIR)