diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-25 17:35:28 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-25 17:35:28 -0500 |
| commit | 8c7b90c7758790722870ea5635d6f0c56fee6b32 (patch) | |
| tree | 86cd20abe1bf3045a78e72ca5ccb6ddcbfe42e4f /tests/test-prog-lisp.el | |
| parent | dae7a12e099a094f9b924c623302ad567d796f0e (diff) | |
| download | dotemacs-8c7b90c7758790722870ea5635d6f0c56fee6b32.tar.gz dotemacs-8c7b90c7758790722870ea5635d6f0c56fee6b32.zip | |
test(prog-lisp): cover the elisp and Common Lisp mode-setup functions
prog-lisp.el had no tests. I added four for the config it owns directly: cj/elisp-setup and cj/common-lisp-setup are each registered on their mode hook and set the buffer-local conventions this config picks (4-space, no tabs, fill-column 120 for elisp; 2-space, fill-column 100 for Common Lisp).
The module loads with use-package stubbed to a no-op, so no packages load, ensure, or download during the run. That keeps it batch-safe and independent of which Lisp packages happen to be installed.
Diffstat (limited to 'tests/test-prog-lisp.el')
| -rw-r--r-- | tests/test-prog-lisp.el | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/test-prog-lisp.el b/tests/test-prog-lisp.el new file mode 100644 index 00000000..ab980c5b --- /dev/null +++ b/tests/test-prog-lisp.el @@ -0,0 +1,66 @@ +;;; test-prog-lisp.el --- Smoke tests for prog-lisp owned config -*- lexical-binding: t; -*- + +;;; Commentary: + +;; prog-lisp.el is mostly use-package config; the behavior it owns directly is +;; the two mode-setup functions and their hook registration. These tests load +;; the module with use-package stubbed to a no-op, so no packages load, ensure, +;; or download in batch, then assert the setup hooks are registered and apply +;; the buffer-local conventions this config sets. + +;;; Code: + +(require 'ert) +(require 'cl-lib) +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) + +(defconst test-prog-lisp--repo-root + (file-name-directory + (directory-file-name + (file-name-directory (or load-file-name buffer-file-name)))) + "Repository root, derived from this file's location under tests/.") + +(defun test-prog-lisp--load () + "Load prog-lisp.el with use-package stubbed so no packages load or install." + (cl-letf (((symbol-function 'use-package) + (cons 'macro (lambda (&rest _) nil)))) + (load (expand-file-name "modules/prog-lisp.el" test-prog-lisp--repo-root) + nil t))) + +;;; cj/elisp-setup + +(ert-deftest test-prog-lisp-elisp-setup-registered () + "Normal: the elisp setup function is added to emacs-lisp-mode-hook." + (let ((emacs-lisp-mode-hook nil)) + (test-prog-lisp--load) + (should (memq 'cj/elisp-setup emacs-lisp-mode-hook)))) + +(ert-deftest test-prog-lisp-elisp-setup-sets-buffer-locals () + "Normal: elisp setup uses 4-space indent, no tabs, fill-column 120." + (test-prog-lisp--load) + (with-temp-buffer + (cl-letf (((symbol-function 'display-fill-column-indicator-mode) #'ignore)) + (cj/elisp-setup) + (should (= tab-width 4)) + (should (null indent-tabs-mode)) + (should (= fill-column 120))))) + +;;; cj/common-lisp-setup + +(ert-deftest test-prog-lisp-common-lisp-setup-registered () + "Normal: the Common Lisp setup function is added to lisp-mode-hook." + (let ((lisp-mode-hook nil)) + (test-prog-lisp--load) + (should (memq 'cj/common-lisp-setup lisp-mode-hook)))) + +(ert-deftest test-prog-lisp-common-lisp-setup-sets-buffer-locals () + "Normal: Common Lisp setup uses 2-space indent, no tabs, fill-column 100." + (test-prog-lisp--load) + (with-temp-buffer + (cj/common-lisp-setup) + (should (= tab-width 2)) + (should (null indent-tabs-mode)) + (should (= fill-column 100)))) + +(provide 'test-prog-lisp) +;;; test-prog-lisp.el ends here |
