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.
(eshell-match-command-output "[ foo = bar ] || echo hi"
"hi\n")))
+\f
+;; Pipelines
+
+(ert-deftest esh-cmd-test/pipeline-wait/head-proc ()
+ "Check that piping a non-process to a process command waits for the process."
+ (skip-unless (executable-find "cat"))
+ (with-temp-eshell
+ (eshell-match-command-output "echo hi | *cat"
+ "hi")))
+
+(ert-deftest esh-cmd-test/pipeline-wait/tail-proc ()
+ "Check that piping a process to a non-process command waits for the process."
+ (skip-unless (executable-find "echo"))
+ (with-temp-eshell
+ (eshell-match-command-output "*echo hi | echo bye"
+ "bye\nhi\n")))
+
+(ert-deftest esh-cmd-test/pipeline-wait/subcommand ()
+ "Check that piping with an asynchronous subcommand waits for the subcommand."
+ (skip-unless (and (executable-find "echo")
+ (executable-find "cat")))
+ (with-temp-eshell
+ (eshell-match-command-output "echo ${*echo hi} | *cat"
+ "hi")))
+
+(ert-deftest esh-cmd-test/pipeline-wait/subcommand-with-pipe ()
+ "Check that piping with an asynchronous subcommand with its own pipe works.
+This should also wait for the subcommand."
+ (skip-unless (and (executable-find "echo")
+ (executable-find "cat")))
+ (with-temp-eshell
+ (eshell-match-command-output "echo ${*echo hi | *cat} | *cat"
+ "hi")))
+
+(ert-deftest esh-cmd-test/reset-in-pipeline/subcommand ()
+ "Check that subcommands reset `eshell-in-pipeline-p'."
+ (skip-unless (executable-find "cat"))
+ (dolist (template '("echo {%s} | *cat"
+ "echo ${%s} | *cat"
+ "*cat $<%s> | *cat"))
+ (eshell-command-result-equal
+ (format template "echo $eshell-in-pipeline-p")
+ nil)
+ (eshell-command-result-equal
+ (format template "echo | echo $eshell-in-pipeline-p")
+ "last")
+ (eshell-command-result-equal
+ (format template "echo $eshell-in-pipeline-p | echo")
+ "first")
+ (eshell-command-result-equal
+ (format template "echo | echo $eshell-in-pipeline-p | echo")
+ "t")))
+
+(ert-deftest esh-cmd-test/reset-in-pipeline/lisp ()
+ "Check that interpolated Lisp forms reset `eshell-in-pipeline-p'."
+ (skip-unless (executable-find "cat"))
+ (dolist (template '("echo (%s) | *cat"
+ "echo $(%s) | *cat"))
+ (eshell-command-result-equal
+ (format template "format \"%s\" eshell-in-pipeline-p")
+ "nil")))
+
\f
;; Control flow statements
(eshell-match-command-output "{echo foo; echo bar} | rev"
"\\`raboof\n?")))
+(ert-deftest esh-io-test/pipeline/stdin-to-head ()
+ "Check that standard input is sent to the head process in a pipeline."
+ (skip-unless (and (executable-find "tr")
+ (executable-find "rev")))
+ (with-temp-eshell
+ (eshell-insert-command "tr a-z A-Z | rev")
+ (eshell-insert-command "hello")
+ (eshell-send-eof-to-process)
+ (eshell-wait-for-subprocess)
+ (should (eshell-match-output "OLLEH\n"))))
+
\f
;; Virtual targets
;;; Tests:
-(ert-deftest eshell-test/pipe-headproc ()
- "Check that piping a non-process to a process command waits for the process"
- (skip-unless (executable-find "cat"))
- (with-temp-eshell
- (eshell-match-command-output "echo hi | *cat"
- "hi")))
-
-(ert-deftest eshell-test/pipe-tailproc ()
- "Check that piping a process to a non-process command waits for the process"
- (skip-unless (executable-find "echo"))
- (with-temp-eshell
- (eshell-match-command-output "*echo hi | echo bye"
- "bye\nhi\n")))
-
-(ert-deftest eshell-test/pipe-headproc-stdin ()
- "Check that standard input is sent to the head process in a pipeline"
- (skip-unless (and (executable-find "tr")
- (executable-find "rev")))
- (with-temp-eshell
- (eshell-insert-command "tr a-z A-Z | rev")
- (eshell-insert-command "hello")
- (eshell-send-eof-to-process)
- (eshell-wait-for-subprocess)
- (should (eshell-match-output "OLLEH\n"))))
-
-(ert-deftest eshell-test/pipe-subcommand ()
- "Check that piping with an asynchronous subcommand works"
- (skip-unless (and (executable-find "echo")
- (executable-find "cat")))
- (with-temp-eshell
- (eshell-match-command-output "echo ${*echo hi} | *cat"
- "hi")))
-
-(ert-deftest eshell-test/pipe-subcommand-with-pipe ()
- "Check that piping with an asynchronous subcommand with its own pipe works"
- (skip-unless (and (executable-find "echo")
- (executable-find "cat")))
- (with-temp-eshell
- (eshell-match-command-output "echo ${*echo hi | *cat} | *cat"
- "hi")))
-
-(ert-deftest eshell-test/subcommand-reset-in-pipeline ()
- "Check that subcommands reset `eshell-in-pipeline-p'."
- (skip-unless (executable-find "cat"))
- (dolist (template '("echo {%s} | *cat"
- "echo ${%s} | *cat"
- "*cat $<%s> | *cat"))
- (eshell-command-result-equal
- (format template "echo $eshell-in-pipeline-p")
- nil)
- (eshell-command-result-equal
- (format template "echo | echo $eshell-in-pipeline-p")
- "last")
- (eshell-command-result-equal
- (format template "echo $eshell-in-pipeline-p | echo")
- "first")
- (eshell-command-result-equal
- (format template "echo | echo $eshell-in-pipeline-p | echo")
- "t")))
-
-(ert-deftest eshell-test/lisp-reset-in-pipeline ()
- "Check that interpolated Lisp forms reset `eshell-in-pipeline-p'."
- (skip-unless (executable-find "cat"))
- (dolist (template '("echo (%s) | *cat"
- "echo $(%s) | *cat"))
- (eshell-command-result-equal
- (format template "format \"%s\" eshell-in-pipeline-p")
- "nil")))
-
(ert-deftest eshell-test/eshell-command/simple ()
"Test that the `eshell-command' function writes to the current buffer."
(skip-unless (executable-find "echo"))