aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp/eshell
diff options
context:
space:
mode:
authorJim Porter2022-07-17 20:25:00 -0700
committerJim Porter2022-08-05 17:58:54 -0700
commitd7b89ea4077d4fe677ba0577245328819ee79cdc (patch)
treed4e499042bdf2f301be7f2d7ec05f0d1bfd8d44b /test/lisp/eshell
parentb70369c557efed3dcd86dc64a2e73e3480dea6af (diff)
downloademacs-d7b89ea4077d4fe677ba0577245328819ee79cdc.tar.gz
emacs-d7b89ea4077d4fe677ba0577245328819ee79cdc.zip
Allow creating processes where only one of stdin or stdout is a PTY
* src/lisp.h (emacs_spawn): * src/callproc.c (emacs_spawn): Add PTY_IN and PTY_OUT arguments to specify which streams should be set up as a PTY. (call_process): Adjust call to 'emacs_spawn'. * src/process.h (Lisp_Process): Replace 'pty_flag' with 'pty_in' and 'pty_out'. * src/process.c (is_pty_from_symbol): New function. (make-process): Allow :connection-type to be a cons cell, and allow using a stderr process with a PTY for stdin/stdout. (create_process): Handle creating a process where only one of stdin or stdout is a PTY. * lisp/eshell/esh-proc.el (eshell-needs-pipe, eshell-needs-pipe-p): Remove. (eshell-gather-process-output): Use 'make-process' and set ':connection-type' as needed by the value of 'eshell-in-pipeline-p'. * lisp/net/tramp.el (tramp-handle-make-process): * lisp/net/tramp-adb.el (tramp-adb-handle-make-process): * lisp/net/tramp-sh.el (tramp-sh-handle-make-process): Don't signal an error when ':connection-type' is a cons cell. * test/src/process-tests.el (process-test-sentinel-wait-function-working-p): Allow passing PROC in, and rework into... (process-test-wait-for-sentinel): ... this. (process-test-sentinel-accept-process-output) (process-test-sentinel-sit-for, process-test-quoted-batfile) (process-test-stderr-filter): Use 'process-test-wait-for-sentinel'. (make/process/test-connection-type): New function. (make-process/connection-type/pty, make-process/connection-type/pty-2) (make-process/connection-type/pipe) (make-process/connection-type/pipe-2) (make-process/connection-type/in-pty) (make-process/connection-type/out-pty) (make-process/connection-type/pty-with-stderr-buffer) (make-process/connection-type/out-pty-with-stderr-buffer): New tests. * test/lisp/eshell/esh-proc-tests.el (esh-proc-test--detect-pty-cmd): New variable. (esh-proc-test/pipeline-connection-type/no-pipeline) (esh-proc-test/pipeline-connection-type/first) (esh-proc-test/pipeline-connection-type/middle) (esh-proc-test/pipeline-connection-type/last): New tests. * doc/lispref/processes.texi (Asynchronous Processes): Document new ':connection-type' behavior. (Output from Processes): Remove caveat about ':stderr' forcing 'make-process' to use pipes. * etc/NEWS: Announce this change (bug#56025).
Diffstat (limited to 'test/lisp/eshell')
-rw-r--r--test/lisp/eshell/esh-proc-tests.el43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/lisp/eshell/esh-proc-tests.el b/test/lisp/eshell/esh-proc-tests.el
index 7f461d1813c..734bb91a6a5 100644
--- a/test/lisp/eshell/esh-proc-tests.el
+++ b/test/lisp/eshell/esh-proc-tests.el
@@ -28,6 +28,15 @@
28 (file-name-directory (or load-file-name 28 (file-name-directory (or load-file-name
29 default-directory)))) 29 default-directory))))
30 30
31(defvar esh-proc-test--detect-pty-cmd
32 (concat "sh -c '"
33 "if [ -t 0 ]; then echo stdin; fi; "
34 "if [ -t 1 ]; then echo stdout; fi; "
35 "if [ -t 2 ]; then echo stderr; fi"
36 "'"))
37
38;;; Tests:
39
31(ert-deftest esh-proc-test/sigpipe-exits-process () 40(ert-deftest esh-proc-test/sigpipe-exits-process ()
32 "Test that a SIGPIPE is properly sent to a process if a pipe closes" 41 "Test that a SIGPIPE is properly sent to a process if a pipe closes"
33 (skip-unless (and (executable-find "sh") 42 (skip-unless (and (executable-find "sh")
@@ -44,6 +53,40 @@
44 (eshell-wait-for-subprocess t) 53 (eshell-wait-for-subprocess t)
45 (should (eq (process-list) nil)))) 54 (should (eq (process-list) nil))))
46 55
56(ert-deftest esh-proc-test/pipeline-connection-type/no-pipeline ()
57 "Test that all streams are PTYs when a command is not in a pipeline."
58 (skip-unless (executable-find "sh"))
59 (should (equal (eshell-test-command-result esh-proc-test--detect-pty-cmd)
60 ;; PTYs aren't supported on MS-Windows.
61 (unless (eq system-type 'windows-nt)
62 "stdin\nstdout\nstderr\n"))))
63
64(ert-deftest esh-proc-test/pipeline-connection-type/first ()
65 "Test that only stdin is a PTY when a command starts a pipeline."
66 (skip-unless (and (executable-find "sh")
67 (executable-find "cat")))
68 (should (equal (eshell-test-command-result
69 (concat esh-proc-test--detect-pty-cmd " | cat"))
70 (unless (eq system-type 'windows-nt)
71 "stdin\n"))))
72
73(ert-deftest esh-proc-test/pipeline-connection-type/middle ()
74 "Test that all streams are pipes when a command is in the middle of a
75pipeline."
76 (skip-unless (and (executable-find "sh")
77 (executable-find "cat")))
78 (should (equal (eshell-test-command-result
79 (concat "echo | " esh-proc-test--detect-pty-cmd " | cat"))
80 nil)))
81
82(ert-deftest esh-proc-test/pipeline-connection-type/last ()
83 "Test that only output streams are PTYs when a command ends a pipeline."
84 (skip-unless (executable-find "sh"))
85 (should (equal (eshell-test-command-result
86 (concat "echo | " esh-proc-test--detect-pty-cmd))
87 (unless (eq system-type 'windows-nt)
88 "stdout\nstderr\n"))))
89
47(ert-deftest esh-proc-test/kill-pipeline () 90(ert-deftest esh-proc-test/kill-pipeline ()
48 "Test that killing a pipeline of processes only emits a single 91 "Test that killing a pipeline of processes only emits a single
49prompt. See bug#54136." 92prompt. See bug#54136."