]> git.eshelyaron.com Git - emacs.git/commitdiff
; Move some Eshell tests to more-topical files
authorJim Porter <jporterbugs@gmail.com>
Thu, 7 Sep 2023 00:00:59 +0000 (17:00 -0700)
committerJim Porter <jporterbugs@gmail.com>
Sun, 10 Sep 2023 17:38:25 +0000 (10:38 -0700)
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.

test/lisp/eshell/esh-cmd-tests.el
test/lisp/eshell/esh-io-tests.el
test/lisp/eshell/eshell-tests.el

index a7208eb3a0b83179ffe2cbd35c9abdaf3d22f87f..3967910a53d0a5560c8ff7d82dcd248b2489dd97 100644 (file)
@@ -137,6 +137,68 @@ bug#59469."
    (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
 
index ce80f3a8f0843c3e1dc4688658086395591d7c22..0201b6ab650925e6598577ed6020d1ef2471331b 100644 (file)
@@ -334,6 +334,17 @@ stdout originally pointed (the terminal)."
    (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
 
index 46c9482ecf49db4b686ad45148efe84c785d083b..777c927c78e1c9dc56e811ef2446b558a3e09c82 100644 (file)
 
 ;;; 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"))