From b64c05684bf0ff3a036bf562eb8e8e2bccf81218 Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Sat, 15 Jun 2024 16:59:11 -0700 Subject: [PATCH] Fix Eshell "which" test on MS-Windows * 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 | 12 ++++++++++-- test/lisp/eshell/eshell-tests-helpers.el | 7 +------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/test/lisp/eshell/esh-cmd-tests.el b/test/lisp/eshell/esh-cmd-tests.el index 166a0ba1fff..70e1901c169 100644 --- a/test/lisp/eshell/esh-cmd-tests.el +++ b/test/lisp/eshell/esh-cmd-tests.el @@ -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." diff --git a/test/lisp/eshell/eshell-tests-helpers.el b/test/lisp/eshell/eshell-tests-helpers.el index acbe57a7283..bfd829c95e9 100644 --- a/test/lisp/eshell/eshell-tests-helpers.el +++ b/test/lisp/eshell/eshell-tests-helpers.el @@ -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'." -- 2.39.2