diff options
| author | Craig Jennings <c@cjennings.net> | 2026-04-30 10:24:39 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-04-30 10:24:39 -0500 |
| commit | bb936fc082d4feb6a8759399ae07c840ea386b68 (patch) | |
| tree | d40202ce3ccbef02998ae956a9925e11b6b0b64d /tests/testutil-format-wiring.el | |
| parent | d28bd8404f856985d82d493416633fee02e737f5 (diff) | |
| download | dotemacs-bb936fc082d4feb6a8759399ae07c840ea386b68.tar.gz dotemacs-bb936fc082d4feb6a8759399ae07c840ea386b68.zip | |
test(prog): cover formatter wiring for python, go, shell, typescript
Four test files plus a shared testutil that locks in the formatter
bindings on C-; f across the four languages. Each test file checks:
- the format command is fboundp after the relevant package loads
- the C-; f binding resolves to that command (in the relevant
mode-map, or in the buffer-local map for hook-based wiring)
- the underlying executable is on PATH (skipped via ert-skip if
not installed)
No production change. The bindings were already at C-; f via two
mechanisms. Use-package :bind handles python and shell. The other
two install via local-set-key inside a hook. This regression net
catches silent breakage if any of those wirings get reshaped later.
The shared tests/testutil-format-wiring.el carries
format-test--ensure-packages-init, which calls package-initialize
once per batch run, since make test runs Emacs with --no-site-file
--no-site-lisp. Without it, use-package can't find blacken / shfmt
/ go-mode in elpa/. Also format-test--skip-unless-executable wraps
ert-skip with a clear "not on PATH" message so missing tools fail
informatively.
Per-language wiring inventory (no changes, just locked in):
- Python: blacken-buffer in python-ts-mode-map (use-package :bind)
- Shell: shfmt-buffer in sh-mode-map and bash-ts-mode-map
(use-package :bind, gated on :if executable-find)
- Go: gofmt via cj/go-mode-keybindings hook
- TS/JS/Web: cj/webdev-format-buffer via cj/webdev-keybindings hook
13 tests across 4 files, all passing.
Diffstat (limited to 'tests/testutil-format-wiring.el')
| -rw-r--r-- | tests/testutil-format-wiring.el | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/testutil-format-wiring.el b/tests/testutil-format-wiring.el new file mode 100644 index 00000000..eba57564 --- /dev/null +++ b/tests/testutil-format-wiring.el @@ -0,0 +1,38 @@ +;;; testutil-format-wiring.el --- Shared helpers for formatter wiring tests -*- lexical-binding: t; -*- + +;;; Commentary: +;; Helpers used by the per-language formatter-wiring tests. Two pieces: +;; +;; - `format-test--ensure-packages-init' bootstraps `package' once per +;; batch run so use-package forms in the prog-* modules can find +;; their packages in elpa. The Makefile's test target invokes Emacs +;; with --no-site-file --no-site-lisp, which skips the implicit +;; `package-initialize' that an interactive session would do at +;; startup. +;; +;; - `format-test--skip-unless-executable' is a thin wrapper around +;; `ert-skip' for the "formatter not installed on this machine" path. +;; Tests that need the underlying binary on PATH call this first. + +;;; Code: + +(require 'ert) +(require 'package) + +(defvar format-test--packages-initialized nil + "Non-nil once `package-initialize' has run in this batch process.") + +(defun format-test--ensure-packages-init () + "Initialise `package' the first time this is called in a batch run." + (unless format-test--packages-initialized + (package-initialize) + (setq format-test--packages-initialized t))) + +(defun format-test--skip-unless-executable (program) + "Skip the current ERT test unless PROGRAM is on PATH." + (unless (executable-find program) + (ert-skip (format "%s not on PATH; skipping installation-dependent assertion" + program)))) + +(provide 'testutil-format-wiring) +;;; testutil-format-wiring.el ends here |
