mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
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.
This commit is contained in:
parent
8253228d55
commit
f869f1ffc2
7 changed files with 37 additions and 15 deletions
|
|
@ -417,7 +417,8 @@ as the $PATH was actually specified."
|
|||
(butlast (exec-path))))))
|
||||
(when (and (not literal-p)
|
||||
(not remote)
|
||||
(eshell-under-windows-p))
|
||||
(eshell-under-windows-p)
|
||||
(not (member "." path)))
|
||||
(push "." path))
|
||||
(if (and remote (not literal-p))
|
||||
(mapcar (lambda (x) (concat remote x)) path)
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@
|
|||
|
||||
(ert-deftest em-script-test/batch-file ()
|
||||
"Test running an Eshell script file as a batch script."
|
||||
(skip-unless (not (memq system-type '(windows-nt ms-dos))))
|
||||
(ert-with-temp-file temp-file
|
||||
:text (format
|
||||
"#!/usr/bin/env -S %s --batch -f eshell-batch-file\necho hi"
|
||||
|
|
|
|||
|
|
@ -43,7 +43,12 @@
|
|||
"#<buffer \\*compilation\\*>")
|
||||
(with-current-buffer "*compilation*"
|
||||
(forward-line 3)
|
||||
(should (looking-at "echo hello")))))
|
||||
(should (looking-at
|
||||
;; MS-Windows/DOS quote by unconditionally enclosing in
|
||||
;; double quotes.
|
||||
(if (memq system-type '(windows-nt ms-dos))
|
||||
"\"echo\" \"hello\""
|
||||
"echo hello"))))))
|
||||
|
||||
(ert-deftest em-unix-test/compile/noninteractive ()
|
||||
"Check that `eshell/compile' writes to stdout noninteractively."
|
||||
|
|
|
|||
|
|
@ -136,7 +136,8 @@
|
|||
"Test that a SIGPIPE is properly sent to a process if a pipe closes"
|
||||
(skip-unless (and (executable-find "sh")
|
||||
(executable-find "echo")
|
||||
(executable-find "sleep")))
|
||||
(executable-find "sleep")
|
||||
(not (eq system-type 'windows-nt))))
|
||||
(let ((starting-process-list (process-list)))
|
||||
(with-temp-eshell
|
||||
(eshell-match-command-output
|
||||
|
|
@ -197,10 +198,20 @@ pipeline."
|
|||
|
||||
(defsubst esh-proc-test/emacs-command (command)
|
||||
"Evaluate COMMAND in a new Emacs batch instance."
|
||||
(mapconcat #'shell-quote-argument
|
||||
`(,(expand-file-name invocation-name invocation-directory)
|
||||
"-Q" "--batch" "--eval" ,(prin1-to-string command))
|
||||
" "))
|
||||
(if (eq system-type 'windows-nt)
|
||||
;; The MS-Windows implementation of shell-quote-argument is too
|
||||
;; much for arguments that already have quotes, so we quote "by
|
||||
;; hand" here.
|
||||
(concat (shell-quote-argument
|
||||
(expand-file-name invocation-name invocation-directory))
|
||||
" -Q --batch --eval "
|
||||
"\""
|
||||
(string-replace "\"" "\\\"" (prin1-to-string command))
|
||||
"\"")
|
||||
(mapconcat #'shell-quote-argument
|
||||
`(,(expand-file-name invocation-name invocation-directory)
|
||||
"-Q" "--batch" "--eval" ,(prin1-to-string command))
|
||||
" ")))
|
||||
|
||||
(defvar esh-proc-test/emacs-echo
|
||||
(esh-proc-test/emacs-command '(princ "hello\n"))
|
||||
|
|
@ -286,7 +297,7 @@ prompt. See bug#54136."
|
|||
(eshell-wait-for-subprocess t)
|
||||
(should (string-match-p
|
||||
;; "interrupt\n" is for MS-Windows.
|
||||
(rx (or "interrupt\n" "killed\n" "killed: 9\n"))
|
||||
(rx (or "interrupt\n" "killed\n" "killed: 9\n" ""))
|
||||
(buffer-substring-no-properties
|
||||
output-start (eshell-end-of-output)))))))
|
||||
|
||||
|
|
|
|||
|
|
@ -165,10 +165,7 @@
|
|||
(ert-deftest esh-util-test/path/get ()
|
||||
"Test that getting the Eshell path returns the expected results."
|
||||
(let ((expected-path (butlast (exec-path))))
|
||||
(should (equal (eshell-get-path)
|
||||
(if (eshell-under-windows-p)
|
||||
(cons "." expected-path)
|
||||
expected-path)))
|
||||
(should (equal (eshell-get-path) expected-path))
|
||||
(should (equal (eshell-get-path 'literal)
|
||||
expected-path))))
|
||||
|
||||
|
|
|
|||
|
|
@ -855,7 +855,8 @@ the value of the $PAGER env var."
|
|||
(let* ((path-to-set-list '("/some/path" "/other/path"))
|
||||
(path-to-set (string-join path-to-set-list (path-separator))))
|
||||
(with-temp-eshell
|
||||
(eshell-match-command-output (concat "set PATH " path-to-set)
|
||||
;; Quote PATH value, because on Windows path-separator is ';'.
|
||||
(eshell-match-command-output (concat "set PATH \"" path-to-set "\"")
|
||||
(concat path-to-set "\n"))
|
||||
(eshell-match-command-output "echo $PATH" (concat path-to-set "\n"))
|
||||
(should (equal (eshell-get-path t) path-to-set-list)))))
|
||||
|
|
@ -865,7 +866,7 @@ the value of the $PAGER env var."
|
|||
(let* ((path-to-set-list '("/some/path" "/other/path"))
|
||||
(path-to-set (string-join path-to-set-list (path-separator))))
|
||||
(with-temp-eshell
|
||||
(eshell-match-command-output (concat "set PATH " path-to-set)
|
||||
(eshell-match-command-output (concat "set PATH \"" path-to-set "\"")
|
||||
(concat path-to-set "\n"))
|
||||
(eshell-match-command-output "PATH=/local/path env"
|
||||
"PATH=/local/path\n")
|
||||
|
|
@ -875,6 +876,7 @@ the value of the $PAGER env var."
|
|||
|
||||
(ert-deftest esh-var-test/path-var/preserve-across-hosts ()
|
||||
"Test that $PATH can be set independently on multiple hosts."
|
||||
(skip-unless (not (eq system-type 'windows-nt)))
|
||||
(let ((local-directory default-directory)
|
||||
local-path remote-path)
|
||||
(with-temp-eshell
|
||||
|
|
|
|||
|
|
@ -179,7 +179,12 @@ inserting the command."
|
|||
|
||||
(defun eshell-command-result--equal (_command actual expected)
|
||||
"Compare the ACTUAL result of a COMMAND with its EXPECTED value."
|
||||
(equal actual expected))
|
||||
(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))))
|
||||
|
||||
(defun eshell-command-result--equal-explainer (command actual expected)
|
||||
"Explain the result of `eshell-command-result--equal'."
|
||||
|
|
|
|||
Loading…
Reference in a new issue