diff options
| author | Craig Jennings <c@cjennings.net> | 2026-04-30 00:22:24 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-04-30 00:22:24 -0500 |
| commit | 29c21851bddf76c5fd659d4225bb426fc1396750 (patch) | |
| tree | db092a78fe65212c483754268bda2b194266c213 | |
| parent | 6102ef81e7cc8af7cf847906cbc1bb27fc8a75e5 (diff) | |
| download | gloss-29c21851bddf76c5fd659d4225bb426fc1396750.tar.gz gloss-29c21851bddf76c5fd659d4225bb426fc1396750.zip | |
chore: add Cask + ert-runner test infrastructure
Replace the bare emacs --batch test runner with cask exec ert-runner.
The Makefile test targets now delegate. validate-parens, compile, and
lint stay on bare emacs --batch. Running cask once per file would slow
them down for no real win.
Adds:
- Cask file declaring sources and ert-runner as a dev dep
- .ert-runner config adding . and tests to load-path
- tests/test-helper.el placeholder for future test setup
- .gitignore entry for .cask/
All 88 tests pass in 0.19s via the new path.
| -rw-r--r-- | .ert-runner | 2 | ||||
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | Cask | 8 | ||||
| -rw-r--r-- | Makefile | 19 | ||||
| -rw-r--r-- | tests/test-helper.el | 17 |
5 files changed, 42 insertions, 7 deletions
diff --git a/.ert-runner b/.ert-runner new file mode 100644 index 0000000..676e285 --- /dev/null +++ b/.ert-runner @@ -0,0 +1,2 @@ +-L . +-L tests @@ -10,6 +10,9 @@ *.elc *.eln +# Cask-installed deps +/.cask/ + # Test logs /tests/*-output.log @@ -0,0 +1,8 @@ +(source gnu) +(source nongnu) +(source melpa) + +(package-file "gloss.el") + +(development + (depends-on "ert-runner")) @@ -10,11 +10,12 @@ TEST_FILES = $(wildcard tests/test-*.el) UNIT_TESTS = $(filter-out tests/test-integration-%.el,$(TEST_FILES)) INTEGRATION_TESTS = $(wildcard tests/test-integration-*.el) -.PHONY: help test test-unit test-integration test-file test-name validate-parens compile lint clean +.PHONY: help test test-unit test-integration test-file test-name validate-parens compile lint clean install help: @echo "Targets:" - @echo " make test Run all tests" + @echo " make install Install dev deps via Cask" + @echo " make test Run all tests via cask exec ert-runner" @echo " make test-unit Unit tests only" @echo " make test-integration Integration tests only" @echo " make test-file FILE=path/to/test-foo.el Run one test file" @@ -24,22 +25,26 @@ help: @echo " make lint elisp-lint pass" @echo " make clean Remove .elc" +install: + @cask install + test: - @$(EMACS) $(EMACSFLAGS) $(LOADPATH) -l ert $(addprefix -l ,$(TEST_FILES)) -f ert-run-tests-batch-and-exit + @cask exec ert-runner $(TEST_FILES) test-unit: - @$(EMACS) $(EMACSFLAGS) $(LOADPATH) -l ert $(addprefix -l ,$(UNIT_TESTS)) -f ert-run-tests-batch-and-exit + @cask exec ert-runner $(UNIT_TESTS) test-integration: - @$(EMACS) $(EMACSFLAGS) $(LOADPATH) -l ert $(addprefix -l ,$(INTEGRATION_TESTS)) -f ert-run-tests-batch-and-exit + @if [ -z "$(INTEGRATION_TESTS)" ]; then echo "No integration tests yet."; exit 0; fi + @cask exec ert-runner $(INTEGRATION_TESTS) test-file: @if [ -z "$(FILE)" ]; then echo "Usage: make test-file FILE=tests/test-NAME.el"; exit 1; fi - @$(EMACS) $(EMACSFLAGS) $(LOADPATH) -l ert -l "$(FILE)" -f ert-run-tests-batch-and-exit + @cask exec ert-runner "$(FILE)" test-name: @if [ -z "$(TEST)" ]; then echo "Usage: make test-name TEST=pattern"; exit 1; fi - @$(EMACS) $(EMACSFLAGS) $(LOADPATH) -l ert $(addprefix -l ,$(TEST_FILES)) --eval "(ert-run-tests-batch-and-exit \"$(TEST)\")" + @cask exec ert-runner --pattern "$(TEST)" $(TEST_FILES) validate-parens: @for f in $(PACKAGE_FILES) $(TEST_FILES); do \ diff --git a/tests/test-helper.el b/tests/test-helper.el new file mode 100644 index 0000000..783fafa --- /dev/null +++ b/tests/test-helper.el @@ -0,0 +1,17 @@ +;;; test-helper.el --- Test setup for ert-runner -*- lexical-binding: t -*- + +;; SPDX-License-Identifier: GPL-3.0-or-later + +;;; Commentary: + +;; Loaded automatically by ert-runner before test files. Adds the +;; tests/ directory to `load-path' so `(require \\='testutil-gloss)' and +;; sibling testutil files resolve. + +;;; Code: + +(let ((tests-dir (file-name-directory (or load-file-name buffer-file-name)))) + (add-to-list 'load-path tests-dir)) + +(provide 'test-helper) +;;; test-helper.el ends here |
