From aeb070716c41e3ee3012ae75d4554d05a203ffe4 Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Sat, 24 Sep 2022 18:13:03 -0700 Subject: [PATCH 1/5] ; Allow ignoring errors when calling 'eshell-match-command-output' * test/lisp/eshell/eshell-tests-helpers.el (eshell-match-command-output): New argument IGNORE-ERRORS. * test/lisp/eshell/esh-var-tests.el (esh-var-test/last-status-var-lisp-command) (esh-var-test/last-status-var-lisp-form) (esh-var-test/last-status-var-lisp-form-2): Ignore errors when calling 'eshell-match-command-output'. --- test/lisp/eshell/esh-var-tests.el | 15 ++++++--------- test/lisp/eshell/eshell-tests-helpers.el | 13 ++++++++++--- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/test/lisp/eshell/esh-var-tests.el b/test/lisp/eshell/esh-var-tests.el index cb5b1766bb..ad695e45d7 100644 --- a/test/lisp/eshell/esh-var-tests.el +++ b/test/lisp/eshell/esh-var-tests.el @@ -472,9 +472,8 @@ esh-var-test/last-status-var-lisp-command "t\n0\n") (eshell-match-command-output "zerop 1; echo $?" "0\n") - (let ((debug-on-error nil)) - (eshell-match-command-output "zerop foo; echo $?" - "1\n")))) + (eshell-match-command-output "zerop foo; echo $?" + "1\n" nil t))) (ert-deftest esh-var-test/last-status-var-lisp-form () "Test using the \"last exit status\" ($?) variable with a Lisp form" @@ -484,9 +483,8 @@ esh-var-test/last-status-var-lisp-form "t\n0\n") (eshell-match-command-output "(zerop 1); echo $?" "2\n") - (let ((debug-on-error nil)) - (eshell-match-command-output "(zerop \"foo\"); echo $?" - "1\n"))))) + (eshell-match-command-output "(zerop \"foo\"); echo $?" + "1\n" nil t)))) (ert-deftest esh-var-test/last-status-var-lisp-form-2 () "Test using the \"last exit status\" ($?) variable with a Lisp form. @@ -497,9 +495,8 @@ esh-var-test/last-status-var-lisp-form-2 "0\n") (eshell-match-command-output "(zerop 0); echo $?" "0\n") - (let ((debug-on-error nil)) - (eshell-match-command-output "(zerop \"foo\"); echo $?" - "1\n"))))) + (eshell-match-command-output "(zerop \"foo\"); echo $?" + "1\n" nil t)))) (ert-deftest esh-var-test/last-status-var-ext-cmd () "Test using the \"last exit status\" ($?) variable with an external command" diff --git a/test/lisp/eshell/eshell-tests-helpers.el b/test/lisp/eshell/eshell-tests-helpers.el index 73abfcbb55..e713e162ad 100644 --- a/test/lisp/eshell/eshell-tests-helpers.el +++ b/test/lisp/eshell/eshell-tests-helpers.el @@ -100,9 +100,16 @@ eshell-match-output--explainer (put 'eshell-match-output 'ert-explainer #'eshell-match-output--explainer) -(defun eshell-match-command-output (command regexp &optional func) - "Insert a COMMAND at the end of the buffer and match the output with REGEXP." - (eshell-insert-command command func) +(defun eshell-match-command-output (command regexp &optional func + ignore-errors) + "Insert a COMMAND at the end of the buffer and match the output with REGEXP. +FUNC is the function to call after inserting the text (see +`eshell-insert-command'). + +If IGNORE-ERRORS is non-nil, ignore any errors signaled when +inserting the command." + (let ((debug-on-error (and (not ignore-errors) debug-on-error))) + (eshell-insert-command command func)) (eshell-wait-for-subprocess) (should (eshell-match-output regexp))) -- 2.25.1