From ba22e0cc3c81d85b3ee8aaa337d6a388627c3af2 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 5 May 2026 05:11:55 -0500 Subject: test: cover wttrin-debug.el and expand lint to all source files I added 24 unit tests across six new files for wttrin-debug.el. They cover enable/disable, the debug-log writer, clear-log, show-log, and the mode-line diagnostic dump. That lifts wttrin-debug.el coverage from 27% to 95%, and overall coverage from 84% to 94%. Each function gets Normal / Boundary / Error categories where applicable. Globals like `wttrin-debug` and `wttrin--debug-log` are isolated per test with let-bindings. The dynamic-scope rebinding restores state cleanly at exit. I expanded the `lint` target to run on all three source files instead of just `wttrin.el`. Checkdoc and elisp-lint run on every file. Package-lint stays scoped to `wttrin.el` because the others aren't standalone packages. The tricky bit: `elisp-lint-file` re-runs package-lint internally as one of its validators. So the explicit guard alone wasn't enough. The fix binds `elisp-lint-ignored-validators` to include "package-lint" for the secondaries, which suppresses the re-run at the validator level. I also added `*-autoloads.el` to .gitignore. Eask generates `emacs-wttrin-autoloads.el` during install, and it shouldn't be tracked. I skipped one function: `wttrin--debug-mode-line-info` is a one-line dispatcher to `debug-wttrin-mode-line`. Testing it would assert the dispatch happened, which only tests Emacs. --- tests/test-debug-wttrin-enable.el | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/test-debug-wttrin-enable.el (limited to 'tests/test-debug-wttrin-enable.el') diff --git a/tests/test-debug-wttrin-enable.el b/tests/test-debug-wttrin-enable.el new file mode 100644 index 0000000..569547d --- /dev/null +++ b/tests/test-debug-wttrin-enable.el @@ -0,0 +1,43 @@ +;;; test-debug-wttrin-enable.el --- Tests for debug-wttrin-enable -*- lexical-binding: t; -*- + +;; Copyright (C) 2025-2026 Craig Jennings + +;;; Commentary: + +;; Unit tests for debug-wttrin-enable. Verifies the interactive command +;; flips `wttrin-debug' to t and is idempotent when already enabled. + +;;; Code: + +(require 'ert) +(require 'wttrin) +(require 'testutil-wttrin) + +(require 'wttrin-debug + (expand-file-name "wttrin-debug.el" + (file-name-directory (locate-library "wttrin")))) + +;;; Normal Cases + +(ert-deftest test-debug-wttrin-enable-normal-flips-from-nil-to-t () + "Calling enable when wttrin-debug is nil sets it to t." + (let ((wttrin-debug nil)) + (debug-wttrin-enable) + (should (eq wttrin-debug t)))) + +(ert-deftest test-debug-wttrin-enable-normal-idempotent-when-already-enabled () + "Calling enable when wttrin-debug is already t leaves it t." + (let ((wttrin-debug t)) + (debug-wttrin-enable) + (should (eq wttrin-debug t)))) + +;;; Boundary Cases + +(ert-deftest test-debug-wttrin-enable-boundary-overrides-non-boolean-truthy-value () + "Calling enable replaces a non-boolean truthy value with t." + (let ((wttrin-debug 'verbose)) + (debug-wttrin-enable) + (should (eq wttrin-debug t)))) + +(provide 'test-debug-wttrin-enable) +;;; test-debug-wttrin-enable.el ends here -- cgit v1.2.3