diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-05 05:20:44 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-05 05:20:44 -0500 |
| commit | 35131cb72c08c657d2a3389338d0c049d57e69bd (patch) | |
| tree | ad377579abb8bc143dd57c9a4f63fa244d137a94 /tests/test-wttrin-debug-mode-line.el | |
| parent | 306c4ea1dd07de0d862c0943aeb8b7e170a1b343 (diff) | |
| download | emacs-wttrin-35131cb72c08c657d2a3389338d0c049d57e69bd.tar.gz emacs-wttrin-35131cb72c08c657d2a3389338d0c049d57e69bd.zip | |
refactor: rename debug-wttrin-* commands to wttrin-debug-* with obsolete aliases
The four interactive commands in `wttrin-debug.el` used `debug-wttrin-` as their prefix instead of the package's `wttrin-debug-` prefix. package-lint flags this as a convention violation, and it makes M-x discovery slightly less consistent for users.
Renamed:
- `debug-wttrin-show-raw` -> `wttrin-debug-show-raw`
- `debug-wttrin-enable` -> `wttrin-debug-enable`
- `debug-wttrin-disable` -> `wttrin-debug-disable`
- `debug-wttrin-mode-line` -> `wttrin-debug-mode-line`
The old names stay available as `define-obsolete-function-alias` entries marked since 0.4.0, so anyone with a keybinding or `(call-interactively 'debug-wttrin-enable)` in their config keeps working. The byte-compiler will emit an obsolescence warning to nudge migration. Aliases will be removed in a future release.
Internal caller `wttrin--debug-mode-line-info` now invokes the new name. Test files renamed to match (`test-debug-wttrin-*.el` -> `test-wttrin-debug-*.el`); inside each, ert-deftest names and function calls were updated.
Added `tests/test-wttrin-debug-aliases.el` to verify each old name resolves via `indirect-function` to the new name and carries `byte-obsolete-info` with the expected target and "0.4.0" version.
Diffstat (limited to 'tests/test-wttrin-debug-mode-line.el')
| -rw-r--r-- | tests/test-wttrin-debug-mode-line.el | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/tests/test-wttrin-debug-mode-line.el b/tests/test-wttrin-debug-mode-line.el new file mode 100644 index 0000000..b9e135b --- /dev/null +++ b/tests/test-wttrin-debug-mode-line.el @@ -0,0 +1,79 @@ +;;; test-wttrin-debug-mode-line.el --- Tests for wttrin-debug-mode-line -*- lexical-binding: t; -*- + +;; Copyright (C) 2025-2026 Craig Jennings + +;;; Commentary: + +;; Unit tests for wttrin-debug-mode-line. This function is a UI-heavy +;; diagnostic dump, so testing focuses on the two top-level branches: +;; - When *wttr.in* is missing, no diagnostic buffer is produced. +;; - When *wttr.in* exists, the diagnostic buffer is created and contains +;; the expected section labels. + +;;; Code: + +(require 'ert) +(require 'wttrin) +(require 'testutil-wttrin) + +(require 'wttrin-debug + (expand-file-name "wttrin-debug.el" + (file-name-directory (locate-library "wttrin")))) + +;;; Setup and Teardown + +(defun test-wttrin-debug-mode-line-setup () + "Setup for wttrin-debug-mode-line tests." + (when (get-buffer "*wttr.in*") + (kill-buffer "*wttr.in*")) + (when (get-buffer "*wttrin-mode-debug*") + (kill-buffer "*wttrin-mode-debug*"))) + +(defun test-wttrin-debug-mode-line-teardown () + "Teardown for wttrin-debug-mode-line tests." + (when (get-buffer "*wttr.in*") + (kill-buffer "*wttr.in*")) + (when (get-buffer "*wttrin-mode-debug*") + (kill-buffer "*wttrin-mode-debug*"))) + +;;; Normal Cases + +(ert-deftest test-wttrin-debug-mode-line-normal-no-buffer-skips-diagnostic-buffer () + "When the *wttr.in* buffer is absent, no diagnostic buffer is created." + (test-wttrin-debug-mode-line-setup) + (unwind-protect + (progn + (wttrin-debug-mode-line) + (should-not (get-buffer "*wttrin-mode-debug*"))) + (test-wttrin-debug-mode-line-teardown))) + +(ert-deftest test-wttrin-debug-mode-line-normal-buffer-exists-creates-diagnostic-buffer () + "When the *wttr.in* buffer exists, the diagnostic buffer is created." + (test-wttrin-debug-mode-line-setup) + (unwind-protect + (progn + (with-current-buffer (get-buffer-create "*wttr.in*") + (wttrin-mode)) + (wttrin-debug-mode-line) + (should (get-buffer "*wttrin-mode-debug*"))) + (test-wttrin-debug-mode-line-teardown))) + +(ert-deftest test-wttrin-debug-mode-line-normal-diagnostic-buffer-contains-section-labels () + "Diagnostic buffer contains the expected section labels." + (test-wttrin-debug-mode-line-setup) + (unwind-protect + (progn + (with-current-buffer (get-buffer-create "*wttr.in*") + (wttrin-mode)) + (wttrin-debug-mode-line) + (with-current-buffer "*wttrin-mode-debug*" + (let ((contents (buffer-string))) + (should (string-match-p "Wttrin Mode-Line Debug Info" contents)) + (should (string-match-p "Buffer:" contents)) + (should (string-match-p "Major mode:" contents)) + (should (string-match-p "mode-name variable:" contents)) + (should (string-match-p "mode-line-format first 5 elements:" contents))))) + (test-wttrin-debug-mode-line-teardown))) + +(provide 'test-wttrin-debug-mode-line) +;;; test-wttrin-debug-mode-line.el ends here |
