aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Porter2023-09-06 17:00:59 -0700
committerJim Porter2023-09-10 10:38:25 -0700
commite554ee0b5f77a3b6fe70e7a4d3d60bf319879aca (patch)
treebf30586f0dfacbc5f17adff991bcae084236f10e
parentf9667836c4b193d02a375350f4a16e0fe8d8b4f2 (diff)
downloademacs-e554ee0b5f77a3b6fe70e7a4d3d60bf319879aca.tar.gz
emacs-e554ee0b5f77a3b6fe70e7a4d3d60bf319879aca.zip
; Move some Eshell tests to more-topical files
eshell-tests.el should mainly be for code in eshell.el. * test/lisp/eshell/eshell-tests.el (eshell-test/pipe-headproc) (eshell-test/pipe-tailproc, eshell-test/pipe-subcommand) (eshell-test/pipe-subcommand-with-pipe) (eshell-test/subcommand-reset-in-pipeline) (eshell-test/lisp-reset-in-pipeline): Move to... * test/lisp/eshell/esh-cmd-tests.el (esh-cmd-test/pipeline-wait/head-proc) (esh-cmd-test/pipeline-wait/tail-proc) (esh-cmd-test/pipeline-wait/subcommand) (esh-cmd-test/pipeline-wait/subcommand-with-pipe) (esh-cmd-test/reset-in-pipeline/subcommand) (esh-cmd-test/reset-in-pipeline/lisp): ... here. * test/lisp/eshell/eshell-tests.el (eshell-test/pipe-headproc-stdin): Move to... * test/lisp/eshell/esh-io-tests.el (esh-io-test/pipeline/stdin-to-head): ... here.
-rw-r--r--test/lisp/eshell/esh-cmd-tests.el62
-rw-r--r--test/lisp/eshell/esh-io-tests.el11
-rw-r--r--test/lisp/eshell/eshell-tests.el69
3 files changed, 73 insertions, 69 deletions
diff --git a/test/lisp/eshell/esh-cmd-tests.el b/test/lisp/eshell/esh-cmd-tests.el
index a7208eb3a0b..3967910a53d 100644
--- a/test/lisp/eshell/esh-cmd-tests.el
+++ b/test/lisp/eshell/esh-cmd-tests.el
@@ -138,6 +138,68 @@ bug#59469."
138 "hi\n"))) 138 "hi\n")))
139 139
140 140
141;; Pipelines
142
143(ert-deftest esh-cmd-test/pipeline-wait/head-proc ()
144 "Check that piping a non-process to a process command waits for the process."
145 (skip-unless (executable-find "cat"))
146 (with-temp-eshell
147 (eshell-match-command-output "echo hi | *cat"
148 "hi")))
149
150(ert-deftest esh-cmd-test/pipeline-wait/tail-proc ()
151 "Check that piping a process to a non-process command waits for the process."
152 (skip-unless (executable-find "echo"))
153 (with-temp-eshell
154 (eshell-match-command-output "*echo hi | echo bye"
155 "bye\nhi\n")))
156
157(ert-deftest esh-cmd-test/pipeline-wait/subcommand ()
158 "Check that piping with an asynchronous subcommand waits for the subcommand."
159 (skip-unless (and (executable-find "echo")
160 (executable-find "cat")))
161 (with-temp-eshell
162 (eshell-match-command-output "echo ${*echo hi} | *cat"
163 "hi")))
164
165(ert-deftest esh-cmd-test/pipeline-wait/subcommand-with-pipe ()
166 "Check that piping with an asynchronous subcommand with its own pipe works.
167This should also wait for the subcommand."
168 (skip-unless (and (executable-find "echo")
169 (executable-find "cat")))
170 (with-temp-eshell
171 (eshell-match-command-output "echo ${*echo hi | *cat} | *cat"
172 "hi")))
173
174(ert-deftest esh-cmd-test/reset-in-pipeline/subcommand ()
175 "Check that subcommands reset `eshell-in-pipeline-p'."
176 (skip-unless (executable-find "cat"))
177 (dolist (template '("echo {%s} | *cat"
178 "echo ${%s} | *cat"
179 "*cat $<%s> | *cat"))
180 (eshell-command-result-equal
181 (format template "echo $eshell-in-pipeline-p")
182 nil)
183 (eshell-command-result-equal
184 (format template "echo | echo $eshell-in-pipeline-p")
185 "last")
186 (eshell-command-result-equal
187 (format template "echo $eshell-in-pipeline-p | echo")
188 "first")
189 (eshell-command-result-equal
190 (format template "echo | echo $eshell-in-pipeline-p | echo")
191 "t")))
192
193(ert-deftest esh-cmd-test/reset-in-pipeline/lisp ()
194 "Check that interpolated Lisp forms reset `eshell-in-pipeline-p'."
195 (skip-unless (executable-find "cat"))
196 (dolist (template '("echo (%s) | *cat"
197 "echo $(%s) | *cat"))
198 (eshell-command-result-equal
199 (format template "format \"%s\" eshell-in-pipeline-p")
200 "nil")))
201
202
141;; Control flow statements 203;; Control flow statements
142 204
143(ert-deftest esh-cmd-test/for-loop () 205(ert-deftest esh-cmd-test/for-loop ()
diff --git a/test/lisp/eshell/esh-io-tests.el b/test/lisp/eshell/esh-io-tests.el
index ce80f3a8f08..0201b6ab650 100644
--- a/test/lisp/eshell/esh-io-tests.el
+++ b/test/lisp/eshell/esh-io-tests.el
@@ -334,6 +334,17 @@ stdout originally pointed (the terminal)."
334 (eshell-match-command-output "{echo foo; echo bar} | rev" 334 (eshell-match-command-output "{echo foo; echo bar} | rev"
335 "\\`raboof\n?"))) 335 "\\`raboof\n?")))
336 336
337(ert-deftest esh-io-test/pipeline/stdin-to-head ()
338 "Check that standard input is sent to the head process in a pipeline."
339 (skip-unless (and (executable-find "tr")
340 (executable-find "rev")))
341 (with-temp-eshell
342 (eshell-insert-command "tr a-z A-Z | rev")
343 (eshell-insert-command "hello")
344 (eshell-send-eof-to-process)
345 (eshell-wait-for-subprocess)
346 (should (eshell-match-output "OLLEH\n"))))
347
337 348
338;; Virtual targets 349;; Virtual targets
339 350
diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el
index 46c9482ecf4..777c927c78e 100644
--- a/test/lisp/eshell/eshell-tests.el
+++ b/test/lisp/eshell/eshell-tests.el
@@ -38,75 +38,6 @@
38 38
39;;; Tests: 39;;; Tests:
40 40
41(ert-deftest eshell-test/pipe-headproc ()
42 "Check that piping a non-process to a process command waits for the process"
43 (skip-unless (executable-find "cat"))
44 (with-temp-eshell
45 (eshell-match-command-output "echo hi | *cat"
46 "hi")))
47
48(ert-deftest eshell-test/pipe-tailproc ()
49 "Check that piping a process to a non-process command waits for the process"
50 (skip-unless (executable-find "echo"))
51 (with-temp-eshell
52 (eshell-match-command-output "*echo hi | echo bye"
53 "bye\nhi\n")))
54
55(ert-deftest eshell-test/pipe-headproc-stdin ()
56 "Check that standard input is sent to the head process in a pipeline"
57 (skip-unless (and (executable-find "tr")
58 (executable-find "rev")))
59 (with-temp-eshell
60 (eshell-insert-command "tr a-z A-Z | rev")
61 (eshell-insert-command "hello")
62 (eshell-send-eof-to-process)
63 (eshell-wait-for-subprocess)
64 (should (eshell-match-output "OLLEH\n"))))
65
66(ert-deftest eshell-test/pipe-subcommand ()
67 "Check that piping with an asynchronous subcommand works"
68 (skip-unless (and (executable-find "echo")
69 (executable-find "cat")))
70 (with-temp-eshell
71 (eshell-match-command-output "echo ${*echo hi} | *cat"
72 "hi")))
73
74(ert-deftest eshell-test/pipe-subcommand-with-pipe ()
75 "Check that piping with an asynchronous subcommand with its own pipe works"
76 (skip-unless (and (executable-find "echo")
77 (executable-find "cat")))
78 (with-temp-eshell
79 (eshell-match-command-output "echo ${*echo hi | *cat} | *cat"
80 "hi")))
81
82(ert-deftest eshell-test/subcommand-reset-in-pipeline ()
83 "Check that subcommands reset `eshell-in-pipeline-p'."
84 (skip-unless (executable-find "cat"))
85 (dolist (template '("echo {%s} | *cat"
86 "echo ${%s} | *cat"
87 "*cat $<%s> | *cat"))
88 (eshell-command-result-equal
89 (format template "echo $eshell-in-pipeline-p")
90 nil)
91 (eshell-command-result-equal
92 (format template "echo | echo $eshell-in-pipeline-p")
93 "last")
94 (eshell-command-result-equal
95 (format template "echo $eshell-in-pipeline-p | echo")
96 "first")
97 (eshell-command-result-equal
98 (format template "echo | echo $eshell-in-pipeline-p | echo")
99 "t")))
100
101(ert-deftest eshell-test/lisp-reset-in-pipeline ()
102 "Check that interpolated Lisp forms reset `eshell-in-pipeline-p'."
103 (skip-unless (executable-find "cat"))
104 (dolist (template '("echo (%s) | *cat"
105 "echo $(%s) | *cat"))
106 (eshell-command-result-equal
107 (format template "format \"%s\" eshell-in-pipeline-p")
108 "nil")))
109
110(ert-deftest eshell-test/eshell-command/simple () 41(ert-deftest eshell-test/eshell-command/simple ()
111 "Test that the `eshell-command' function writes to the current buffer." 42 "Test that the `eshell-command' function writes to the current buffer."
112 (skip-unless (executable-find "echo")) 43 (skip-unless (executable-find "echo"))