From 6d4461fc3264d6a730d32f1f8a5b58f78769a840 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 13 Jun 2026 13:51:56 -0500 Subject: fix(dwim-shell): valid zip name, real backup timestamp, reachable menu key Three audit fixes. Single-file zip named the archive after the input file (<>.<>), making invalid archives and a "foo." name for directories. It now builds .zip. The dated backup single-quoted $(date ...), so the stamp sat literal in the filename. Now the timestamp is interpolated in Elisp with format-time-string. The dired menu used "M-S-d", which Meta-Shift-d never emits (it sends M-D), so the menu was unreachable in plain dired. It now binds M-D, matching the dirvish sibling. Both command strings moved to top-level builders so they're unit-testable without loading the dwim-shell-command package. --- tests/test-dwim-shell-config-command-fixes.el | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/test-dwim-shell-config-command-fixes.el (limited to 'tests') diff --git a/tests/test-dwim-shell-config-command-fixes.el b/tests/test-dwim-shell-config-command-fixes.el new file mode 100644 index 000000000..2f49a868f --- /dev/null +++ b/tests/test-dwim-shell-config-command-fixes.el @@ -0,0 +1,33 @@ +;;; test-dwim-shell-config-command-fixes.el --- zip/backup command builders -*- lexical-binding: t; -*- + +;;; Commentary: +;; Two audit fixes, extracted into top-level command-string builders so they're +;; testable without loading the dwim-shell-command package (the command defuns +;; that call them live inside its use-package :config, which the batch test +;; harness doesn't instantiate): +;; - cj/dwim-shell--zip-single-file-command names the archive .zip +;; - cj/dwim-shell--dated-backup-command carries a real timestamp, not "$(date)" +;; The third fix (dired menu key M-S-d -> M-D) is a keybinding inside the same +;; :config block; it's verified in the live daemon, not here. + +;;; Code: + +(require 'ert) +(require 'dwim-shell-config) + +(ert-deftest test-dwim-zip-single-file-command-names-archive-dot-zip () + "Normal: the single-file zip template names the archive .zip, with no +leftover <> that would rebuild the input filename." + (let ((cmd (cj/dwim-shell--zip-single-file-command))) + (should (string-match-p "'<>\\.zip'" cmd)) + (should-not (string-match-p "<>" cmd)))) + +(ert-deftest test-dwim-dated-backup-command-carries-real-timestamp () + "Normal: the dated-backup template interpolates a real YYYYMMDD_HHMMSS stamp, +so the substitution can't sit dead inside single quotes." + (let ((cmd (cj/dwim-shell--dated-backup-command))) + (should (string-match-p "\\.[0-9]\\{8\\}_[0-9]\\{6\\}\\.bak'" cmd)) + (should-not (string-match-p "\\$(date" cmd)))) + +(provide 'test-dwim-shell-config-command-fixes) +;;; test-dwim-shell-config-command-fixes.el ends here -- cgit v1.2.3