summaryrefslogtreecommitdiff
path: root/test/lisp/eshell/eshell-tests.el
diff options
context:
space:
mode:
Diffstat (limited to 'test/lisp/eshell/eshell-tests.el')
-rw-r--r--test/lisp/eshell/eshell-tests.el44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el
index 743cc28b9b5..390f75cfbb9 100644
--- a/test/lisp/eshell/eshell-tests.el
+++ b/test/lisp/eshell/eshell-tests.el
@@ -107,6 +107,50 @@
(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"))
+ (ert-with-temp-directory eshell-directory-name
+ (let ((eshell-history-file-name nil))
+ (with-temp-buffer
+ (eshell-command "*echo hi" t)
+ (should (equal (buffer-string) "hi\n"))))))
+
+(ert-deftest eshell-test/eshell-command/pipeline ()
+ "Test that the `eshell-command' function writes to the current buffer.
+This test uses a pipeline for the command."
+ (skip-unless (and (executable-find "echo")
+ (executable-find "cat")))
+ (ert-with-temp-directory eshell-directory-name
+ (let ((eshell-history-file-name nil))
+ (with-temp-buffer
+ (eshell-command "*echo hi | *cat" t)
+ (should (equal (buffer-string) "hi\n"))))))
+
+(ert-deftest eshell-test/eshell-command/background ()
+ "Test that `eshell-command' works for background commands."
+ (skip-unless (executable-find "echo"))
+ (ert-with-temp-directory eshell-directory-name
+ (let ((orig-processes (process-list))
+ (eshell-history-file-name nil))
+ (with-temp-buffer
+ (eshell-command "*echo hi &" t)
+ (eshell-wait-for (lambda () (equal (process-list) orig-processes)))
+ (should (equal (buffer-string) "hi\n"))))))
+
+(ert-deftest eshell-test/eshell-command/background-pipeline ()
+ "Test that `eshell-command' works for background commands.
+This test uses a pipeline for the command."
+ (skip-unless (and (executable-find "echo")
+ (executable-find "cat")))
+ (ert-with-temp-directory eshell-directory-name
+ (let ((orig-processes (copy-tree (process-list)))
+ (eshell-history-file-name nil))
+ (with-temp-buffer
+ (eshell-command "*echo hi | *cat &" t)
+ (eshell-wait-for (lambda () (equal (process-list) orig-processes)))
+ (should (equal (buffer-string) "hi\n"))))))
+
(ert-deftest eshell-test/command-running-p ()
"Modeline should show no command running"
(with-temp-eshell