]> git.eshelyaron.com Git - emacs.git/commitdiff
; * test/lisp/shell-tests.el: Add tests for shell-dirtrack-mode (bug#64311)
authorVladimir Sedach <vas@oneofus.la>
Tue, 27 Jun 2023 04:30:25 +0000 (22:30 -0600)
committerEli Zaretskii <eliz@gnu.org>
Sat, 8 Jul 2023 16:30:06 +0000 (19:30 +0300)
test/lisp/shell-tests.el

index db9124e24350414d704d181fd06d6388f9540a57..ddddfdb2e0f79f3a4796d04c80f758426eb4572f 100644 (file)
     (should (equal (split-string-shell-command "ls /tmp/foo\\ bar")
                    '("ls" "/tmp/foo bar")))))
 
+(ert-deftest shell-dirtrack-on-by-default ()
+  (with-temp-buffer
+    (shell-mode)
+    (should shell-dirtrack-mode)))
+
+(ert-deftest shell-dirtrack-should-not-be-on-in-unrelated-modes ()
+  (with-temp-buffer
+    (should (not shell-dirtrack-mode))))
+
+(ert-deftest shell-dirtrack-sets-list-buffers-directory ()
+  (let ((start-dir default-directory))
+    (with-temp-buffer
+      (should-not list-buffers-directory)
+      (shell-mode)
+      (shell-cd "..")
+      (should list-buffers-directory)
+      (should (not (equal start-dir list-buffers-directory)))
+      (should (string-prefix-p list-buffers-directory start-dir)))))
+
+(ert-deftest shell-directory-tracker-cd ()
+  (let ((start-dir default-directory))
+    (with-temp-buffer
+      (should-not list-buffers-directory)
+      (shell-mode)
+      (cl-letf (((symbol-function 'shell-unquote-argument)
+                 (lambda (x) x)))
+        (shell-directory-tracker "cd .."))
+      (should list-buffers-directory)
+      (should (not (equal start-dir list-buffers-directory)))
+      (should (string-prefix-p list-buffers-directory start-dir)))))
+
 ;;; shell-tests.el ends here