; Adjust Eshell regression tests to avoid SIGPIPE

In batch mode, SIGPIPEs can cause Emacs to abort (bug#66186).

* lisp/eshell/esh-io.el (eshell-output-object-to-target): Update
comment.

* test/lisp/eshell/esh-proc-tests.el
(esh-proc-test/pipeline-connection-type/middle)
(esh-proc-test/pipeline-connection-type/last): Use '(ignore)', since
that causes no output when called with no arguments, thus avoiding a
risky 'process-send-string'.
This commit is contained in:
Jim Porter 2023-09-24 22:30:34 -07:00
parent 6b2219cd27
commit 862e5effbf
2 changed files with 12 additions and 15 deletions

View file

@ -648,8 +648,11 @@ Returns what was actually sent, or nil if nothing was sent.")
(process-send-string target object)
(error
;; If `process-send-string' raises an error and the process has
;; finished, treat it as a broken pipe. Otherwise, just
;; re-throw the signal.
;; finished, treat it as a broken pipe. Otherwise, just re-raise
;; the signal. NOTE: When running Emacs in batch mode
;; (e.g. during regression tests), Emacs can abort due to SIGPIPE
;; here. Maybe `process-send-string' should handle SIGPIPE even
;; in batch mode (bug#66186).
(if (process-live-p target)
(signal (car err) (cdr err))
(signal 'eshell-pipe-broken (list target)))))

View file

@ -174,23 +174,17 @@
pipeline."
(skip-unless (and (executable-find "sh")
(executable-find "cat")))
;; An `eshell-pipe-broken' signal might occur internally; let Eshell
;; handle it!
(let ((debug-on-error nil))
(eshell-command-result-equal
(concat "echo hi | " esh-proc-test--detect-pty-cmd " | cat")
nil)))
(eshell-command-result-equal
(concat "(ignore) | " esh-proc-test--detect-pty-cmd " | cat")
nil))
(ert-deftest esh-proc-test/pipeline-connection-type/last ()
"Test that only output streams are PTYs when a command ends a pipeline."
(skip-unless (executable-find "sh"))
;; An `eshell-pipe-broken' signal might occur internally; let Eshell
;; handle it!
(let ((debug-on-error nil))
(eshell-command-result-equal
(concat "echo hi | " esh-proc-test--detect-pty-cmd)
(unless (eq system-type 'windows-nt)
"stdout\nstderr\n"))))
(eshell-command-result-equal
(concat "(ignore) | " esh-proc-test--detect-pty-cmd)
(unless (eq system-type 'windows-nt)
"stdout\nstderr\n")))
;; Synchronous processes