aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2024-06-09 10:56:39 +0300
committerEli Zaretskii2024-06-09 10:56:39 +0300
commitf869f1ffc2ef0e126e633553e6b4c38bee90f7f8 (patch)
treed7fc76046664b0c8b83399e25f9c34369f8984b8
parent8253228d55b368ad7ea4d66d802059e8afff2b12 (diff)
downloademacs-f869f1ffc2ef0e126e633553e6b4c38bee90f7f8.tar.gz
emacs-f869f1ffc2ef0e126e633553e6b4c38bee90f7f8.zip
Fix Eshell tests on MS-Windows
* lisp/eshell/esh-util.el (eshell-get-path): Don't add "." if it is already there. * test/lisp/eshell/esh-var-tests.el (esh-var-test/path-var/preserve-across-hosts): Skip on MS-Windows. (esh-var-test/path-var/set, esh-var-test/path-var/set-locally): Quote the PATH value, for MS-Windows. * test/lisp/eshell/esh-util-tests.el (esh-util-test/path/get): No need to add ".": it is already done by 'eshell-get-path'. * test/lisp/eshell/esh-proc-tests.el (esh-proc-test/kill-pipeline): Accept empty string as valid output. (esh-proc-test/sigpipe-exits-process): Skip on MS-Windows: no SIGPIPE. (esh-proc-test/emacs-command): Quote correctly for MS-Windows. * test/lisp/eshell/em-unix-tests.el (em-unix-test/compile/interactive): Fix test on MS-Windows. * test/lisp/eshell/em-script-tests.el (em-script-test/batch-file): Skip on MS-Windows. * test/lisp/eshell/eshell-tests-helpers.el (eshell-command-result--equal): Compare strings (file names) case-insensitively on MS-Windows.
-rw-r--r--lisp/eshell/esh-util.el3
-rw-r--r--test/lisp/eshell/em-script-tests.el1
-rw-r--r--test/lisp/eshell/em-unix-tests.el7
-rw-r--r--test/lisp/eshell/esh-proc-tests.el23
-rw-r--r--test/lisp/eshell/esh-util-tests.el5
-rw-r--r--test/lisp/eshell/esh-var-tests.el6
-rw-r--r--test/lisp/eshell/eshell-tests-helpers.el7
7 files changed, 37 insertions, 15 deletions
diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el
index 85e30e23cec..1504d89731d 100644
--- a/lisp/eshell/esh-util.el
+++ b/lisp/eshell/esh-util.el
@@ -417,7 +417,8 @@ as the $PATH was actually specified."
417 (butlast (exec-path)))))) 417 (butlast (exec-path))))))
418 (when (and (not literal-p) 418 (when (and (not literal-p)
419 (not remote) 419 (not remote)
420 (eshell-under-windows-p)) 420 (eshell-under-windows-p)
421 (not (member "." path)))
421 (push "." path)) 422 (push "." path))
422 (if (and remote (not literal-p)) 423 (if (and remote (not literal-p))
423 (mapcar (lambda (x) (concat remote x)) path) 424 (mapcar (lambda (x) (concat remote x)) path)
diff --git a/test/lisp/eshell/em-script-tests.el b/test/lisp/eshell/em-script-tests.el
index f3adbae9df7..94afe775a3b 100644
--- a/test/lisp/eshell/em-script-tests.el
+++ b/test/lisp/eshell/em-script-tests.el
@@ -115,6 +115,7 @@
115 115
116(ert-deftest em-script-test/batch-file () 116(ert-deftest em-script-test/batch-file ()
117 "Test running an Eshell script file as a batch script." 117 "Test running an Eshell script file as a batch script."
118 (skip-unless (not (memq system-type '(windows-nt ms-dos))))
118 (ert-with-temp-file temp-file 119 (ert-with-temp-file temp-file
119 :text (format 120 :text (format
120 "#!/usr/bin/env -S %s --batch -f eshell-batch-file\necho hi" 121 "#!/usr/bin/env -S %s --batch -f eshell-batch-file\necho hi"
diff --git a/test/lisp/eshell/em-unix-tests.el b/test/lisp/eshell/em-unix-tests.el
index 2ee42c81333..7312fb831cd 100644
--- a/test/lisp/eshell/em-unix-tests.el
+++ b/test/lisp/eshell/em-unix-tests.el
@@ -43,7 +43,12 @@
43 "#<buffer \\*compilation\\*>") 43 "#<buffer \\*compilation\\*>")
44 (with-current-buffer "*compilation*" 44 (with-current-buffer "*compilation*"
45 (forward-line 3) 45 (forward-line 3)
46 (should (looking-at "echo hello"))))) 46 (should (looking-at
47 ;; MS-Windows/DOS quote by unconditionally enclosing in
48 ;; double quotes.
49 (if (memq system-type '(windows-nt ms-dos))
50 "\"echo\" \"hello\""
51 "echo hello"))))))
47 52
48(ert-deftest em-unix-test/compile/noninteractive () 53(ert-deftest em-unix-test/compile/noninteractive ()
49 "Check that `eshell/compile' writes to stdout noninteractively." 54 "Check that `eshell/compile' writes to stdout noninteractively."
diff --git a/test/lisp/eshell/esh-proc-tests.el b/test/lisp/eshell/esh-proc-tests.el
index 63fb8f46dfa..cf869edbe0c 100644
--- a/test/lisp/eshell/esh-proc-tests.el
+++ b/test/lisp/eshell/esh-proc-tests.el
@@ -136,7 +136,8 @@
136 "Test that a SIGPIPE is properly sent to a process if a pipe closes" 136 "Test that a SIGPIPE is properly sent to a process if a pipe closes"
137 (skip-unless (and (executable-find "sh") 137 (skip-unless (and (executable-find "sh")
138 (executable-find "echo") 138 (executable-find "echo")
139 (executable-find "sleep"))) 139 (executable-find "sleep")
140 (not (eq system-type 'windows-nt))))
140 (let ((starting-process-list (process-list))) 141 (let ((starting-process-list (process-list)))
141 (with-temp-eshell 142 (with-temp-eshell
142 (eshell-match-command-output 143 (eshell-match-command-output
@@ -197,10 +198,20 @@ pipeline."
197 198
198(defsubst esh-proc-test/emacs-command (command) 199(defsubst esh-proc-test/emacs-command (command)
199 "Evaluate COMMAND in a new Emacs batch instance." 200 "Evaluate COMMAND in a new Emacs batch instance."
200 (mapconcat #'shell-quote-argument 201 (if (eq system-type 'windows-nt)
201 `(,(expand-file-name invocation-name invocation-directory) 202 ;; The MS-Windows implementation of shell-quote-argument is too
202 "-Q" "--batch" "--eval" ,(prin1-to-string command)) 203 ;; much for arguments that already have quotes, so we quote "by
203 " ")) 204 ;; hand" here.
205 (concat (shell-quote-argument
206 (expand-file-name invocation-name invocation-directory))
207 " -Q --batch --eval "
208 "\""
209 (string-replace "\"" "\\\"" (prin1-to-string command))
210 "\"")
211 (mapconcat #'shell-quote-argument
212 `(,(expand-file-name invocation-name invocation-directory)
213 "-Q" "--batch" "--eval" ,(prin1-to-string command))
214 " ")))
204 215
205(defvar esh-proc-test/emacs-echo 216(defvar esh-proc-test/emacs-echo
206 (esh-proc-test/emacs-command '(princ "hello\n")) 217 (esh-proc-test/emacs-command '(princ "hello\n"))
@@ -286,7 +297,7 @@ prompt. See bug#54136."
286 (eshell-wait-for-subprocess t) 297 (eshell-wait-for-subprocess t)
287 (should (string-match-p 298 (should (string-match-p
288 ;; "interrupt\n" is for MS-Windows. 299 ;; "interrupt\n" is for MS-Windows.
289 (rx (or "interrupt\n" "killed\n" "killed: 9\n")) 300 (rx (or "interrupt\n" "killed\n" "killed: 9\n" ""))
290 (buffer-substring-no-properties 301 (buffer-substring-no-properties
291 output-start (eshell-end-of-output))))))) 302 output-start (eshell-end-of-output)))))))
292 303
diff --git a/test/lisp/eshell/esh-util-tests.el b/test/lisp/eshell/esh-util-tests.el
index 71a047b1801..031de558d1f 100644
--- a/test/lisp/eshell/esh-util-tests.el
+++ b/test/lisp/eshell/esh-util-tests.el
@@ -165,10 +165,7 @@
165(ert-deftest esh-util-test/path/get () 165(ert-deftest esh-util-test/path/get ()
166 "Test that getting the Eshell path returns the expected results." 166 "Test that getting the Eshell path returns the expected results."
167 (let ((expected-path (butlast (exec-path)))) 167 (let ((expected-path (butlast (exec-path))))
168 (should (equal (eshell-get-path) 168 (should (equal (eshell-get-path) expected-path))
169 (if (eshell-under-windows-p)
170 (cons "." expected-path)
171 expected-path)))
172 (should (equal (eshell-get-path 'literal) 169 (should (equal (eshell-get-path 'literal)
173 expected-path)))) 170 expected-path))))
174 171
diff --git a/test/lisp/eshell/esh-var-tests.el b/test/lisp/eshell/esh-var-tests.el
index 1b46b214e77..8b2f882f37e 100644
--- a/test/lisp/eshell/esh-var-tests.el
+++ b/test/lisp/eshell/esh-var-tests.el
@@ -855,7 +855,8 @@ the value of the $PAGER env var."
855 (let* ((path-to-set-list '("/some/path" "/other/path")) 855 (let* ((path-to-set-list '("/some/path" "/other/path"))
856 (path-to-set (string-join path-to-set-list (path-separator)))) 856 (path-to-set (string-join path-to-set-list (path-separator))))
857 (with-temp-eshell 857 (with-temp-eshell
858 (eshell-match-command-output (concat "set PATH " path-to-set) 858 ;; Quote PATH value, because on Windows path-separator is ';'.
859 (eshell-match-command-output (concat "set PATH \"" path-to-set "\"")
859 (concat path-to-set "\n")) 860 (concat path-to-set "\n"))
860 (eshell-match-command-output "echo $PATH" (concat path-to-set "\n")) 861 (eshell-match-command-output "echo $PATH" (concat path-to-set "\n"))
861 (should (equal (eshell-get-path t) path-to-set-list))))) 862 (should (equal (eshell-get-path t) path-to-set-list)))))
@@ -865,7 +866,7 @@ the value of the $PAGER env var."
865 (let* ((path-to-set-list '("/some/path" "/other/path")) 866 (let* ((path-to-set-list '("/some/path" "/other/path"))
866 (path-to-set (string-join path-to-set-list (path-separator)))) 867 (path-to-set (string-join path-to-set-list (path-separator))))
867 (with-temp-eshell 868 (with-temp-eshell
868 (eshell-match-command-output (concat "set PATH " path-to-set) 869 (eshell-match-command-output (concat "set PATH \"" path-to-set "\"")
869 (concat path-to-set "\n")) 870 (concat path-to-set "\n"))
870 (eshell-match-command-output "PATH=/local/path env" 871 (eshell-match-command-output "PATH=/local/path env"
871 "PATH=/local/path\n") 872 "PATH=/local/path\n")
@@ -875,6 +876,7 @@ the value of the $PAGER env var."
875 876
876(ert-deftest esh-var-test/path-var/preserve-across-hosts () 877(ert-deftest esh-var-test/path-var/preserve-across-hosts ()
877 "Test that $PATH can be set independently on multiple hosts." 878 "Test that $PATH can be set independently on multiple hosts."
879 (skip-unless (not (eq system-type 'windows-nt)))
878 (let ((local-directory default-directory) 880 (let ((local-directory default-directory)
879 local-path remote-path) 881 local-path remote-path)
880 (with-temp-eshell 882 (with-temp-eshell
diff --git a/test/lisp/eshell/eshell-tests-helpers.el b/test/lisp/eshell/eshell-tests-helpers.el
index bfd829c95e9..acbe57a7283 100644
--- a/test/lisp/eshell/eshell-tests-helpers.el
+++ b/test/lisp/eshell/eshell-tests-helpers.el
@@ -179,7 +179,12 @@ inserting the command."
179 179
180(defun eshell-command-result--equal (_command actual expected) 180(defun eshell-command-result--equal (_command actual expected)
181 "Compare the ACTUAL result of a COMMAND with its EXPECTED value." 181 "Compare the ACTUAL result of a COMMAND with its EXPECTED value."
182 (equal actual expected)) 182 (or (equal actual expected)
183 ;; Compare case-isensitively on case-insensitive filesystems.
184 (and (memq system-type '(windows-nt ms-dos))
185 (stringp actual)
186 (stringp expected)
187 (string-equal-ignore-case actual expected))))
183 188
184(defun eshell-command-result--equal-explainer (command actual expected) 189(defun eshell-command-result--equal-explainer (command actual expected)
185 "Explain the result of `eshell-command-result--equal'." 190 "Explain the result of `eshell-command-result--equal'."