diff options
| author | Jim Porter | 2024-08-28 18:30:29 -0700 |
|---|---|---|
| committer | Jim Porter | 2024-08-28 18:48:28 -0700 |
| commit | 5c68545a936ab42df90c8498ca77207a5e6aff1f (patch) | |
| tree | 794a3e9116b4c1e5f9cb677e229a1fa9ae8a8d0e /test | |
| parent | 9cd88bd62a6b266f866e56f21c62156d24075dac (diff) | |
| download | emacs-5c68545a936ab42df90c8498ca77207a5e6aff1f.tar.gz emacs-5c68545a936ab42df90c8498ca77207a5e6aff1f.zip | |
Use 'eshell-with-handles' in a few more places
* lisp/eshell/em-alias.el (eshell-write-aliases-list):
* lisp/eshell/em-script.el (eshell-batch-file):
* lisp/eshell/esh-cmd.el (eshell-command-to-value):
* lisp/eshell/eshell.el (eshell-command): Use 'eshell-with-handles'.
* test/lisp/eshell/esh-io-tests.el (eshell-test-file-string): Move to...
* test/lisp/eshell/eshell-tests-helpers.el (eshell-test-file-string):
... here.
* test/lisp/eshell/eshell-tests.el
(eshell-test/eshell-command/output-file):
* test/lisp/eshell/em-script-tests.el
(em-script-test/execute-file/output-file): New tests.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/eshell/em-script-tests.el | 8 | ||||
| -rw-r--r-- | test/lisp/eshell/esh-io-tests.el | 6 | ||||
| -rw-r--r-- | test/lisp/eshell/eshell-tests-helpers.el | 6 | ||||
| -rw-r--r-- | test/lisp/eshell/eshell-tests.el | 6 |
4 files changed, 20 insertions, 6 deletions
diff --git a/test/lisp/eshell/em-script-tests.el b/test/lisp/eshell/em-script-tests.el index 86a78e43026..b9f96fa86db 100644 --- a/test/lisp/eshell/em-script-tests.el +++ b/test/lisp/eshell/em-script-tests.el | |||
| @@ -113,6 +113,14 @@ | |||
| 113 | (eshell-execute-file temp-file '(1 2 3) t)) | 113 | (eshell-execute-file temp-file '(1 2 3) t)) |
| 114 | (should (equal (buffer-string) "6"))))) | 114 | (should (equal (buffer-string) "6"))))) |
| 115 | 115 | ||
| 116 | (ert-deftest em-script-test/execute-file/output-file () | ||
| 117 | "Test `eshell-execute-file' redirecting to a file." | ||
| 118 | (ert-with-temp-file temp-file :text "echo more" | ||
| 119 | (ert-with-temp-file output-file :text "initial" | ||
| 120 | (with-temp-eshell-settings | ||
| 121 | (eshell-execute-file temp-file nil output-file)) | ||
| 122 | (should (equal (eshell-test-file-string output-file) "moreinitial"))))) | ||
| 123 | |||
| 116 | (ert-deftest em-script-test/batch-file () | 124 | (ert-deftest em-script-test/batch-file () |
| 117 | "Test running an Eshell script file as a batch script." | 125 | "Test running an Eshell script file as a batch script." |
| 118 | (ert-with-temp-file temp-file | 126 | (ert-with-temp-file temp-file |
diff --git a/test/lisp/eshell/esh-io-tests.el b/test/lisp/eshell/esh-io-tests.el index b4e8c0b4a9a..6add14c05fa 100644 --- a/test/lisp/eshell/esh-io-tests.el +++ b/test/lisp/eshell/esh-io-tests.el | |||
| @@ -34,12 +34,6 @@ | |||
| 34 | (defvar eshell-test-value-with-fun nil) | 34 | (defvar eshell-test-value-with-fun nil) |
| 35 | (defun eshell-test-value-with-fun ()) | 35 | (defun eshell-test-value-with-fun ()) |
| 36 | 36 | ||
| 37 | (defun eshell-test-file-string (file) | ||
| 38 | "Return the contents of FILE as a string." | ||
| 39 | (with-temp-buffer | ||
| 40 | (insert-file-contents file) | ||
| 41 | (buffer-string))) | ||
| 42 | |||
| 43 | (defun eshell/test-output () | 37 | (defun eshell/test-output () |
| 44 | "Write some test output separately to stdout and stderr." | 38 | "Write some test output separately to stdout and stderr." |
| 45 | (eshell-printn "stdout") | 39 | (eshell-printn "stdout") |
diff --git a/test/lisp/eshell/eshell-tests-helpers.el b/test/lisp/eshell/eshell-tests-helpers.el index bfd829c95e9..def04be0577 100644 --- a/test/lisp/eshell/eshell-tests-helpers.el +++ b/test/lisp/eshell/eshell-tests-helpers.el | |||
| @@ -139,6 +139,12 @@ After inserting, call FUNC. If FUNC is nil, instead call | |||
| 139 | (buffer-substring-no-properties | 139 | (buffer-substring-no-properties |
| 140 | (eshell-beginning-of-output) (eshell-end-of-output))) | 140 | (eshell-beginning-of-output) (eshell-end-of-output))) |
| 141 | 141 | ||
| 142 | (defun eshell-test-file-string (file) | ||
| 143 | "Return the contents of FILE as a string." | ||
| 144 | (with-temp-buffer | ||
| 145 | (insert-file-contents file) | ||
| 146 | (buffer-string))) | ||
| 147 | |||
| 142 | (defun eshell-match-output (regexp) | 148 | (defun eshell-match-output (regexp) |
| 143 | "Test whether the output of the last command matches REGEXP." | 149 | "Test whether the output of the last command matches REGEXP." |
| 144 | (string-match-p regexp (eshell-last-output))) | 150 | (string-match-p regexp (eshell-last-output))) |
diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el index f16c28cd1ae..c84af62fdbd 100644 --- a/test/lisp/eshell/eshell-tests.el +++ b/test/lisp/eshell/eshell-tests.el | |||
| @@ -138,6 +138,12 @@ This test uses a pipeline for the command." | |||
| 138 | (forward-line) | 138 | (forward-line) |
| 139 | (should (looking-at "bye\n")))))) | 139 | (should (looking-at "bye\n")))))) |
| 140 | 140 | ||
| 141 | (ert-deftest eshell-test/eshell-command/output-file () | ||
| 142 | "Test that `eshell-command' can write to a file." | ||
| 143 | (ert-with-temp-file temp-file :text "initial" | ||
| 144 | (eshell-command "echo more" temp-file) | ||
| 145 | (should (equal (eshell-test-file-string temp-file) "moreinitial")))) | ||
| 146 | |||
| 141 | (ert-deftest eshell-test/command-running-p () | 147 | (ert-deftest eshell-test/command-running-p () |
| 142 | "Modeline should show no command running" | 148 | "Modeline should show no command running" |
| 143 | (with-temp-eshell | 149 | (with-temp-eshell |