]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix Eshell "which" test on MS-Windows
authorJim Porter <jporterbugs@gmail.com>
Sat, 15 Jun 2024 23:59:11 +0000 (16:59 -0700)
committerEshel Yaron <me@eshelyaron.com>
Mon, 17 Jun 2024 10:43:51 +0000 (12:43 +0200)
* test/lisp/eshell/esh-cmd-tests.el
(esh-cmd-test/which/plain/external-program): Compare the file name
case-insensitively on case-insensitive file systems.

* test/lisp/eshell/eshell-tests-helpers.el
(eshell-command-result--equal): Revert to the previous implementation.

(cherry picked from commit aefcccc1d411c973a3275959d7fa340d77f9157e)

test/lisp/eshell/esh-cmd-tests.el
test/lisp/eshell/eshell-tests-helpers.el

index 166a0ba1fff0bfc458465e8972685be24da77de4..70e1901c169ebb7cd15fa708bc1ae354aa83a481 100644 (file)
@@ -538,8 +538,16 @@ NAME is the name of the test case."
 (ert-deftest esh-cmd-test/which/plain/external-program ()
   "Check that `which' finds external programs."
   (skip-unless (executable-find "sh"))
-  (eshell-command-result-equal "which sh"
-                               (concat (executable-find "sh") "\n")))
+  (ert-info (#'eshell-get-debug-logs :prefix "Command logs: ")
+    (let ((actual (eshell-test-command-result "which sh"))
+          (expected (concat (executable-find "sh") "\n")))
+      ;; Eshell handles the casing of the PATH differently from
+      ;; `executable-find'.  This means that the results may not match
+      ;; exactly on case-insensitive file systems (e.g. when using
+      ;; MS-Windows), so compare case-insensitively there.
+      (should (if (file-name-case-insensitive-p actual)
+                  (string-equal-ignore-case actual expected)
+                (string-equal actual expected))))))
 
 (ert-deftest esh-cmd-test/which/plain/not-found ()
   "Check that `which' reports an error for not-found commands."
index acbe57a72833c209d69375e3d1c66b00ef9528de..bfd829c95e9640e9470973934456ae1b0a7b4266 100644 (file)
@@ -179,12 +179,7 @@ inserting the command."
 
 (defun eshell-command-result--equal (_command actual expected)
   "Compare the ACTUAL result of a COMMAND with its EXPECTED value."
-  (or (equal actual expected)
-      ;; Compare case-isensitively on case-insensitive filesystems.
-      (and (memq system-type '(windows-nt ms-dos))
-           (stringp actual)
-           (stringp expected)
-           (string-equal-ignore-case actual expected))))
+  (equal actual expected))
 
 (defun eshell-command-result--equal-explainer (command actual expected)
   "Explain the result of `eshell-command-result--equal'."