diff options
| author | Sean Whitton | 2022-01-22 18:54:55 -0700 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-01-24 21:45:00 +0100 |
| commit | 42aef82a2b0d7b464a97fb0a50ae00501d7b4708 (patch) | |
| tree | b08fba36f765496465a5d1354ec15c7f3e2bb101 /test | |
| parent | 1693423fd74d882f7e682a65136c1111e253058a (diff) | |
| download | emacs-42aef82a2b0d7b464a97fb0a50ae00501d7b4708.tar.gz emacs-42aef82a2b0d7b464a97fb0a50ae00501d7b4708.zip | |
Rework eshell-match-result for testing asynchronous commands
When using eshell-match-result via eshell-command-result-p to examine
the output of asynchronous Eshell commands, a newly emitted prompt is
included in the text against which the regexp is matched. This makes
it awkward to match against the whole output; for example, to check
whether it is empty. Rework the function to exclude the prompt.
* test/lisp/eshell/eshell-tests-helpers.el (eshell-match-result):
Exclude any newly emitted prompt from the text against which the
regexp is matched. Additionally, the function no longer moves point.
* test/lisp/eshell/eshell-tests.el (eshell-test/flush-output): Update
and simplify test given how eshell-match-result no longer moves point.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/eshell/eshell-tests-helpers.el | 9 | ||||
| -rw-r--r-- | test/lisp/eshell/eshell-tests.el | 5 |
2 files changed, 7 insertions, 7 deletions
diff --git a/test/lisp/eshell/eshell-tests-helpers.el b/test/lisp/eshell/eshell-tests-helpers.el index 2afa63ae51a..a150adb1442 100644 --- a/test/lisp/eshell/eshell-tests-helpers.el +++ b/test/lisp/eshell/eshell-tests-helpers.el | |||
| @@ -66,10 +66,11 @@ raise an error." | |||
| 66 | (funcall (or func 'eshell-send-input))) | 66 | (funcall (or func 'eshell-send-input))) |
| 67 | 67 | ||
| 68 | (defun eshell-match-result (regexp) | 68 | (defun eshell-match-result (regexp) |
| 69 | "Check that text after `eshell-last-input-end' matches REGEXP." | 69 | "Check that output of last command matches REGEXP." |
| 70 | (goto-char eshell-last-input-end) | 70 | (should |
| 71 | (should (string-match-p regexp (buffer-substring-no-properties | 71 | (string-match-p |
| 72 | (point) (point-max))))) | 72 | regexp (buffer-substring-no-properties |
| 73 | (eshell-beginning-of-output) (eshell-end-of-output))))) | ||
| 73 | 74 | ||
| 74 | (defun eshell-command-result-p (text regexp &optional func) | 75 | (defun eshell-command-result-p (text regexp &optional func) |
| 75 | "Insert a command at the end of the buffer." | 76 | "Insert a command at the end of the buffer." |
diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el index 6aeefdfde21..542815df809 100644 --- a/test/lisp/eshell/eshell-tests.el +++ b/test/lisp/eshell/eshell-tests.el | |||
| @@ -232,9 +232,8 @@ chars" | |||
| 232 | (with-temp-eshell | 232 | (with-temp-eshell |
| 233 | (eshell-insert-command "echo alpha") | 233 | (eshell-insert-command "echo alpha") |
| 234 | (eshell-kill-output) | 234 | (eshell-kill-output) |
| 235 | (eshell-match-result (regexp-quote "*** output flushed ***\n")) | 235 | (eshell-match-result |
| 236 | (should (forward-line)) | 236 | (concat "^" (regexp-quote "*** output flushed ***\n") "$")))) |
| 237 | (should (= (point) eshell-last-output-start)))) | ||
| 238 | 237 | ||
| 239 | (ert-deftest eshell-test/run-old-command () | 238 | (ert-deftest eshell-test/run-old-command () |
| 240 | "Re-run an old command" | 239 | "Re-run an old command" |