aboutsummaryrefslogtreecommitdiff
path: root/tests/test-dwim-shell-config-empty-dirs.el
blob: 1c7129c387c1b488413acd7cea36c549b8725234 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
;;; test-dwim-shell-config-empty-dirs.el --- Tests for empty-dirs command builder -*- lexical-binding: t; -*-

;;; Commentary:
;; Covers cj/dwim-shell--empty-dirs-command, which builds the find command for
;; cj/dwim-shell-commands-remove-empty-directories.  The command is scoped to an
;; explicit root (shell-quoted) rather than the ambient current directory.

;;; Code:

(require 'ert)
(require 'dwim-shell-config)

(ert-deftest test-dwim-empty-dirs-command-shape ()
  "Normal: builds a find ... -type d -empty -delete command for the root."
  (let ((root "/home/me/proj"))
    (should (equal (cj/dwim-shell--empty-dirs-command root)
                   (format "find %s -type d -empty -delete  # <<*>>"
                           (shell-quote-argument root))))))

(ert-deftest test-dwim-empty-dirs-command-quotes-spaces ()
  "Boundary: a root with spaces is shell-quoted, not left to word-split."
  (let ((cmd (cj/dwim-shell--empty-dirs-command "/home/me/my dir")))
    (should (string-match-p (regexp-quote (shell-quote-argument "/home/me/my dir"))
                            cmd))
    (should-not (string-match-p "find /home/me/my dir " cmd))))

(provide 'test-dwim-shell-config-empty-dirs)
;;; test-dwim-shell-config-empty-dirs.el ends here