all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#57216: 29.0.50; [PATCH] Provide ERT explainers for Eshell test functions
@ 2022-08-14 21:20 Jim Porter
  2022-08-15  7:01 ` Lars Ingebrigtsen
  2022-08-15 11:12 ` Eli Zaretskii
  0 siblings, 2 replies; 5+ messages in thread
From: Jim Porter @ 2022-08-14 21:20 UTC (permalink / raw)
  To: 57216; +Cc: eliz

[-- Attachment #1: Type: text/plain, Size: 1942 bytes --]

It can be difficult to diagnose test failures in the Eshell ERT test 
suite, since it doesn't print useful details like the command that was 
executed. See bug#57129 for example.

Here are some patches to fix that. The failures now look like this:

----------------------------------------

     (ert-test-failed
      ((should
        (eshell-match-output regexp))
       :form
       (eshell-match-output "wrong")
       :value nil :explanation
       (mismatched-output
        (command "echo $INSIDE_EMACS[, 1]\n")
        (output "eshell\n")
        (regexp "wrong"))))

----------------------------------------

     (ert-test-failed
      ((should
        (eshell-command-result--equal command
                                      (eshell-test-command-result command)
                                      result))
       :form
       (eshell-command-result--equal "echo $LINES" 22 2)
       :value nil :explanation
       (nonequal-result
        (command "echo $LINES")
        (result 22)
        (expected 2))))

----------------------------------------

Most of the first two patches are purely-mechanical changes to update 
function calls. The diffs ended up being pretty big, but I think it 
improves matters. Let me know if I should do it differently (especially 
for the commit message; I didn't see much benefit to listing *every* 
test function I touched, but maybe I should do that?)

While I was testing these, I also found a couple real bugs with the 
'eshell-command-result' function. This throws 'eshell-defer':

   M-: (eshell-command-result "if {[ foo = foo ]} {echo hi}")

That's because 'eshell-do-eval' wasn't forwarding the SYNCHRONOUS-P 
argument in a couple spots.

This is also wrong:

   M-: (eshell-command-result "if (zerop 1) {echo yes} {echo no}")
     => nil

It should return "no".

I fixed these in the third patch. Maybe that could go in a separate bug, 
but it's fairly closely related to this one.

[-- Attachment #2: 0001-Provide-ERT-explainer-for-eshell-match-command-outpu.patch --]
[-- Type: text/plain, Size: 41043 bytes --]

From d5e106d57c736f0c44ccecaf7834aeafa35e5a9d Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sat, 13 Aug 2022 20:31:11 -0700
Subject: [PATCH 1/3] Provide ERT explainer for 'eshell-match-command-output'

This was formerly named 'eshell-command-result-p', but "result" isn't
quite the right terminology, since this function specifically tested
the output of a command, not its Lisp result (as
'eshell-command-result' would return).

* test/lisp/eshell/eshell-tests-helpers.el (eshell-insert-command):
Provide a more-complete docstring.
(eshell-match-result): Rename to...
(eshell-match-output): ... this.
(eshell-match-output--explainer): New function.
(eshell-command-result-p): Rename to...
(eshell-match-command-output): ... this.

* test/lisp/eshell/em-alias-tests.el
* test/lisp/eshell/em-dirs-tests.el
* test/lisp/eshell/em-extpipe-tests.el
* test/lisp/eshell/em-script-tests.el
* test/lisp/eshell/esh-cmd-tests.el
* test/lisp/eshell/esh-proc-tests.el
* test/lisp/eshell/esh-var-tests.el
* test/lisp/eshell/eshell-tests-helpers.el
* test/lisp/eshell/eshell-tests.el: Use 'eshell-match-command-output'.
---
 test/lisp/eshell/em-alias-tests.el       |  28 ++---
 test/lisp/eshell/em-dirs-tests.el        |  40 +++----
 test/lisp/eshell/em-extpipe-tests.el     |  18 ++--
 test/lisp/eshell/em-script-tests.el      |  20 ++--
 test/lisp/eshell/esh-cmd-tests.el        | 128 ++++++++++++-----------
 test/lisp/eshell/esh-proc-tests.el       |   4 +-
 test/lisp/eshell/esh-var-tests.el        | 110 +++++++++----------
 test/lisp/eshell/eshell-tests-helpers.el |  38 ++++---
 test/lisp/eshell/eshell-tests.el         |  44 ++++----
 9 files changed, 222 insertions(+), 208 deletions(-)

diff --git a/test/lisp/eshell/em-alias-tests.el b/test/lisp/eshell/em-alias-tests.el
index 497159e346..aca622220e 100644
--- a/test/lisp/eshell/em-alias-tests.el
+++ b/test/lisp/eshell/em-alias-tests.el
@@ -38,50 +38,50 @@ em-alias-test/simple-alias
   "Test a simple alias with no arguments"
   (with-temp-eshell
    (eshell-insert-command "alias say-hi 'echo hi'")
-   (eshell-command-result-p "say-hi" "hi\n")
-   (eshell-command-result-p "say-hi bye" "hi\n")))
+   (eshell-match-command-output "say-hi" "hi\n")
+   (eshell-match-command-output "say-hi bye" "hi\n")))
 
 (ert-deftest em-alias-test/alias-arg-vars ()
   "Test alias with $0, $1, ... variables"
   (with-temp-eshell
    (eshell-insert-command "alias show-args 'printnl $0 \"$1 $2\"'")
-   (eshell-command-result-p "show-args one two" "show-args\none two\n")))
+   (eshell-match-command-output "show-args one two" "show-args\none two\n")))
 
 (ert-deftest em-alias-test/alias-arg-vars-indices ()
   "Test alias with $1, $2, ... variables using indices"
   (with-temp-eshell
    (eshell-insert-command "alias funny-sum '+ $1[0] $2[1]'")
-   (eshell-command-result-p "funny-sum (list 1 2) (list 3 4)"
-                            "5\n")))
+   (eshell-match-command-output "funny-sum (list 1 2) (list 3 4)"
+                                "5\n")))
 
 (ert-deftest em-alias-test/alias-arg-vars-split-indices ()
   "Test alias with $0, $1, ... variables using split indices"
   (with-temp-eshell
    (eshell-insert-command "alias my-prefix 'echo $0[- 0]'")
-   (eshell-command-result-p "my-prefix"
-                            "my\n")
+   (eshell-match-command-output "my-prefix"
+                                "my\n")
    (eshell-insert-command "alias funny-sum '+ $1[: 0] $2[: 1]'")
-   (eshell-command-result-p "funny-sum 1:2 3:4"
-                            "5\n")))
+   (eshell-match-command-output "funny-sum 1:2 3:4"
+                                "5\n")))
 
 (ert-deftest em-alias-test/alias-all-args-var ()
   "Test alias with the $* variable"
   (with-temp-eshell
    (eshell-insert-command "alias show-all-args 'printnl $*'")
-   (eshell-command-result-p "show-all-args" "\\`\\'")
-   (eshell-command-result-p "show-all-args a" "a\n")
-   (eshell-command-result-p "show-all-args a b c" "a\nb\nc\n")))
+   (eshell-match-command-output "show-all-args" "\\`\\'")
+   (eshell-match-command-output "show-all-args a" "a\n")
+   (eshell-match-command-output "show-all-args a b c" "a\nb\nc\n")))
 
 (ert-deftest em-alias-test/alias-all-args-var-indices ()
   "Test alias with the $* variable using indices"
   (with-temp-eshell
    (eshell-insert-command "alias add-pair '+ $*[0] $*[1]'")
-   (eshell-command-result-p "add-pair 1 2" "3\n")))
+   (eshell-match-command-output "add-pair 1 2" "3\n")))
 
 (ert-deftest em-alias-test/alias-all-args-var-split-indices ()
   "Test alias with the $* variable using split indices"
   (with-temp-eshell
    (eshell-insert-command "alias add-funny-pair '+ $*[0][: 0] $*[1][: 1]'")
-   (eshell-command-result-p "add-funny-pair 1:2 3:4" "5\n")))
+   (eshell-match-command-output "add-funny-pair 1:2 3:4" "5\n")))
 
 ;; em-alias-tests.el ends here
diff --git a/test/lisp/eshell/em-dirs-tests.el b/test/lisp/eshell/em-dirs-tests.el
index 8e96cc0747..9e44ef9851 100644
--- a/test/lisp/eshell/em-dirs-tests.el
+++ b/test/lisp/eshell/em-dirs-tests.el
@@ -58,45 +58,45 @@ em-dirs-test/oldpwd-var
   "Test using the $OLDPWD variable."
   (let (eshell-last-dir-ring-file-name)
     (with-temp-eshell
-     (eshell-command-result-p "echo $OLDPWD"
-                              "\\`\\'")
+     (eshell-match-command-output "echo $OLDPWD"
+                                  "\\`\\'")
      (ring-insert eshell-last-dir-ring "/some/path")
-     (eshell-command-result-p "echo $OLDPWD"
-                              "/some/path\n"))))
+     (eshell-match-command-output "echo $OLDPWD"
+                                  "/some/path\n"))))
 
 (ert-deftest em-dirs-test/oldpwd-var-indices ()
   "Test using the $OLDPWD variable with indices."
   (let (eshell-last-dir-ring-file-name)
     (with-temp-eshell
      (ring-insert eshell-last-dir-ring "/some/path/here")
-     (eshell-command-result-p "echo $OLDPWD[/ 1]"
-                              "some\n")
-     (eshell-command-result-p "echo $OLDPWD[/ 1 3]"
-                              "(\"some\" \"here\")\n"))))
+     (eshell-match-command-output "echo $OLDPWD[/ 1]"
+                                  "some\n")
+     (eshell-match-command-output "echo $OLDPWD[/ 1 3]"
+                                  "(\"some\" \"here\")\n"))))
 
 (ert-deftest em-dirs-test/directory-ring-var ()
   "Test using the $- (directory ring) variable."
   (let (eshell-last-dir-ring-file-name)
     (with-temp-eshell
-     (eshell-command-result-p "echo $-"
-                              "\\`\\'")
+     (eshell-match-command-output "echo $-"
+                                  "\\`\\'")
      (ring-insert eshell-last-dir-ring "/some/path")
      (ring-insert eshell-last-dir-ring "/other/path")
-     (eshell-command-result-p "echo $-"
-                              "/other/path\n")
-     (eshell-command-result-p "echo $-[0]"
-                              "/other/path\n")
-     (eshell-command-result-p "echo $-[1]"
-                              "/some/path\n"))))
+     (eshell-match-command-output "echo $-"
+                                  "/other/path\n")
+     (eshell-match-command-output "echo $-[0]"
+                                  "/other/path\n")
+     (eshell-match-command-output "echo $-[1]"
+                                  "/some/path\n"))))
 
 (ert-deftest em-dirs-test/directory-ring-var-indices ()
   "Test using the $- (directory ring) variable with multiple indices."
   (let (eshell-last-dir-ring-file-name)
     (with-temp-eshell
      (ring-insert eshell-last-dir-ring "/some/path/here")
-     (eshell-command-result-p "echo $-[0][/ 1]"
-                              "some\n")
-     (eshell-command-result-p "echo $-[1][/ 1 3]"
-                              "(\"some\" \"here\")\n"))))
+     (eshell-match-command-output "echo $-[0][/ 1]"
+                                  "some\n")
+     (eshell-match-command-output "echo $-[1][/ 1 3]"
+                                  "(\"some\" \"here\")\n"))))
 
 ;; em-dirs-tests.el ends here
diff --git a/test/lisp/eshell/em-extpipe-tests.el b/test/lisp/eshell/em-extpipe-tests.el
index 29f5dc0551..04e7827942 100644
--- a/test/lisp/eshell/em-extpipe-tests.el
+++ b/test/lisp/eshell/em-extpipe-tests.el
@@ -80,7 +80,7 @@ em-extpipe-test-1
   (should-parse '(eshell-named-command
                   "sh" (list "-c" "echo \"bar\" | rev >temp")))
   (with-substitute-for-temp
-   (eshell-command-result-p input "^$")
+   (eshell-match-command-output input "^$")
    (temp-should-string= "rab")))
 
 (em-extpipe-tests--deftest em-extpipe-test-2
@@ -91,7 +91,7 @@ em-extpipe-test-2
      '((eshell-named-command "echo" (list (eshell-escape-arg "bar")))
        (eshell-named-command "sh" (list "-c" "rev >temp")))))
   (with-substitute-for-temp
-   (eshell-command-result-p input "^$")
+   (eshell-match-command-output input "^$")
    (temp-should-string= "rab")))
 
 (em-extpipe-tests--deftest em-extpipe-test-3 "foo *| bar | baz -d"
@@ -111,7 +111,7 @@ em-extpipe-test-4
       (eshell-named-command "sh"
 			    (list "-c" "echo \"bar\" | rev"))))
   (with-substitute-for-temp
-   (eshell-command-result-p input "^$")
+   (eshell-match-command-output input "^$")
    (temp-buffer-should-string= "rab")))
 
 (em-extpipe-tests--deftest em-extpipe-test-5
@@ -177,7 +177,7 @@ em-extpipe-test-14
   (should-parse '(eshell-named-command "sh" (list "-c" "tac <temp")))
   (with-substitute-for-temp
    (with-temp-buffer (insert "bar\nbaz\n") (write-file temp))
-   (eshell-command-result-p input "baz\nbar")))
+   (eshell-match-command-output input "baz\nbar")))
 
 (em-extpipe-tests--deftest em-extpipe-test-15 "echo \"bar\" *| cat"
   (skip-unless (executable-find "cat"))
@@ -185,8 +185,8 @@ em-extpipe-test-15
    '(eshell-named-command "sh" (list "-c" "echo \"bar\" | cat")))
   (cl-letf (((symbol-function 'eshell/cat)
              (lambda (&rest _args) (eshell-print "nonsense"))))
-    (eshell-command-result-p input "bar")
-    (eshell-command-result-p "echo \"bar\" | cat" "nonsense")))
+    (eshell-match-command-output input "bar")
+    (eshell-match-command-output "echo \"bar\" | cat" "nonsense")))
 
 (em-extpipe-tests--deftest em-extpipe-test-16 "echo \"bar\" *| rev"
   (skip-unless (executable-find "rev"))
@@ -195,11 +195,11 @@ em-extpipe-test-16
   (let ((eshell-prefer-lisp-functions t))
     (cl-letf (((symbol-function 'rev)
                (lambda (&rest _args) (eshell-print "nonsense"))))
-      (eshell-command-result-p input "rab")
-      (eshell-command-result-p "echo \"bar\" | rev" "nonsense"))))
+      (eshell-match-command-output input "rab")
+      (eshell-match-command-output "echo \"bar\" | rev" "nonsense"))))
 
 ;; Confirm we don't break input of sharp-quoted symbols (Bug#53518).
 (em-extpipe-tests--deftest em-extpipe-test-17 "funcall #'upcase foo"
-  (eshell-command-result-p input "FOO"))
+  (eshell-match-command-output input "FOO"))
 
 ;;; em-extpipe-tests.el ends here
diff --git a/test/lisp/eshell/em-script-tests.el b/test/lisp/eshell/em-script-tests.el
index a34f943402..b837d464cc 100644
--- a/test/lisp/eshell/em-script-tests.el
+++ b/test/lisp/eshell/em-script-tests.el
@@ -38,25 +38,25 @@ em-script-test/source-script
   "Test sourcing script with no argumentss"
   (ert-with-temp-file temp-file :text "echo hi"
     (with-temp-eshell
-     (eshell-command-result-p (format "source %s" temp-file)
-                              "hi\n"))))
+     (eshell-match-command-output (format "source %s" temp-file)
+                                  "hi\n"))))
 
 (ert-deftest em-script-test/source-script-arg-vars ()
   "Test sourcing script with $0, $1, ... variables"
   (ert-with-temp-file temp-file :text "printnl $0 \"$1 $2\""
     (with-temp-eshell
-     (eshell-command-result-p (format "source %s one two" temp-file)
-                              (format "%s\none two\n" temp-file)))))
+     (eshell-match-command-output (format "source %s one two" temp-file)
+                                  (format "%s\none two\n" temp-file)))))
 
 (ert-deftest em-script-test/source-script-all-args-var ()
   "Test sourcing script with the $* variable"
   (ert-with-temp-file temp-file :text "printnl $*"
     (with-temp-eshell
-     (eshell-command-result-p (format "source %s" temp-file)
-                              "\\`\\'")
-     (eshell-command-result-p (format "source %s a" temp-file)
-                              "a\n")
-     (eshell-command-result-p (format "source %s a b c" temp-file)
-                              "a\nb\nc\n"))))
+     (eshell-match-command-output (format "source %s" temp-file)
+                                  "\\`\\'")
+     (eshell-match-command-output (format "source %s a" temp-file)
+                                  "a\n")
+     (eshell-match-command-output (format "source %s a b c" temp-file)
+                                  "a\nb\nc\n"))))
 
 ;; em-script-tests.el ends here
diff --git a/test/lisp/eshell/esh-cmd-tests.el b/test/lisp/eshell/esh-cmd-tests.el
index e86985ec71..05635e8a7b 100644
--- a/test/lisp/eshell/esh-cmd-tests.el
+++ b/test/lisp/eshell/esh-cmd-tests.el
@@ -80,19 +80,19 @@ esh-cmd-test/and-operator
   "Test logical && operator."
   (skip-unless (executable-find "["))
   (with-temp-eshell
-   (eshell-command-result-p "[ foo = foo ] && echo hi"
-                            "hi\n")
-   (eshell-command-result-p "[ foo = bar ] && echo hi"
-                            "\\`\\'")))
+   (eshell-match-command-output "[ foo = foo ] && echo hi"
+                                "hi\n")
+   (eshell-match-command-output "[ foo = bar ] && echo hi"
+                                "\\`\\'")))
 
 (ert-deftest esh-cmd-test/or-operator ()
   "Test logical || operator."
   (skip-unless (executable-find "["))
   (with-temp-eshell
-   (eshell-command-result-p "[ foo = foo ] || echo hi"
-                            "\\`\\'")
-   (eshell-command-result-p "[ foo = bar ] || echo hi"
-                            "hi\n")))
+   (eshell-match-command-output "[ foo = foo ] || echo hi"
+                                "\\`\\'")
+   (eshell-match-command-output "[ foo = bar ] || echo hi"
+                                "hi\n")))
 
 \f
 ;; Control flow statements
@@ -100,20 +100,20 @@ esh-cmd-test/or-operator
 (ert-deftest esh-cmd-test/for-loop ()
   "Test invocation of a for loop."
   (with-temp-eshell
-   (eshell-command-result-p "for i in 5 { echo $i }"
-                            "5\n")))
+   (eshell-match-command-output "for i in 5 { echo $i }"
+                                "5\n")))
 
 (ert-deftest esh-cmd-test/for-loop-list ()
   "Test invocation of a for loop iterating over a list."
   (with-temp-eshell
-   (eshell-command-result-p "for i in (list 1 2 (list 3 4)) { echo $i }"
-                            "1\n2\n(3 4)\n")))
+   (eshell-match-command-output "for i in (list 1 2 (list 3 4)) { echo $i }"
+                                "1\n2\n(3 4)\n")))
 
 (ert-deftest esh-cmd-test/for-loop-multiple-args ()
   "Test invocation of a for loop iterating over multiple arguments."
   (with-temp-eshell
-   (eshell-command-result-p "for i in 1 2 (list 3 4) { echo $i }"
-                            "1\n2\n3\n4\n")))
+   (eshell-match-command-output "for i in 1 2 (list 3 4) { echo $i }"
+                                "1\n2\n3\n4\n")))
 
 (ert-deftest esh-cmd-test/for-name-loop () ; bug#15231
   "Test invocation of a for loop using `name'."
@@ -126,7 +126,7 @@ esh-cmd-test/for-name-shadow-loop
   "Test invocation of a for loop using an env-var."
   (let ((process-environment (cons "name=env-value" process-environment)))
     (with-temp-eshell
-     (eshell-command-result-p
+     (eshell-match-command-output
       "echo $name; for name in 3 { echo $name }; echo $name"
       "env-value\n3\nenv-value\n"))))
 
@@ -134,7 +134,7 @@ esh-cmd-test/while-loop
   "Test invocation of a while loop."
   (with-temp-eshell
    (let ((eshell-test-value '(0 1 2)))
-     (eshell-command-result-p
+     (eshell-match-command-output
       (concat "while $eshell-test-value "
               "{ setq eshell-test-value (cdr eshell-test-value) }")
       "(1 2)\n(2)\n"))))
@@ -143,7 +143,7 @@ esh-cmd-test/while-loop-lisp-form
   "Test invocation of a while loop using a Lisp form."
   (with-temp-eshell
    (let ((eshell-test-value 0))
-     (eshell-command-result-p
+     (eshell-match-command-output
       (concat "while (/= eshell-test-value 3) "
               "{ setq eshell-test-value (1+ eshell-test-value) }")
       "1\n2\n3\n"))))
@@ -153,7 +153,7 @@ esh-cmd-test/while-loop-ext-cmd
   (skip-unless (executable-find "["))
   (with-temp-eshell
    (let ((eshell-test-value 0))
-     (eshell-command-result-p
+     (eshell-match-command-output
       (concat "while {[ $eshell-test-value -ne 3 ]} "
               "{ setq eshell-test-value (1+ eshell-test-value) }")
       "1\n2\n3\n"))))
@@ -162,7 +162,7 @@ esh-cmd-test/until-loop
   "Test invocation of an until loop."
   (with-temp-eshell
    (let ((eshell-test-value nil))
-     (eshell-command-result-p
+     (eshell-match-command-output
       (concat "until $eshell-test-value "
               "{ setq eshell-test-value t }")
       "t\n"))))
@@ -172,7 +172,7 @@ esh-cmd-test/until-loop-lisp-form
   (skip-unless (executable-find "["))
   (with-temp-eshell
    (let ((eshell-test-value 0))
-     (eshell-command-result-p
+     (eshell-match-command-output
       (concat "until (= eshell-test-value 3) "
               "{ setq eshell-test-value (1+ eshell-test-value) }")
       "1\n2\n3\n"))))
@@ -182,7 +182,7 @@ esh-cmd-test/until-loop-ext-cmd
   (skip-unless (executable-find "["))
   (with-temp-eshell
    (let ((eshell-test-value 0))
-     (eshell-command-result-p
+     (eshell-match-command-output
       (concat "until {[ $eshell-test-value -eq 3 ]} "
               "{ setq eshell-test-value (1+ eshell-test-value) }")
       "1\n2\n3\n"))))
@@ -191,93 +191,95 @@ esh-cmd-test/if-statement
   "Test invocation of an if statement."
   (with-temp-eshell
    (let ((eshell-test-value t))
-     (eshell-command-result-p "if $eshell-test-value {echo yes}"
-                              "yes\n"))
+     (eshell-match-command-output "if $eshell-test-value {echo yes}"
+                                  "yes\n"))
    (let ((eshell-test-value nil))
-     (eshell-command-result-p "if $eshell-test-value {echo yes}"
-                              "\\`\\'"))))
+     (eshell-match-command-output "if $eshell-test-value {echo yes}"
+                                  "\\`\\'"))))
 
 (ert-deftest esh-cmd-test/if-else-statement ()
   "Test invocation of an if/else statement."
   (with-temp-eshell
    (let ((eshell-test-value t))
-     (eshell-command-result-p "if $eshell-test-value {echo yes} {echo no}"
-                              "yes\n"))
+     (eshell-match-command-output "if $eshell-test-value {echo yes} {echo no}"
+                                  "yes\n"))
    (let ((eshell-test-value nil))
-     (eshell-command-result-p "if $eshell-test-value {echo yes} {echo no}"
-                              "no\n"))))
+     (eshell-match-command-output "if $eshell-test-value {echo yes} {echo no}"
+                                  "no\n"))))
 
 (ert-deftest esh-cmd-test/if-else-statement-lisp-form ()
   "Test invocation of an if/else statement using a Lisp form."
   (with-temp-eshell
-   (eshell-command-result-p "if (zerop 0) {echo yes} {echo no}"
-                            "yes\n")
-   (eshell-command-result-p "if (zerop 1) {echo yes} {echo no}"
-                            "no\n")
+   (eshell-match-command-output "if (zerop 0) {echo yes} {echo no}"
+                                "yes\n")
+   (eshell-match-command-output "if (zerop 1) {echo yes} {echo no}"
+                                "no\n")
    (let ((debug-on-error nil))
-     (eshell-command-result-p "if (zerop \"foo\") {echo yes} {echo no}"
-                              "no\n"))))
+     (eshell-match-command-output "if (zerop \"foo\") {echo yes} {echo no}"
+                                  "no\n"))))
 
 (ert-deftest esh-cmd-test/if-else-statement-lisp-form-2 ()
   "Test invocation of an if/else statement using a Lisp form.
 This tests when `eshell-lisp-form-nil-is-failure' is nil."
   (let ((eshell-lisp-form-nil-is-failure nil))
     (with-temp-eshell
-     (eshell-command-result-p "if (zerop 0) {echo yes} {echo no}"
-                              "yes\n")
-     (eshell-command-result-p "if (zerop 1) {echo yes} {echo no}"
-                              "yes\n")
+     (eshell-match-command-output "if (zerop 0) {echo yes} {echo no}"
+                                  "yes\n")
+     (eshell-match-command-output "if (zerop 1) {echo yes} {echo no}"
+                                  "yes\n")
      (let ((debug-on-error nil))
-       (eshell-command-result-p "if (zerop \"foo\") {echo yes} {echo no}"
-                                "no\n")))))
+       (eshell-match-command-output "if (zerop \"foo\") {echo yes} {echo no}"
+                                    "no\n")))))
 
 (ert-deftest esh-cmd-test/if-else-statement-ext-cmd ()
   "Test invocation of an if/else statement using an external command."
   (skip-unless (executable-find "["))
   (with-temp-eshell
-   (eshell-command-result-p "if {[ foo = foo ]} {echo yes} {echo no}"
-                            "yes\n")
-   (eshell-command-result-p "if {[ foo = bar ]} {echo yes} {echo no}"
-                            "no\n")))
+   (eshell-match-command-output "if {[ foo = foo ]} {echo yes} {echo no}"
+                                "yes\n")
+   (eshell-match-command-output "if {[ foo = bar ]} {echo yes} {echo no}"
+                                "no\n")))
 
 (ert-deftest esh-cmd-test/unless-statement ()
   "Test invocation of an unless statement."
   (with-temp-eshell
    (let ((eshell-test-value t))
-     (eshell-command-result-p "unless $eshell-test-value {echo no}"
-                              "\\`\\'"))
+     (eshell-match-command-output "unless $eshell-test-value {echo no}"
+                                  "\\`\\'"))
    (let ((eshell-test-value nil))
-     (eshell-command-result-p "unless $eshell-test-value {echo no}"
-                              "no\n"))))
+     (eshell-match-command-output "unless $eshell-test-value {echo no}"
+                                  "no\n"))))
 
 (ert-deftest esh-cmd-test/unless-else-statement ()
   "Test invocation of an unless/else statement."
   (with-temp-eshell
    (let ((eshell-test-value t))
-     (eshell-command-result-p "unless $eshell-test-value {echo no} {echo yes}"
-                              "yes\n"))
+     (eshell-match-command-output
+      "unless $eshell-test-value {echo no} {echo yes}"
+      "yes\n"))
    (let ((eshell-test-value nil))
-     (eshell-command-result-p "unless $eshell-test-value {echo no} {echo yes}"
-                              "no\n"))))
+     (eshell-match-command-output
+      "unless $eshell-test-value {echo no} {echo yes}"
+      "no\n"))))
 
 (ert-deftest esh-cmd-test/unless-else-statement-lisp-form ()
   "Test invocation of an unless/else statement using a Lisp form."
   (with-temp-eshell
-   (eshell-command-result-p "unless (zerop 0) {echo no} {echo yes}"
-                            "yes\n")
-   (eshell-command-result-p "unless (zerop 1) {echo no} {echo yes}"
-                            "no\n")
+   (eshell-match-command-output "unless (zerop 0) {echo no} {echo yes}"
+                                "yes\n")
+   (eshell-match-command-output "unless (zerop 1) {echo no} {echo yes}"
+                                "no\n")
    (let ((debug-on-error nil))
-     (eshell-command-result-p "unless (zerop \"foo\") {echo no} {echo yes}"
-                              "no\n"))))
+     (eshell-match-command-output "unless (zerop \"foo\") {echo no} {echo yes}"
+                                  "no\n"))))
 
 (ert-deftest esh-cmd-test/unless-else-statement-ext-cmd ()
   "Test invocation of an unless/else statement using an external command."
   (skip-unless (executable-find "["))
   (with-temp-eshell
-   (eshell-command-result-p "unless {[ foo = foo ]} {echo no} {echo yes}"
-                            "yes\n")
-   (eshell-command-result-p "unless {[ foo = bar ]} {echo no} {echo yes}"
-                            "no\n")))
+   (eshell-match-command-output "unless {[ foo = foo ]} {echo no} {echo yes}"
+                                "yes\n")
+   (eshell-match-command-output "unless {[ foo = bar ]} {echo no} {echo yes}"
+                                "no\n")))
 
 ;; esh-cmd-tests.el ends here
diff --git a/test/lisp/eshell/esh-proc-tests.el b/test/lisp/eshell/esh-proc-tests.el
index 734bb91a6a..f538e8c43a 100644
--- a/test/lisp/eshell/esh-proc-tests.el
+++ b/test/lisp/eshell/esh-proc-tests.el
@@ -43,7 +43,7 @@ esh-proc-test/sigpipe-exits-process
                     (executable-find "echo")
                     (executable-find "sleep")))
   (with-temp-eshell
-   (eshell-command-result-p
+   (eshell-match-command-output
     ;; The first command is like `yes' but slower.  This is to prevent
     ;; it from taxing Emacs's process filter too much and causing a
     ;; hang.
@@ -136,4 +136,4 @@ esh-proc-test/kill-background-process
    (kill-process (caar eshell-process-list))
    ;; Give `eshell-sentinel' a chance to run.
    (sit-for 0.1)
-   (eshell-match-result "\\[sh\\(\\.exe\\)?\\] [[:digit:]]+\n")))
+   (should (eshell-match-output "\\[sh\\(\\.exe\\)?\\] [[:digit:]]+\n"))))
diff --git a/test/lisp/eshell/esh-var-tests.el b/test/lisp/eshell/esh-var-tests.el
index 0c094ee5a7..ca74ad1959 100644
--- a/test/lisp/eshell/esh-var-tests.el
+++ b/test/lisp/eshell/esh-var-tests.el
@@ -153,15 +153,15 @@ esh-var-test/interp-cmd-external
   "Interpolate command result from external command"
   (skip-unless (executable-find "echo"))
   (with-temp-eshell
-   (eshell-command-result-p "echo ${*echo hi}"
-                            "hi\n")))
+   (eshell-match-command-output "echo ${*echo hi}"
+                                "hi\n")))
 
 (ert-deftest esh-var-test/interp-cmd-external-indices ()
   "Interpolate command result from external command with index"
   (skip-unless (executable-find "echo"))
   (with-temp-eshell
-   (eshell-command-result-p "echo ${*echo \"hi\nbye\"}[1]"
-                            "bye\n")))
+   (eshell-match-command-output "echo ${*echo \"hi\nbye\"}[1]"
+                                "bye\n")))
 
 (ert-deftest esh-var-test/interp-temp-cmd ()
   "Interpolate command result redirected to temp file"
@@ -196,8 +196,8 @@ esh-var-test/interp-concat-cmd-external
   "Interpolate command result from external command with concatenation"
   (skip-unless (executable-find "echo"))
   (with-temp-eshell
-   (eshell-command-result-p "echo ${echo hi}-${*echo there}"
-                            "hi-there\n")))
+   (eshell-match-command-output "echo ${echo hi}-${*echo there}"
+                                "hi-there\n")))
 
 (ert-deftest esh-var-test/quoted-interp-var ()
   "Interpolate variable inside double-quotes"
@@ -490,72 +490,72 @@ esh-var-test/columns-var
 (ert-deftest esh-var-test/inside-emacs-var ()
   "Test presence of \"INSIDE_EMACS\" in subprocesses"
   (with-temp-eshell
-   (eshell-command-result-p "env"
-                            (format "INSIDE_EMACS=%s,eshell"
-                                    emacs-version))))
+   (eshell-match-command-output "env"
+                                (format "INSIDE_EMACS=%s,eshell"
+                                        emacs-version))))
 
 (ert-deftest esh-var-test/inside-emacs-var-split-indices ()
   "Test using \"INSIDE_EMACS\" with split indices"
   (with-temp-eshell
-   (eshell-command-result-p "echo $INSIDE_EMACS[, 1]"
-                            "eshell")))
+   (eshell-match-command-output "echo $INSIDE_EMACS[, 1]"
+                                "eshell")))
 
 (ert-deftest esh-var-test/last-status-var-lisp-command ()
   "Test using the \"last exit status\" ($?) variable with a Lisp command"
   (with-temp-eshell
-   (eshell-command-result-p "zerop 0; echo $?"
-                            "t\n0\n")
-   (eshell-command-result-p "zerop 1; echo $?"
-                            "0\n")
+   (eshell-match-command-output "zerop 0; echo $?"
+                                "t\n0\n")
+   (eshell-match-command-output "zerop 1; echo $?"
+                                "0\n")
    (let ((debug-on-error nil))
-     (eshell-command-result-p "zerop foo; echo $?"
-                              "1\n"))))
+     (eshell-match-command-output "zerop foo; echo $?"
+                                  "1\n"))))
 
 (ert-deftest esh-var-test/last-status-var-lisp-form ()
   "Test using the \"last exit status\" ($?) variable with a Lisp form"
   (let ((eshell-lisp-form-nil-is-failure t))
-  (with-temp-eshell
-   (eshell-command-result-p "(zerop 0); echo $?"
-                            "t\n0\n")
-   (eshell-command-result-p "(zerop 1); echo $?"
-                            "2\n")
-   (let ((debug-on-error nil))
-     (eshell-command-result-p "(zerop \"foo\"); echo $?"
-                              "1\n")))))
+    (with-temp-eshell
+     (eshell-match-command-output "(zerop 0); echo $?"
+                                  "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")))))
 
 (ert-deftest esh-var-test/last-status-var-lisp-form-2 ()
   "Test using the \"last exit status\" ($?) variable with a Lisp form.
 This tests when `eshell-lisp-form-nil-is-failure' is nil."
   (let ((eshell-lisp-form-nil-is-failure nil))
     (with-temp-eshell
-     (eshell-command-result-p "(zerop 0); echo $?"
-                              "0\n")
-     (eshell-command-result-p "(zerop 0); echo $?"
-                              "0\n")
+     (eshell-match-command-output "(zerop 0); echo $?"
+                                  "0\n")
+     (eshell-match-command-output "(zerop 0); echo $?"
+                                  "0\n")
      (let ((debug-on-error nil))
-       (eshell-command-result-p "(zerop \"foo\"); echo $?"
-                                "1\n")))))
+       (eshell-match-command-output "(zerop \"foo\"); echo $?"
+                                    "1\n")))))
 
 (ert-deftest esh-var-test/last-status-var-ext-cmd ()
   "Test using the \"last exit status\" ($?) variable with an external command"
   (skip-unless (executable-find "["))
   (with-temp-eshell
-   (eshell-command-result-p "[ foo = foo ]; echo $?"
-                            "0\n")
-   (eshell-command-result-p "[ foo = bar ]; echo $?"
-                            "1\n")))
+   (eshell-match-command-output "[ foo = foo ]; echo $?"
+                                "0\n")
+   (eshell-match-command-output "[ foo = bar ]; echo $?"
+                                "1\n")))
 
 (ert-deftest esh-var-test/last-result-var ()
   "Test using the \"last result\" ($$) variable"
   (with-temp-eshell
-   (eshell-command-result-p "+ 1 2; + $$ 2"
-                            "3\n5\n")))
+   (eshell-match-command-output "+ 1 2; + $$ 2"
+                                "3\n5\n")))
 
 (ert-deftest esh-var-test/last-result-var-twice ()
   "Test using the \"last result\" ($$) variable twice"
   (with-temp-eshell
-   (eshell-command-result-p "+ 1 2; + $$ $$"
-                            "3\n6\n")))
+   (eshell-match-command-output "+ 1 2; + $$ $$"
+                                "3\n6\n")))
 
 (ert-deftest esh-var-test/last-result-var-ext-cmd ()
   "Test using the \"last result\" ($$) variable with an external command"
@@ -564,41 +564,41 @@ esh-var-test/last-result-var-ext-cmd
    ;; MS-DOS/MS-Windows have an external command 'format', which we
    ;; don't want here.
    (let ((eshell-prefer-lisp-functions t))
-     (eshell-command-result-p "[ foo = foo ]; format \"%s\" $$"
-                              "t\n")
-     (eshell-command-result-p "[ foo = bar ]; format \"%s\" $$"
-                              "nil\n"))))
+     (eshell-match-command-output "[ foo = foo ]; format \"%s\" $$"
+                                  "t\n")
+     (eshell-match-command-output "[ foo = bar ]; format \"%s\" $$"
+                                  "nil\n"))))
 
 (ert-deftest esh-var-test/last-result-var-split-indices ()
   "Test using the \"last result\" ($$) variable with split indices"
   (with-temp-eshell
-   (eshell-command-result-p
+   (eshell-match-command-output
     "string-join (list \"01\" \"02\") :; + $$[: 1] 3"
     "01:02\n5\n")
-   (eshell-command-result-p
+   (eshell-match-command-output
     "string-join (list \"01\" \"02\") :; echo \"$$[: 1]\""
     "01:02\n02\n")))
 
 (ert-deftest esh-var-test/last-arg-var ()
   "Test using the \"last arg\" ($_) variable"
   (with-temp-eshell
-   (eshell-command-result-p "+ 1 2; + $_ 4"
-                            "3\n6\n")))
+   (eshell-match-command-output "+ 1 2; + $_ 4"
+                                "3\n6\n")))
 
 (ert-deftest esh-var-test/last-arg-var-indices ()
   "Test using the \"last arg\" ($_) variable with indices"
   (with-temp-eshell
-   (eshell-command-result-p "+ 1 2; + $_[0] 4"
-                            "3\n5\n")
-   (eshell-command-result-p "+ 1 2; + $_[1] 4"
-                            "3\n6\n")))
+   (eshell-match-command-output "+ 1 2; + $_[0] 4"
+                                "3\n5\n")
+   (eshell-match-command-output "+ 1 2; + $_[1] 4"
+                                "3\n6\n")))
 
 (ert-deftest esh-var-test/last-arg-var-split-indices ()
   "Test using the \"last arg\" ($_) variable with split indices"
   (with-temp-eshell
-   (eshell-command-result-p "concat 01:02 03:04; + $_[0][: 1] 5"
-                            "01:0203:04\n7\n")
-   (eshell-command-result-p "concat 01:02 03:04; echo \"$_[0][: 1]\""
-                            "01:0203:04\n02\n")))
+   (eshell-match-command-output "concat 01:02 03:04; + $_[0][: 1] 5"
+                                "01:0203:04\n7\n")
+   (eshell-match-command-output "concat 01:02 03:04; echo \"$_[0][: 1]\""
+                                "01:0203:04\n02\n")))
 
 ;; esh-var-tests.el ends here
diff --git a/test/lisp/eshell/eshell-tests-helpers.el b/test/lisp/eshell/eshell-tests-helpers.el
index 4ad76ca697..778087bd75 100644
--- a/test/lisp/eshell/eshell-tests-helpers.el
+++ b/test/lisp/eshell/eshell-tests-helpers.el
@@ -65,24 +65,36 @@ eshell-wait-for-subprocess
         (error "timed out waiting for subprocess(es)"))
       (sit-for 0.1))))
 
-(defun eshell-insert-command (text &optional func)
-  "Insert a command at the end of the buffer."
+(defun eshell-insert-command (command &optional func)
+  "Insert a COMMAND at the end of the buffer.
+After inserting, call FUNC.  If FUNC is nil, instead call
+`eshell-send-input'."
   (goto-char eshell-last-output-end)
-  (insert-and-inherit text)
+  (insert-and-inherit command)
   (funcall (or func 'eshell-send-input)))
 
-(defun eshell-match-result (regexp)
-  "Check that output of last command matches REGEXP."
-  (should
-   (string-match-p
+(defun eshell-match-output (regexp)
+  "Test whether the output of the last command matches REGEXP."
+  (string-match-p
     regexp (buffer-substring-no-properties
-            (eshell-beginning-of-output) (eshell-end-of-output)))))
-
-(defun eshell-command-result-p (text regexp &optional func)
-  "Insert a command at the end of the buffer."
-  (eshell-insert-command text func)
+            (eshell-beginning-of-output) (eshell-end-of-output))))
+
+(defun eshell-match-output--explainer (regexp)
+  "Explain the result of `eshell-match-output'."
+  `(mismatched-output
+    (command ,(buffer-substring-no-properties
+               eshell-last-input-start eshell-last-input-end))
+    (output ,(buffer-substring-no-properties
+              (eshell-beginning-of-output) (eshell-end-of-output)))
+    (regexp ,regexp)))
+
+(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)
   (eshell-wait-for-subprocess)
-  (eshell-match-result regexp))
+  (should (eshell-match-output regexp)))
 
 (defvar eshell-history-file-name)
 
diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el
index 8423500ea7..c7a9516bea 100644
--- a/test/lisp/eshell/eshell-tests.el
+++ b/test/lisp/eshell/eshell-tests.el
@@ -40,15 +40,15 @@ 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-command-result-p "echo hi | *cat"
-                            "hi")))
+   (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-command-result-p "*echo hi | echo bye"
-                            "bye\nhi\n")))
+   (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"
@@ -59,23 +59,23 @@ eshell-test/pipe-headproc-stdin
    (eshell-insert-command "hello")
    (eshell-send-eof-to-process)
    (eshell-wait-for-subprocess)
-   (eshell-match-result "OLLEH\n")))
+   (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-command-result-p "echo ${*echo hi} | *cat"
-                            "hi")))
+   (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-command-result-p "echo ${*echo hi | *cat} | *cat"
-                            "hi")))
+   (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'."
@@ -129,32 +129,32 @@ eshell-test/escape-nonspecial
   "Test that \"\\c\" and \"c\" are equivalent when \"c\" is not a
 special character."
   (with-temp-eshell
-   (eshell-command-result-p "echo he\\llo"
-                            "hello\n")))
+   (eshell-match-command-output "echo he\\llo"
+                                "hello\n")))
 
 (ert-deftest eshell-test/escape-nonspecial-unicode ()
   "Test that \"\\c\" and \"c\" are equivalent when \"c\" is a
 unicode character (unicode characters are nonspecial by
 definition)."
   (with-temp-eshell
-   (eshell-command-result-p "echo Vid\\éos"
-                            "Vidéos\n")))
+   (eshell-match-command-output "echo Vid\\éos"
+                                "Vidéos\n")))
 
 (ert-deftest eshell-test/escape-nonspecial-quoted ()
   "Test that the backslash is preserved for escaped nonspecial
 chars"
   (with-temp-eshell
-   (eshell-command-result-p "echo \"h\\i\""
-                            ;; Backslashes are doubled for regexp.
-                            "h\\\\i\n")))
+   (eshell-match-command-output "echo \"h\\i\""
+                                ;; Backslashes are doubled for regexp.
+                                "h\\\\i\n")))
 
 (ert-deftest eshell-test/escape-special-quoted ()
   "Test that the backslash is not preserved for escaped special
 chars"
   (with-temp-eshell
-   (eshell-command-result-p "echo \"\\\"hi\\\\\""
-                            ;; Backslashes are doubled for regexp.
-                            "\\\"hi\\\\\n")))
+   (eshell-match-command-output "echo \"\\\"hi\\\\\""
+                                ;; Backslashes are doubled for regexp.
+                                "\\\"hi\\\\\n")))
 
 (ert-deftest eshell-test/command-running-p ()
   "Modeline should show no command running"
@@ -188,15 +188,15 @@ eshell-test/queue-input
                  (> count 0))
        (sit-for 1)
        (setq count (1- count))))
-   (eshell-match-result "alpha\n")))
+   (should (eshell-match-output "alpha\n"))))
 
 (ert-deftest eshell-test/flush-output ()
   "Test flushing of previous output"
   (with-temp-eshell
    (eshell-insert-command "echo alpha")
    (eshell-kill-output)
-   (eshell-match-result
-    (concat "^" (regexp-quote "*** output flushed ***\n") "$"))))
+   (should (eshell-match-output
+            (concat "^" (regexp-quote "*** output flushed ***\n") "$")))))
 
 (ert-deftest eshell-test/run-old-command ()
   "Re-run an old command"
-- 
2.25.1


[-- Attachment #3: 0002-Add-eshell-command-result-equal-with-an-ERT-explaine.patch --]
[-- Type: text/plain, Size: 43621 bytes --]

From 9b75f80778bda31d36c99edbef888cbc2335f587 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sun, 14 Aug 2022 13:44:04 -0700
Subject: [PATCH 2/3] Add 'eshell-command-result-equal' with an ERT explainer

* test/lisp/eshell/eshell-tests-helpers.el
(eshell-command-result--equal, eshell-command-result--equal-explainer)
(eshell-command-result-equal): New functions.

* test/lisp/eshell/em-basic-tests.el
* test/lisp/eshell/em-dirs-tests.el
* test/lisp/eshell/esh-cmd-tests.el
* test/lisp/eshell/esh-proc-tests.el
* test/lisp/eshell/esh-var-tests.el
* test/lisp/eshell/eshell-tests.el: Use 'eshell-command-result-equal'.
---
 test/lisp/eshell/em-basic-tests.el       |  18 +-
 test/lisp/eshell/em-dirs-tests.el        |  16 +-
 test/lisp/eshell/esh-cmd-tests.el        |  19 +-
 test/lisp/eshell/esh-proc-tests.el       |  31 +-
 test/lisp/eshell/esh-var-tests.el        | 391 ++++++++++-------------
 test/lisp/eshell/eshell-tests-helpers.el |  21 ++
 test/lisp/eshell/eshell-tests.el         |  31 +-
 7 files changed, 254 insertions(+), 273 deletions(-)

diff --git a/test/lisp/eshell/em-basic-tests.el b/test/lisp/eshell/em-basic-tests.el
index 7a24f8b46c..bc8baeaa03 100644
--- a/test/lisp/eshell/em-basic-tests.el
+++ b/test/lisp/eshell/em-basic-tests.el
@@ -36,25 +36,25 @@
 (ert-deftest em-basic-test/umask-print-numeric ()
   "Test printing umask numerically."
   (cl-letf (((symbol-function 'default-file-modes) (lambda () #o775)))
-    (should (equal (eshell-test-command-result "umask") "002\n")))
+    (eshell-command-result-equal "umask" "002\n"))
   (cl-letf (((symbol-function 'default-file-modes) (lambda () #o654)))
-    (should (equal (eshell-test-command-result "umask") "123\n")))
+    (eshell-command-result-equal "umask" "123\n"))
   ;; Make sure larger numbers don't cause problems.
   (cl-letf (((symbol-function 'default-file-modes) (lambda () #o1775)))
-    (should (equal (eshell-test-command-result "umask") "002\n"))))
+    (eshell-command-result-equal "umask" "002\n")))
 
 (ert-deftest em-basic-test/umask-read-symbolic ()
   "Test printing umask symbolically."
   (cl-letf (((symbol-function 'default-file-modes) (lambda () #o775)))
-    (should (equal (eshell-test-command-result "umask -S")
-                   "u=rwx,g=rwx,o=rx\n")))
+    (eshell-command-result-equal "umask -S"
+                                 "u=rwx,g=rwx,o=rx\n"))
   (cl-letf (((symbol-function 'default-file-modes) (lambda () #o654)))
-    (should (equal (eshell-test-command-result "umask -S")
-                   "u=wx,g=rx,o=x\n")))
+    (eshell-command-result-equal "umask -S"
+                                 "u=wx,g=rx,o=x\n"))
   ;; Make sure larger numbers don't cause problems.
   (cl-letf (((symbol-function 'default-file-modes) (lambda () #o1775)))
-    (should (equal (eshell-test-command-result "umask -S")
-                   "u=rwx,g=rwx,o=rx\n"))))
+    (eshell-command-result-equal "umask -S"
+                                 "u=rwx,g=rwx,o=rx\n")))
 
 (ert-deftest em-basic-test/umask-set ()
   "Test setting umask."
diff --git a/test/lisp/eshell/em-dirs-tests.el b/test/lisp/eshell/em-dirs-tests.el
index 9e44ef9851..f72d708dca 100644
--- a/test/lisp/eshell/em-dirs-tests.el
+++ b/test/lisp/eshell/em-dirs-tests.el
@@ -37,22 +37,22 @@
 (ert-deftest em-dirs-test/pwd-var ()
   "Test using the $PWD variable."
   (let ((default-directory "/some/path"))
-    (should (equal (eshell-test-command-result "echo $PWD")
-                   (expand-file-name default-directory)))))
+    (eshell-command-result-equal "echo $PWD"
+                                 (expand-file-name default-directory))))
 
 (ert-deftest em-dirs-test/pwd-var-indices ()
   "Test using the $PWD variable with indices."
   (let ((default-directory "/some/path/here"))
-    (should (equal (eshell-test-command-result "echo $PWD[/ 1]")
-                   "some"))
-    (should (equal (eshell-test-command-result "echo $PWD[/ 1 3]")
-                   '("some" "here")))))
+    (eshell-command-result-equal "echo $PWD[/ 1]"
+                                 "some")
+    (eshell-command-result-equal "echo $PWD[/ 1 3]"
+                                 '("some" "here"))))
 
 (ert-deftest em-dirs-test/short-pwd-var ()
   "Test using the $+ (current directory) variable."
   (let ((default-directory "/some/path"))
-    (should (equal (eshell-test-command-result "echo $+")
-                   (expand-file-name default-directory)))))
+    (eshell-command-result-equal "echo $+"
+                                 (expand-file-name default-directory))))
 
 (ert-deftest em-dirs-test/oldpwd-var ()
   "Test using the $OLDPWD variable."
diff --git a/test/lisp/eshell/esh-cmd-tests.el b/test/lisp/eshell/esh-cmd-tests.el
index 05635e8a7b..c5d780a399 100644
--- a/test/lisp/eshell/esh-cmd-tests.el
+++ b/test/lisp/eshell/esh-cmd-tests.el
@@ -41,37 +41,37 @@ eshell-test-value
 
 (ert-deftest esh-cmd-test/simple-command-result ()
   "Test invocation with a simple command."
-  (should (equal (eshell-test-command-result "+ 1 2") 3)))
+  (eshell-command-result-equal "+ 1 2" 3))
 
 (ert-deftest esh-cmd-test/lisp-command ()
   "Test invocation with an elisp command."
-  (should (equal (eshell-test-command-result "(+ 1 2)") 3)))
+  (eshell-command-result-equal "(+ 1 2)" 3))
 
 (ert-deftest esh-cmd-test/lisp-command-with-quote ()
   "Test invocation with an elisp command containing a quote."
-  (should (equal (eshell-test-command-result "(eq 'foo nil)") nil)))
+  (eshell-command-result-equal "(eq 'foo nil)" nil))
 
 (ert-deftest esh-cmd-test/lisp-command-args ()
   "Test invocation with elisp and trailing args.
 Test that trailing arguments outside the S-expression are
 ignored.  e.g. \"(+ 1 2) 3\" => 3"
-  (should (equal (eshell-test-command-result "(+ 1 2) 3") 3)))
+  (eshell-command-result-equal "(+ 1 2) 3" 3))
 
 (ert-deftest esh-cmd-test/subcommand ()
   "Test invocation with a simple subcommand."
-  (should (equal (eshell-test-command-result "{+ 1 2}") 3)))
+  (eshell-command-result-equal "{+ 1 2}" 3))
 
 (ert-deftest esh-cmd-test/subcommand-args ()
   "Test invocation with a subcommand and trailing args.
 Test that trailing arguments outside the subcommand are ignored.
 e.g. \"{+ 1 2} 3\" => 3"
-  (should (equal (eshell-test-command-result "{+ 1 2} 3") 3)))
+  (eshell-command-result-equal "{+ 1 2} 3" 3))
 
 (ert-deftest esh-cmd-test/subcommand-lisp ()
   "Test invocation with an elisp subcommand and trailing args.
 Test that trailing arguments outside the subcommand are ignored.
 e.g. \"{(+ 1 2)} 3\" => 3"
-  (should (equal (eshell-test-command-result "{(+ 1 2)} 3") 3)))
+  (eshell-command-result-equal "{(+ 1 2)} 3" 3))
 
 \f
 ;; Logical operators
@@ -118,9 +118,8 @@ esh-cmd-test/for-loop-multiple-args
 (ert-deftest esh-cmd-test/for-name-loop () ; bug#15231
   "Test invocation of a for loop using `name'."
   (let ((process-environment (cons "name" process-environment)))
-    (should (equal (eshell-test-command-result
-                    "for name in 3 { echo $name }")
-                   3))))
+    (eshell-command-result-equal "for name in 3 { echo $name }"
+                                 3)))
 
 (ert-deftest esh-cmd-test/for-name-shadow-loop () ; bug#15372
   "Test invocation of a for loop using an env-var."
diff --git a/test/lisp/eshell/esh-proc-tests.el b/test/lisp/eshell/esh-proc-tests.el
index f538e8c43a..2369bb5cc0 100644
--- a/test/lisp/eshell/esh-proc-tests.el
+++ b/test/lisp/eshell/esh-proc-tests.el
@@ -56,36 +56,37 @@ esh-proc-test/sigpipe-exits-process
 (ert-deftest esh-proc-test/pipeline-connection-type/no-pipeline ()
   "Test that all streams are PTYs when a command is not in a pipeline."
   (skip-unless (executable-find "sh"))
-  (should (equal (eshell-test-command-result esh-proc-test--detect-pty-cmd)
-                 ;; PTYs aren't supported on MS-Windows.
-                 (unless (eq system-type 'windows-nt)
-                   "stdin\nstdout\nstderr\n"))))
+  (eshell-command-result-equal
+   esh-proc-test--detect-pty-cmd
+   ;; PTYs aren't supported on MS-Windows.
+   (unless (eq system-type 'windows-nt)
+     "stdin\nstdout\nstderr\n")))
 
 (ert-deftest esh-proc-test/pipeline-connection-type/first ()
   "Test that only stdin is a PTY when a command starts a pipeline."
   (skip-unless (and (executable-find "sh")
                     (executable-find "cat")))
-  (should (equal (eshell-test-command-result
-                  (concat esh-proc-test--detect-pty-cmd " | cat"))
-                 (unless (eq system-type 'windows-nt)
-                   "stdin\n"))))
+  (eshell-command-result-equal
+   (concat esh-proc-test--detect-pty-cmd " | cat")
+   (unless (eq system-type 'windows-nt)
+     "stdin\n")))
 
 (ert-deftest esh-proc-test/pipeline-connection-type/middle ()
   "Test that all streams are pipes when a command is in the middle of a
 pipeline."
   (skip-unless (and (executable-find "sh")
                     (executable-find "cat")))
-  (should (equal (eshell-test-command-result
-                  (concat "echo | " esh-proc-test--detect-pty-cmd " | cat"))
-                 nil)))
+  (eshell-command-result-equal
+   (concat "echo | " esh-proc-test--detect-pty-cmd " | cat")
+   nil))
 
 (ert-deftest esh-proc-test/pipeline-connection-type/last ()
   "Test that only output streams are PTYs when a command ends a pipeline."
   (skip-unless (executable-find "sh"))
-  (should (equal (eshell-test-command-result
-                  (concat "echo | " esh-proc-test--detect-pty-cmd))
-                 (unless (eq system-type 'windows-nt)
-                   "stdout\nstderr\n"))))
+  (eshell-command-result-equal
+   (concat "echo | " esh-proc-test--detect-pty-cmd)
+   (unless (eq system-type 'windows-nt)
+     "stdout\nstderr\n")))
 
 (ert-deftest esh-proc-test/kill-pipeline ()
   "Test that killing a pipeline of processes only emits a single
diff --git a/test/lisp/eshell/esh-var-tests.el b/test/lisp/eshell/esh-var-tests.el
index ca74ad1959..bebc57d359 100644
--- a/test/lisp/eshell/esh-var-tests.el
+++ b/test/lisp/eshell/esh-var-tests.el
@@ -41,113 +41,107 @@ eshell-test-value
 
 (ert-deftest esh-var-test/interp-var ()
   "Interpolate variable"
-  (should (equal (eshell-test-command-result "echo $user-login-name")
-                 user-login-name)))
+  (eshell-command-result-equal "echo $user-login-name"
+                               user-login-name))
 
 (ert-deftest esh-var-test/interp-quoted-var ()
   "Interpolate quoted variable"
-  (should (equal (eshell-test-command-result "echo $'user-login-name'")
-                 user-login-name))
-  (should (equal (eshell-test-command-result "echo $\"user-login-name\"")
-                 user-login-name)))
+  (eshell-command-result-equal "echo $'user-login-name'"
+                               user-login-name)
+  (eshell-command-result-equal "echo $\"user-login-name\""
+                               user-login-name))
 
 (ert-deftest esh-var-test/interp-quoted-var-concat ()
   "Interpolate and concat quoted variable"
-  (should (equal (eshell-test-command-result "echo $'user-login-name'-foo")
-                 (concat user-login-name "-foo")))
-  (should (equal (eshell-test-command-result "echo $\"user-login-name\"-foo")
-                 (concat user-login-name "-foo"))))
+  (eshell-command-result-equal "echo $'user-login-name'-foo"
+                               (concat user-login-name "-foo"))
+  (eshell-command-result-equal "echo $\"user-login-name\"-foo"
+                               (concat user-login-name "-foo")))
 
 (ert-deftest esh-var-test/interp-var-indices ()
   "Interpolate list variable with indices"
   (let ((eshell-test-value '("zero" "one" "two" "three" "four")))
-    (should (equal (eshell-test-command-result "echo $eshell-test-value[0]")
-                   "zero"))
-    (should (equal (eshell-test-command-result "echo $eshell-test-value[0 2]")
-                   '("zero" "two")))
-    (should (equal (eshell-test-command-result "echo $eshell-test-value[0 2 4]")
-                   '("zero" "two" "four")))))
+    (eshell-command-result-equal "echo $eshell-test-value[0]"
+                                 "zero")
+    (eshell-command-result-equal "echo $eshell-test-value[0 2]"
+                                 '("zero" "two"))
+    (eshell-command-result-equal "echo $eshell-test-value[0 2 4]"
+                                 '("zero" "two" "four"))))
 
 (ert-deftest esh-var-test/interp-var-split-indices ()
   "Interpolate string variable with indices"
   (let ((eshell-test-value "zero one two three four"))
-    (should (equal (eshell-test-command-result "echo $eshell-test-value[0]")
-                   "zero"))
-    (should (equal (eshell-test-command-result "echo $eshell-test-value[0 2]")
-                   '("zero" "two")))
-    (should (equal (eshell-test-command-result "echo $eshell-test-value[0 2 4]")
-                   '("zero" "two" "four")))))
+    (eshell-command-result-equal "echo $eshell-test-value[0]"
+                                 "zero")
+    (eshell-command-result-equal "echo $eshell-test-value[0 2]"
+                                 '("zero" "two"))
+    (eshell-command-result-equal "echo $eshell-test-value[0 2 4]"
+                                 '("zero" "two" "four"))))
 
 (ert-deftest esh-var-test/interp-var-string-split-indices ()
   "Interpolate string variable with string splitter and indices"
   (let ((eshell-test-value "zero:one:two:three:four"))
-    (should (equal (eshell-test-command-result "echo $eshell-test-value[: 0]")
-                   "zero"))
-    (should (equal (eshell-test-command-result "echo $eshell-test-value[: 0 2]")
-                   '("zero" "two"))))
+    (eshell-command-result-equal "echo $eshell-test-value[: 0]"
+                                 "zero")
+    (eshell-command-result-equal "echo $eshell-test-value[: 0 2]"
+                                 '("zero" "two")))
   (let ((eshell-test-value "zeroXoneXtwoXthreeXfour"))
-    (should (equal (eshell-test-command-result "echo $eshell-test-value[X 0]")
-                   "zero"))
-    (should (equal (eshell-test-command-result "echo $eshell-test-value[X 0 2]")
-                   '("zero" "two")))))
+    (eshell-command-result-equal "echo $eshell-test-value[X 0]"
+                                 "zero")
+    (eshell-command-result-equal "echo $eshell-test-value[X 0 2]"
+                                 '("zero" "two"))))
 
 (ert-deftest esh-var-test/interp-var-regexp-split-indices ()
   "Interpolate string variable with regexp splitter and indices"
   (let ((eshell-test-value "zero:one!two:three!four"))
-    (should (equal (eshell-test-command-result
-                    "echo $eshell-test-value['[:!]' 0]")
-                   "zero"))
-    (should (equal (eshell-test-command-result
-                    "echo $eshell-test-value['[:!]' 0 2]")
-                   '("zero" "two")))
-    (should (equal (eshell-test-command-result
-                    "echo $eshell-test-value[\"[:!]\" 0]")
-                   "zero"))
-    (should (equal (eshell-test-command-result
-                    "echo $eshell-test-value[\"[:!]\" 0 2]")
-                   '("zero" "two")))))
+    (eshell-command-result-equal "echo $eshell-test-value['[:!]' 0]"
+                                 "zero")
+    (eshell-command-result-equal "echo $eshell-test-value['[:!]' 0 2]"
+                                 '("zero" "two"))
+    (eshell-command-result-equal "echo $eshell-test-value[\"[:!]\" 0]"
+                                 "zero")
+    (eshell-command-result-equal "echo $eshell-test-value[\"[:!]\" 0 2]"
+                                 '("zero" "two"))))
 
 (ert-deftest esh-var-test/interp-var-assoc ()
   "Interpolate alist variable with index"
   (let ((eshell-test-value '(("foo" . 1))))
-    (should (eq (eshell-test-command-result "echo $eshell-test-value[foo]")
-                1))))
+    (eshell-command-result-equal "echo $eshell-test-value[foo]"
+                                 1)))
 
 (ert-deftest esh-var-test/interp-var-length-list ()
   "Interpolate length of list variable"
   (let ((eshell-test-value '((1 2) (3) (5 (6 7 8 9)))))
-    (should (eq (eshell-test-command-result "echo $#eshell-test-value") 3))
-    (should (eq (eshell-test-command-result "echo $#eshell-test-value[1]") 1))
-    (should (eq (eshell-test-command-result "echo $#eshell-test-value[2][1]")
-                4))))
+    (eshell-command-result-equal "echo $#eshell-test-value" 3)
+    (eshell-command-result-equal "echo $#eshell-test-value[1]" 1)
+    (eshell-command-result-equal "echo $#eshell-test-value[2][1]" 4)))
 
 (ert-deftest esh-var-test/interp-var-length-string ()
   "Interpolate length of string variable"
   (let ((eshell-test-value "foobar"))
-    (should (eq (eshell-test-command-result "echo $#eshell-test-value") 6))))
+    (eshell-command-result-equal "echo $#eshell-test-value" 6)))
 
 (ert-deftest esh-var-test/interp-var-length-alist ()
   "Interpolate length of alist variable"
   (let ((eshell-test-value '(("foo" . (1 2 3)))))
-    (should (eq (eshell-test-command-result "echo $#eshell-test-value") 1))
-    (should (eq (eshell-test-command-result "echo $#eshell-test-value[foo]")
-                3))))
+    (eshell-command-result-equal "echo $#eshell-test-value" 1)
+    (eshell-command-result-equal "echo $#eshell-test-value[foo]" 3)))
 
 (ert-deftest esh-var-test/interp-lisp ()
   "Interpolate Lisp form evaluation"
-  (should (equal (eshell-test-command-result "+ $(+ 1 2) 3") 6)))
+  (eshell-command-result-equal "+ $(+ 1 2) 3" 6))
 
 (ert-deftest esh-var-test/interp-lisp-indices ()
   "Interpolate Lisp form evaluation with index"
-  (should (equal (eshell-test-command-result "+ $(list 1 2)[1] 3") 5)))
+  (eshell-command-result-equal "+ $(list 1 2)[1] 3" 5))
 
 (ert-deftest esh-var-test/interp-cmd ()
   "Interpolate command result"
-  (should (equal (eshell-test-command-result "+ ${+ 1 2} 3") 6)))
+  (eshell-command-result-equal "+ ${+ 1 2} 3" 6))
 
 (ert-deftest esh-var-test/interp-cmd-indices ()
   "Interpolate command result with index"
-  (should (equal (eshell-test-command-result "+ ${listify 1 2}[1] 3") 5)))
+  (eshell-command-result-equal "+ ${listify 1 2}[1] 3" 5))
 
 (ert-deftest esh-var-test/interp-cmd-external ()
   "Interpolate command result from external command"
@@ -165,32 +159,32 @@ esh-var-test/interp-cmd-external-indices
 
 (ert-deftest esh-var-test/interp-temp-cmd ()
   "Interpolate command result redirected to temp file"
-  (should (equal (eshell-test-command-result "cat $<echo hi>") "hi")))
+  (eshell-command-result-equal "cat $<echo hi>" "hi"))
 
 (ert-deftest esh-var-test/interp-concat-lisp ()
   "Interpolate and concat Lisp form"
-  (should (equal (eshell-test-command-result "+ $(+ 1 2)3 3") 36)))
+  (eshell-command-result-equal "+ $(+ 1 2)3 3" 36))
 
 (ert-deftest esh-var-test/interp-concat-lisp2 ()
   "Interpolate and concat two Lisp forms"
-  (should (equal (eshell-test-command-result "+ $(+ 1 2)$(+ 1 2) 3") 36)))
+  (eshell-command-result-equal "+ $(+ 1 2)$(+ 1 2) 3" 36))
 
 (ert-deftest esh-var-test/interp-concat-cmd ()
   "Interpolate and concat command with literal"
-  (should (equal (eshell-test-command-result "+ ${+ 1 2}3 3") 36))
-  (should (equal (eshell-test-command-result "echo ${*echo \"foo\nbar\"}-baz")
-                 '("foo" "bar-baz")))
+  (eshell-command-result-equal "+ ${+ 1 2}3 3" 36)
+  (eshell-command-result-equal "echo ${*echo \"foo\nbar\"}-baz"
+                               '("foo" "bar-baz"))
   ;; Concatenating to a number in a list should produce a number...
-  (should (equal (eshell-test-command-result "echo ${*echo \"1\n2\"}3")
-                 '(1 23)))
+  (eshell-command-result-equal "echo ${*echo \"1\n2\"}3"
+                               '(1 23))
   ;; ... but concatenating to a string that looks like a number in a list
   ;; should produce a string.
-  (should (equal (eshell-test-command-result "echo ${*echo \"hi\n2\"}3")
-                 '("hi" "23"))))
+  (eshell-command-result-equal "echo ${*echo \"hi\n2\"}3"
+                               '("hi" "23")))
 
 (ert-deftest esh-var-test/interp-concat-cmd2 ()
   "Interpolate and concat two commands"
-  (should (equal (eshell-test-command-result "+ ${+ 1 2}${+ 1 2} 3") 36)))
+  (eshell-command-result-equal "+ ${+ 1 2}${+ 1 2} 3" 36))
 
 (ert-deftest esh-var-test/interp-concat-cmd-external ()
   "Interpolate command result from external command with concatenation"
@@ -201,151 +195,128 @@ esh-var-test/interp-concat-cmd-external
 
 (ert-deftest esh-var-test/quoted-interp-var ()
   "Interpolate variable inside double-quotes"
-  (should (equal (eshell-test-command-result "echo \"$user-login-name\"")
-                 user-login-name)))
+  (eshell-command-result-equal "echo \"$user-login-name\""
+                               user-login-name))
 
 (ert-deftest esh-var-test/quoted-interp-quoted-var ()
   "Interpolate quoted variable inside double-quotes"
-  (should (equal (eshell-test-command-result
-                  "echo \"hi, $'user-login-name'\"")
-                 (concat "hi, " user-login-name)))
-  (should (equal (eshell-test-command-result
-                  "echo \"hi, $\\\"user-login-name\\\"\"")
-                 (concat "hi, " user-login-name))))
+  (eshell-command-result-equal "echo \"hi, $'user-login-name'\""
+                               (concat "hi, " user-login-name))
+  (eshell-command-result-equal "echo \"hi, $\\\"user-login-name\\\"\""
+                               (concat "hi, " user-login-name)))
 
 (ert-deftest esh-var-test/quoted-interp-var-indices ()
   "Interpolate string variable with indices inside double-quotes"
   (let ((eshell-test-value '("zero" "one" "two" "three" "four")))
-    (should (equal (eshell-test-command-result
-                    "echo \"$eshell-test-value[0]\"")
-                   "zero"))
+    (eshell-command-result-equal "echo \"$eshell-test-value[0]\""
+                                 "zero")
     ;; FIXME: These tests would use the 0th index like the other tests
     ;; here, but evaluating the command just above adds an `escaped'
     ;; property to the string "zero".  This results in the output
     ;; printing the string properties, which is probably the wrong
     ;; behavior.  See bug#54486.
-    (should (equal (eshell-test-command-result
-                    "echo \"$eshell-test-value[1 2]\"")
-                   "(\"one\" \"two\")"))
-    (should (equal (eshell-test-command-result
-                    "echo \"$eshell-test-value[1 2 4]\"")
-                   "(\"one\" \"two\" \"four\")"))))
+    (eshell-command-result-equal "echo \"$eshell-test-value[1 2]\""
+                                 "(\"one\" \"two\")")
+    (eshell-command-result-equal "echo \"$eshell-test-value[1 2 4]\""
+                                 "(\"one\" \"two\" \"four\")")))
 
 (ert-deftest esh-var-test/quoted-interp-var-split-indices ()
   "Interpolate string variable with indices inside double-quotes"
   (let ((eshell-test-value "zero one two three four"))
-    (should (equal (eshell-test-command-result
-                    "echo \"$eshell-test-value[0]\"")
-                   "zero"))
-    (should (equal (eshell-test-command-result
-                    "echo \"$eshell-test-value[0 2]\"")
-                   "(\"zero\" \"two\")"))))
+    (eshell-command-result-equal "echo \"$eshell-test-value[0]\""
+                                 "zero")
+    (eshell-command-result-equal "echo \"$eshell-test-value[0 2]\""
+                                 "(\"zero\" \"two\")")))
 
 (ert-deftest esh-var-test/quoted-interp-var-string-split-indices ()
   "Interpolate string variable with string splitter and indices
 inside double-quotes"
   (let ((eshell-test-value "zero:one:two:three:four"))
-    (should (equal (eshell-test-command-result
-                    "echo \"$eshell-test-value[: 0]\"")
-                   "zero"))
-    (should (equal (eshell-test-command-result
-                    "echo \"$eshell-test-value[: 0 2]\"")
-                   "(\"zero\" \"two\")")))
+    (eshell-command-result-equal "echo \"$eshell-test-value[: 0]\""
+                                 "zero")
+    (eshell-command-result-equal "echo \"$eshell-test-value[: 0 2]\""
+                                 "(\"zero\" \"two\")"))
   (let ((eshell-test-value "zeroXoneXtwoXthreeXfour"))
-    (should (equal (eshell-test-command-result
-                    "echo \"$eshell-test-value[X 0]\"")
-                   "zero"))
-    (should (equal (eshell-test-command-result
-                    "echo \"$eshell-test-value[X 0 2]\"")
-                   "(\"zero\" \"two\")"))))
+    (eshell-command-result-equal "echo \"$eshell-test-value[X 0]\""
+                                 "zero")
+    (eshell-command-result-equal "echo \"$eshell-test-value[X 0 2]\""
+                                 "(\"zero\" \"two\")")))
 
 (ert-deftest esh-var-test/quoted-interp-var-regexp-split-indices ()
   "Interpolate string variable with regexp splitter and indices"
   (let ((eshell-test-value "zero:one!two:three!four"))
-    (should (equal (eshell-test-command-result
-                    "echo \"$eshell-test-value['[:!]' 0]\"")
-                   "zero"))
-    (should (equal (eshell-test-command-result
-                    "echo \"$eshell-test-value['[:!]' 0 2]\"")
-                   "(\"zero\" \"two\")"))
-    (should (equal (eshell-test-command-result
-                    "echo \"$eshell-test-value[\\\"[:!]\\\" 0]\"")
-                   "zero"))
-    (should (equal (eshell-test-command-result
-                    "echo \"$eshell-test-value[\\\"[:!]\\\" 0 2]\"")
-                   "(\"zero\" \"two\")"))))
+    (eshell-command-result-equal "echo \"$eshell-test-value['[:!]' 0]\""
+                                 "zero")
+    (eshell-command-result-equal "echo \"$eshell-test-value['[:!]' 0 2]\""
+                                 "(\"zero\" \"two\")")
+    (eshell-command-result-equal "echo \"$eshell-test-value[\\\"[:!]\\\" 0]\""
+                                 "zero")
+    (eshell-command-result-equal
+     "echo \"$eshell-test-value[\\\"[:!]\\\" 0 2]\""
+     "(\"zero\" \"two\")")))
 
 (ert-deftest esh-var-test/quoted-interp-var-assoc ()
   "Interpolate alist variable with index inside double-quotes"
   (let ((eshell-test-value '(("foo" . 1))))
-    (should (equal (eshell-test-command-result
-                    "echo \"$eshell-test-value[foo]\"")
-                   "1"))))
+    (eshell-command-result-equal "echo \"$eshell-test-value[foo]\""
+                                 "1")))
 
 (ert-deftest esh-var-test/quoted-interp-var-length-list ()
   "Interpolate length of list variable inside double-quotes"
   (let ((eshell-test-value '((1 2) (3) (5 (6 7 8 9)))))
-    (should (equal (eshell-test-command-result "echo \"$#eshell-test-value\"")
-                   "3"))
-    (should (equal (eshell-test-command-result
-                    "echo \"$#eshell-test-value[1]\"")
-                   "1"))
-    (should (equal (eshell-test-command-result
-                    "echo \"$#eshell-test-value[2][1]\"")
-                   "4"))))
+    (eshell-command-result-equal "echo \"$#eshell-test-value\""
+                                 "3")
+    (eshell-command-result-equal "echo \"$#eshell-test-value[1]\""
+                                 "1")
+    (eshell-command-result-equal "echo \"$#eshell-test-value[2][1]\""
+                                 "4")))
 
 (ert-deftest esh-var-test/quoted-interp-var-length-string ()
   "Interpolate length of string variable inside double-quotes"
   (let ((eshell-test-value "foobar"))
-    (should (equal (eshell-test-command-result "echo \"$#eshell-test-value\"")
-                   "6"))))
+    (eshell-command-result-equal "echo \"$#eshell-test-value\""
+                                 "6")))
 
 (ert-deftest esh-var-test/quoted-interp-var-length-alist ()
   "Interpolate length of alist variable inside double-quotes"
   (let ((eshell-test-value '(("foo" . (1 2 3)))))
-    (should (equal (eshell-test-command-result "echo \"$#eshell-test-value\"")
-                   "1"))
-    (should (equal (eshell-test-command-result
-                    "echo \"$#eshell-test-value[foo]\"")
-                   "3"))))
+    (eshell-command-result-equal "echo \"$#eshell-test-value\""
+                                 "1")
+    (eshell-command-result-equal "echo \"$#eshell-test-value[foo]\""
+                                 "3"))
 
 (ert-deftest esh-var-test/quoted-interp-lisp ()
   "Interpolate Lisp form evaluation inside double-quotes"
-  (should (equal (eshell-test-command-result
-                  "echo \"hi $(concat \\\"the\\\" \\\"re\\\")\"")
-                 "hi there")))
+  (eshell-command-result-equal "echo \"hi $(concat \\\"the\\\" \\\"re\\\")\""
+                               "hi there"))
 
 (ert-deftest esh-var-test/quoted-interp-lisp-indices ()
   "Interpolate Lisp form evaluation with index"
-  (should (equal (eshell-test-command-result "concat \"$(list 1 2)[1]\" cool")
-                 "2cool")))
+  (eshell-command-result-equal "concat \"$(list 1 2)[1]\" cool"
+                               "2cool"))
 
 (ert-deftest esh-var-test/quoted-interp-cmd ()
   "Interpolate command result inside double-quotes"
-  (should (equal (eshell-test-command-result
-                  "echo \"hi ${echo \\\"there\\\"}\"")
-                 "hi there")))
+  (eshell-command-result-equal "echo \"hi ${echo \\\"there\\\"}\""
+                               "hi there"))
 
 (ert-deftest esh-var-test/quoted-interp-cmd-indices ()
   "Interpolate command result with index inside double-quotes"
-  (should (equal (eshell-test-command-result
-                  "concat \"${listify 1 2}[1]\" cool")
-                 "2cool")))
+  (eshell-command-result-equal "concat \"${listify 1 2}[1]\" cool"
+                               "2cool"))
 
 (ert-deftest esh-var-test/quoted-interp-temp-cmd ()
   "Interpolate command result redirected to temp file inside double-quotes"
   (let ((temporary-file-directory
          (file-name-as-directory (make-temp-file "esh-vars-tests" t))))
     (unwind-protect
-        (should (equal (eshell-test-command-result "cat \"$<echo hi>\"")
-                       "hi"))
+        (eshell-command-result-equal "cat \"$<echo hi>\"" "hi"))
       (delete-directory temporary-file-directory t))))
 
 (ert-deftest esh-var-test/quoted-interp-concat-cmd ()
   "Interpolate and concat command with literal"
-  (should (equal (eshell-test-command-result
-                  "echo \"${echo \\\"foo\nbar\\\"} baz\"")
-                 "foo\nbar baz")))
+  (eshell-command-result-equal "echo \"${echo \\\"foo\nbar\\\"} baz\""
+                               "foo\nbar baz"))
 
 \f
 ;; Interpolated variable conversion
@@ -353,139 +324,129 @@ esh-var-test/quoted-interp-concat-cmd
 (ert-deftest esh-var-test/interp-convert-var-number ()
   "Interpolate numeric variable"
   (let ((eshell-test-value 123))
-    (should (equal (eshell-test-command-result "type-of $eshell-test-value")
-                   'integer))))
+    (eshell-command-result-equal "type-of $eshell-test-value"
+                                 'integer)))
 
 (ert-deftest esh-var-test/interp-convert-var-split-indices ()
   "Interpolate and convert string variable with indices"
   ;; Check that numeric forms are converted to numbers.
   (let ((eshell-test-value "000 010 020 030 040"))
-    (should (equal (eshell-test-command-result "echo $eshell-test-value[0]")
-                   0))
-    (should (equal (eshell-test-command-result "echo $eshell-test-value[0 2]")
-                   '(0 20))))
+    (eshell-command-result-equal "echo $eshell-test-value[0]"
+                                 0)
+    (eshell-command-result-equal "echo $eshell-test-value[0 2]"
+                                 '(0 20)))
   ;; Check that multiline forms are preserved as-is.
   (let ((eshell-test-value "foo\nbar:baz\n"))
-    (should (equal (eshell-test-command-result "echo $eshell-test-value[: 0]")
-                   "foo\nbar"))
-    (should (equal (eshell-test-command-result "echo $eshell-test-value[: 1]")
-                   "baz\n"))))
+    (eshell-command-result-equal "echo $eshell-test-value[: 0]"
+                                 "foo\nbar")
+    (eshell-command-result-equal "echo $eshell-test-value[: 1]"
+                                 "baz\n")))
 
 (ert-deftest esh-var-test/interp-convert-quoted-var-number ()
   "Interpolate numeric quoted numeric variable"
   (let ((eshell-test-value 123))
-    (should (equal (eshell-test-command-result "type-of $'eshell-test-value'")
-                   'integer))
-    (should (equal (eshell-test-command-result "type-of $\"eshell-test-value\"")
-                   'integer))))
+    (eshell-command-result-equal "type-of $'eshell-test-value'"
+                                 'integer)
+    (eshell-command-result-equal "type-of $\"eshell-test-value\""
+                                 'integer)))
 
 (ert-deftest esh-var-test/interp-convert-quoted-var-split-indices ()
   "Interpolate and convert quoted string variable with indices"
   (let ((eshell-test-value "000 010 020 030 040"))
-    (should (equal (eshell-test-command-result "echo $'eshell-test-value'[0]")
-                   0))
-    (should (equal (eshell-test-command-result "echo $'eshell-test-value'[0 2]")
-                   '(0 20)))))
+    (eshell-command-result-equal "echo $'eshell-test-value'[0]"
+                                 0)
+    (eshell-command-result-equal "echo $'eshell-test-value'[0 2]"
+                                 '(0 20))))
 
 (ert-deftest esh-var-test/interp-convert-cmd-string-newline ()
   "Interpolate trailing-newline command result"
-  (should (equal (eshell-test-command-result "echo ${echo \"foo\n\"}") "foo")))
+  (eshell-command-result-equal "echo ${echo \"foo\n\"}" "foo"))
 
 (ert-deftest esh-var-test/interp-convert-cmd-multiline ()
   "Interpolate multi-line command result"
-  (should (equal (eshell-test-command-result "echo ${echo \"foo\nbar\"}")
-                 '("foo" "bar")))
+  (eshell-command-result-equal "echo ${echo \"foo\nbar\"}"
+                               '("foo" "bar"))
   ;; Numeric output should be converted to numbers...
-  (should (equal (eshell-test-command-result "echo ${echo \"01\n02\n03\"}")
-                 '(1 2 3)))
+  (eshell-command-result-equal "echo ${echo \"01\n02\n03\"}"
+                               '(1 2 3))
   ;; ... but only if every line is numeric.
-  (should (equal (eshell-test-command-result "echo ${echo \"01\n02\nhi\"}")
-                 '("01" "02" "hi"))))
+  (eshell-command-result-equal "echo ${echo \"01\n02\nhi\"}"
+                               '("01" "02" "hi")))
 
 (ert-deftest esh-var-test/interp-convert-cmd-number ()
   "Interpolate numeric command result"
-  (should (equal (eshell-test-command-result "echo ${echo \"1\"}") 1)))
+  (eshell-command-result-equal "echo ${echo \"1\"}" 1))
 
 (ert-deftest esh-var-test/interp-convert-cmd-split-indices ()
   "Interpolate command result with indices"
-  (should (equal (eshell-test-command-result "echo ${echo \"000 010 020\"}[0]")
-                 0))
-  (should (equal (eshell-test-command-result
-                  "echo ${echo \"000 010 020\"}[0 2]")
-                 '(0 20))))
+  (eshell-command-result-equal "echo ${echo \"000 010 020\"}[0]"
+                               0)
+  (eshell-command-result-equal "echo ${echo \"000 010 020\"}[0 2]"
+                               '(0 20)))
 
 (ert-deftest esh-var-test/quoted-interp-convert-var-number ()
   "Interpolate numeric variable inside double-quotes"
   (let ((eshell-test-value 123))
-    (should (equal (eshell-test-command-result "type-of \"$eshell-test-value\"")
-                   'string))))
+    (eshell-command-result-equal "type-of \"$eshell-test-value\""
+                                 'string)))
 
 (ert-deftest esh-var-test/quoted-interp-convert-var-split-indices ()
   "Interpolate string variable with indices inside double-quotes"
   (let ((eshell-test-value "000 010 020 030 040"))
-    (should (equal (eshell-test-command-result
-                    "echo \"$eshell-test-value[0]\"")
-                   "000"))
-    (should (equal (eshell-test-command-result
-                    "echo \"$eshell-test-value[0 2]\"")
-                   "(\"000\" \"020\")"))))
+    (eshell-command-result-equal "echo \"$eshell-test-value[0]\""
+                                 "000")
+    (eshell-command-result-equal "echo \"$eshell-test-value[0 2]\""
+                                 "(\"000\" \"020\")")))
 
 (ert-deftest esh-var-test/quoted-interp-convert-quoted-var-number ()
   "Interpolate numeric quoted variable inside double-quotes"
   (let ((eshell-test-value 123))
-    (should (equal (eshell-test-command-result
-                    "type-of \"$'eshell-test-value'\"")
-                   'string))
-    (should (equal (eshell-test-command-result
-                    "type-of \"$\\\"eshell-test-value\\\"\"")
-                   'string))))
+    (eshell-command-result-equal "type-of \"$'eshell-test-value'\""
+                                 'string)
+    (eshell-command-result-equal "type-of \"$\\\"eshell-test-value\\\"\""
+                                 'string)))
 
 (ert-deftest esh-var-test/quoted-interp-convert-quoted-var-split-indices ()
   "Interpolate quoted string variable with indices inside double-quotes"
   (let ((eshell-test-value "000 010 020 030 040"))
-    (should (equal (eshell-test-command-result
-                    "echo \"$eshell-test-value[0]\"")
-                   "000"))
-    (should (equal (eshell-test-command-result
-                    "echo \"$eshell-test-value[0 2]\"")
-                   "(\"000\" \"020\")"))))
+    (eshell-command-result-equal "echo \"$eshell-test-value[0]\""
+                                 "000")
+    (eshell-command-result-equal "echo \"$eshell-test-value[0 2]\""
+                                 "(\"000\" \"020\")")))
 
 (ert-deftest esh-var-test/quoted-interp-convert-cmd-string-newline ()
   "Interpolate trailing-newline command result inside double-quotes"
-  (should (equal (eshell-test-command-result "echo \"${echo \\\"foo\n\\\"}\"")
-                 "foo"))
-  (should (equal (eshell-test-command-result "echo \"${echo \\\"foo\n\n\\\"}\"")
-                 "foo")))
+  (eshell-command-result-equal "echo \"${echo \\\"foo\n\\\"}\""
+                               "foo")
+  (eshell-command-result-equal "echo \"${echo \\\"foo\n\n\\\"}\""
+                               "foo"))
 
 (ert-deftest esh-var-test/quoted-interp-convert-cmd-multiline ()
   "Interpolate multi-line command result inside double-quotes"
-  (should (equal (eshell-test-command-result
-                  "echo \"${echo \\\"foo\nbar\\\"}\"")
-                 "foo\nbar")))
+  (eshell-command-result-equal "echo \"${echo \\\"foo\nbar\\\"}\""
+                               "foo\nbar"))
 
 (ert-deftest esh-var-test/quoted-interp-convert-cmd-number ()
   "Interpolate numeric command result inside double-quotes"
-  (should (equal (eshell-test-command-result "echo \"${echo \\\"1\\\"}\"")
-                 "1")))
+  (eshell-command-result-equal "echo \"${echo \\\"1\\\"}\"" "1"))
 
 (ert-deftest esh-var-test/quoted-interp-convert-cmd-split-indices ()
   "Interpolate command result with indices inside double-quotes"
-  (should (equal (eshell-test-command-result
-                  "echo \"${echo \\\"000 010 020\\\"}[0]\"")
-                 "000")))
+  (eshell-command-result-equal "echo \"${echo \\\"000 010 020\\\"}[0]\""
+                               "000"))
 
 \f
 ;; Built-in variables
 
 (ert-deftest esh-var-test/lines-var ()
   "$LINES should equal (window-body-height nil 'remap)"
-  (should (equal (eshell-test-command-result "echo $LINES")
-                 (window-body-height nil 'remap))))
+  (eshell-command-result-equal "echo $LINES"
+                               (window-body-height nil 'remap)))
 
 (ert-deftest esh-var-test/columns-var ()
   "$COLUMNS should equal (window-body-width nil 'remap)"
-  (should (equal (eshell-test-command-result "echo $COLUMNS")
-                 (window-body-width nil 'remap))))
+  (eshell-command-result-equal "echo $COLUMNS"
+                               (window-body-width nil 'remap)))
 
 (ert-deftest esh-var-test/inside-emacs-var ()
   "Test presence of \"INSIDE_EMACS\" in subprocesses"
diff --git a/test/lisp/eshell/eshell-tests-helpers.el b/test/lisp/eshell/eshell-tests-helpers.el
index 778087bd75..8f0f993447 100644
--- a/test/lisp/eshell/eshell-tests-helpers.el
+++ b/test/lisp/eshell/eshell-tests-helpers.el
@@ -104,6 +104,27 @@ eshell-test-command-result
     (let ((eshell-history-file-name nil))
       (eshell-command-result command))))
 
+(defun eshell-command-result--equal (_command actual expected)
+  "Compare the ACTUAL result of a COMMAND with its EXPECTED value."
+  (equal actual expected))
+
+(defun eshell-command-result--equal-explainer (command actual expected)
+  "Explain the result of `eshell-command-result--equal'."
+  `(nonequal-result
+    (command ,command)
+    (result ,actual)
+    (expected ,expected)))
+
+(put 'eshell-command-result--equal 'ert-explainer
+     #'eshell-command-result--equal-explainer)
+
+(defun eshell-command-result-equal (command result)
+  "Execute COMMAND non-interactively and compare it to RESULT."
+  (should (eshell-command-result--equal
+           command
+           (eshell-test-command-result command)
+           result)))
+
 (provide 'eshell-tests-helpers)
 
 ;;; eshell-tests-helpers.el ends here
diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el
index c7a9516bea..1845dba280 100644
--- a/test/lisp/eshell/eshell-tests.el
+++ b/test/lisp/eshell/eshell-tests.el
@@ -83,28 +83,27 @@ eshell-test/subcommand-reset-in-pipeline
   (dolist (template '("echo {%s} | *cat"
                       "echo ${%s} | *cat"
                       "*cat $<%s> | *cat"))
-    (should (equal (eshell-test-command-result
-                    (format template "echo $eshell-in-pipeline-p"))
-                   nil))
-    (should (equal (eshell-test-command-result
-                    (format template "echo | echo $eshell-in-pipeline-p"))
-                   "last"))
-    (should (equal (eshell-test-command-result
-                    (format template "echo $eshell-in-pipeline-p | echo"))
-                   "first"))
-    (should (equal (eshell-test-command-result
-                    (format template
-                            "echo | echo $eshell-in-pipeline-p | echo"))
-                   "t"))))
+    (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"))
-    (should (equal (eshell-test-command-result
-                    (format template "format \"%s\" eshell-in-pipeline-p"))
-                   "nil"))))
+    (eshell-command-result-equal
+     (format template "format \"%s\" eshell-in-pipeline-p")
+     "nil")))
 
 (ert-deftest eshell-test/redirect-buffer ()
   "Check that piping to a buffer works"
-- 
2.25.1


[-- Attachment #4: 0003-Fix-non-interactive-use-of-conditionals-in-Eshell.patch --]
[-- Type: text/plain, Size: 9715 bytes --]

From 84efea337e1ea0545717dd2c96d3622ea94ff421 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sun, 14 Aug 2022 13:48:22 -0700
Subject: [PATCH 3/3] Fix non-interactive use of conditionals in Eshell

* lisp/eshell/esh-cmd.el (eshell-rewrite-if-command): Fix misplaced
't' symbol; it should be passed to 'eshell-invokify-arg'.
(eshell-do-eval): Pass 'synchronous-p' to recursive calls in some
missing cases.

* test/lisp/eshell/esh-cmd-tests.el (esh-cmd-test/if-statement,
(esh-cmd-test/if-else-statement)
(esh-cmd-test/if-else-statement-lisp-form)
(esh-cmd-test/if-else-statement-lisp-form-2)
(esh-cmd-test/if-else-statement-ext-cmd)
(esh-cmd-test/unless-statement)
(esh-cmd-test/unless-else-statement)
(esh-cmd-test/unless-else-statement-lisp-form)
(esh-cmd-test/unless-else-statement-ext-cmd): Use
'eshell-command-result-equal'.
---
 lisp/eshell/esh-cmd.el            |   7 +-
 test/lisp/eshell/esh-cmd-tests.el | 119 ++++++++++++++----------------
 2 files changed, 59 insertions(+), 67 deletions(-)

diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el
index 62c95056fd..2f77f3f497 100644
--- a/lisp/eshell/esh-cmd.el
+++ b/lisp/eshell/esh-cmd.el
@@ -607,7 +607,7 @@ eshell-rewrite-if-command
                                t))
        (if (= (length terms) 4)
 	   `(eshell-protect
-             ,(eshell-invokify-arg (car (last terms)))) t))))
+             ,(eshell-invokify-arg (car (last terms)) t))))))
 
 (defvar eshell-last-command-result)     ;Defined in esh-io.el.
 
@@ -1122,7 +1122,7 @@ eshell-do-eval
 	  (setcar eshell-test-body nil))
 	(unless (car eshell-test-body)
           (setcar eshell-test-body (copy-tree (car args))))
-	(while (cadr (eshell-do-eval (car eshell-test-body)))
+	(while (cadr (eshell-do-eval (car eshell-test-body) synchronous-p))
 	  (setcar eshell-command-body
                   (if (cddr args)
                       `(progn ,@(copy-tree (cdr args)))
@@ -1142,7 +1142,8 @@ eshell-do-eval
             (setcar eshell-test-body (copy-tree (car args))))
 	  (setcar eshell-command-body
                   (copy-tree
-                   (if (cadr (eshell-do-eval (car eshell-test-body)))
+                   (if (cadr (eshell-do-eval (car eshell-test-body)
+                                             synchronous-p))
                        (cadr args)
                      (car (cddr args)))))
 	  (eshell-do-eval (car eshell-command-body) synchronous-p))
diff --git a/test/lisp/eshell/esh-cmd-tests.el b/test/lisp/eshell/esh-cmd-tests.el
index c5d780a399..3a582965d6 100644
--- a/test/lisp/eshell/esh-cmd-tests.el
+++ b/test/lisp/eshell/esh-cmd-tests.el
@@ -188,97 +188,88 @@ esh-cmd-test/until-loop-ext-cmd
 
 (ert-deftest esh-cmd-test/if-statement ()
   "Test invocation of an if statement."
-  (with-temp-eshell
-   (let ((eshell-test-value t))
-     (eshell-match-command-output "if $eshell-test-value {echo yes}"
-                                  "yes\n"))
-   (let ((eshell-test-value nil))
-     (eshell-match-command-output "if $eshell-test-value {echo yes}"
-                                  "\\`\\'"))))
+  (let ((eshell-test-value t))
+    (eshell-command-result-equal "if $eshell-test-value {echo yes}"
+                                 "yes"))
+  (let ((eshell-test-value nil))
+    (eshell-command-result-equal "if $eshell-test-value {echo yes}"
+                                 nil)))
 
 (ert-deftest esh-cmd-test/if-else-statement ()
   "Test invocation of an if/else statement."
-  (with-temp-eshell
-   (let ((eshell-test-value t))
-     (eshell-match-command-output "if $eshell-test-value {echo yes} {echo no}"
-                                  "yes\n"))
-   (let ((eshell-test-value nil))
-     (eshell-match-command-output "if $eshell-test-value {echo yes} {echo no}"
-                                  "no\n"))))
+  (let ((eshell-test-value t))
+    (eshell-command-result-equal "if $eshell-test-value {echo yes} {echo no}"
+                                 "yes"))
+  (let ((eshell-test-value nil))
+    (eshell-command-result-equal "if $eshell-test-value {echo yes} {echo no}"
+                                 "no")))
 
 (ert-deftest esh-cmd-test/if-else-statement-lisp-form ()
   "Test invocation of an if/else statement using a Lisp form."
-  (with-temp-eshell
-   (eshell-match-command-output "if (zerop 0) {echo yes} {echo no}"
-                                "yes\n")
-   (eshell-match-command-output "if (zerop 1) {echo yes} {echo no}"
-                                "no\n")
-   (let ((debug-on-error nil))
-     (eshell-match-command-output "if (zerop \"foo\") {echo yes} {echo no}"
-                                  "no\n"))))
+  (eshell-command-result-equal "if (zerop 0) {echo yes} {echo no}"
+                               "yes")
+  (eshell-command-result-equal "if (zerop 1) {echo yes} {echo no}"
+                               "no")
+  (let ((debug-on-error nil))
+    (eshell-command-result-equal "if (zerop \"foo\") {echo yes} {echo no}"
+                                 "no")))
 
 (ert-deftest esh-cmd-test/if-else-statement-lisp-form-2 ()
   "Test invocation of an if/else statement using a Lisp form.
 This tests when `eshell-lisp-form-nil-is-failure' is nil."
   (let ((eshell-lisp-form-nil-is-failure nil))
-    (with-temp-eshell
-     (eshell-match-command-output "if (zerop 0) {echo yes} {echo no}"
-                                  "yes\n")
-     (eshell-match-command-output "if (zerop 1) {echo yes} {echo no}"
-                                  "yes\n")
-     (let ((debug-on-error nil))
-       (eshell-match-command-output "if (zerop \"foo\") {echo yes} {echo no}"
-                                    "no\n")))))
+    (eshell-command-result-equal "if (zerop 0) {echo yes} {echo no}"
+                                 "yes")
+    (eshell-command-result-equal "if (zerop 1) {echo yes} {echo no}"
+                                 "yes")
+    (let ((debug-on-error nil))
+      (eshell-command-result-equal "if (zerop \"foo\") {echo yes} {echo no}"
+                                   "no"))))
 
 (ert-deftest esh-cmd-test/if-else-statement-ext-cmd ()
   "Test invocation of an if/else statement using an external command."
   (skip-unless (executable-find "["))
-  (with-temp-eshell
-   (eshell-match-command-output "if {[ foo = foo ]} {echo yes} {echo no}"
-                                "yes\n")
-   (eshell-match-command-output "if {[ foo = bar ]} {echo yes} {echo no}"
-                                "no\n")))
+  (eshell-command-result-equal "if {[ foo = foo ]} {echo yes} {echo no}"
+                               "yes")
+  (eshell-command-result-equal "if {[ foo = bar ]} {echo yes} {echo no}"
+                               "no"))
 
 (ert-deftest esh-cmd-test/unless-statement ()
   "Test invocation of an unless statement."
-  (with-temp-eshell
-   (let ((eshell-test-value t))
-     (eshell-match-command-output "unless $eshell-test-value {echo no}"
-                                  "\\`\\'"))
-   (let ((eshell-test-value nil))
-     (eshell-match-command-output "unless $eshell-test-value {echo no}"
-                                  "no\n"))))
+  (let ((eshell-test-value t))
+    (eshell-command-result-equal "unless $eshell-test-value {echo no}"
+                                 nil))
+  (let ((eshell-test-value nil))
+    (eshell-command-result-equal "unless $eshell-test-value {echo no}"
+                                 "no")))
 
 (ert-deftest esh-cmd-test/unless-else-statement ()
   "Test invocation of an unless/else statement."
-  (with-temp-eshell
-   (let ((eshell-test-value t))
-     (eshell-match-command-output
-      "unless $eshell-test-value {echo no} {echo yes}"
-      "yes\n"))
-   (let ((eshell-test-value nil))
-     (eshell-match-command-output
-      "unless $eshell-test-value {echo no} {echo yes}"
-      "no\n"))))
+  (let ((eshell-test-value t))
+    (eshell-command-result-equal
+     "unless $eshell-test-value {echo no} {echo yes}"
+     "yes"))
+  (let ((eshell-test-value nil))
+    (eshell-command-result-equal
+     "unless $eshell-test-value {echo no} {echo yes}"
+     "no")))
 
 (ert-deftest esh-cmd-test/unless-else-statement-lisp-form ()
   "Test invocation of an unless/else statement using a Lisp form."
-  (with-temp-eshell
-   (eshell-match-command-output "unless (zerop 0) {echo no} {echo yes}"
-                                "yes\n")
-   (eshell-match-command-output "unless (zerop 1) {echo no} {echo yes}"
-                                "no\n")
-   (let ((debug-on-error nil))
-     (eshell-match-command-output "unless (zerop \"foo\") {echo no} {echo yes}"
-                                  "no\n"))))
+  (eshell-command-result-equal "unless (zerop 0) {echo no} {echo yes}"
+                               "yes")
+  (eshell-command-result-equal "unless (zerop 1) {echo no} {echo yes}"
+                               "no")
+  (let ((debug-on-error nil))
+    (eshell-command-result-equal "unless (zerop \"foo\") {echo no} {echo yes}"
+                                 "no")))
 
 (ert-deftest esh-cmd-test/unless-else-statement-ext-cmd ()
   "Test invocation of an unless/else statement using an external command."
   (skip-unless (executable-find "["))
-  (with-temp-eshell
-   (eshell-match-command-output "unless {[ foo = foo ]} {echo no} {echo yes}"
-                                "yes\n")
-   (eshell-match-command-output "unless {[ foo = bar ]} {echo no} {echo yes}"
-                                "no\n")))
+  (eshell-command-result-equal "unless {[ foo = foo ]} {echo no} {echo yes}"
+                               "yes")
+  (eshell-command-result-equal "unless {[ foo = bar ]} {echo no} {echo yes}"
+                               "no"))
 
 ;; esh-cmd-tests.el ends here
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#57216: 29.0.50; [PATCH] Provide ERT explainers for Eshell test functions
  2022-08-14 21:20 bug#57216: 29.0.50; [PATCH] Provide ERT explainers for Eshell test functions Jim Porter
@ 2022-08-15  7:01 ` Lars Ingebrigtsen
  2022-08-16  3:52   ` Jim Porter
  2022-08-15 11:12 ` Eli Zaretskii
  1 sibling, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2022-08-15  7:01 UTC (permalink / raw)
  To: Jim Porter; +Cc: eliz, 57216

Jim Porter <jporterbugs@gmail.com> writes:

> It can be difficult to diagnose test failures in the Eshell ERT test
> suite, since it doesn't print useful details like the command that was
> executed. See bug#57129 for example.

I'm generally not in favour of making ert tests less trivial (because
that makes dealing with them less easy if you're not familiar with the
specific harness), but in this case, it makes sense, I think.

> Most of the first two patches are purely-mechanical changes to update
> function calls. The diffs ended up being pretty big, but I think it
> improves matters. Let me know if I should do it differently
> (especially for the commit message; I didn't see much benefit to
> listing *every* test function I touched, but maybe I should do that?)

Looks OK to me -- we don't really follow the ChangeLog conventions for
the tests much.






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#57216: 29.0.50; [PATCH] Provide ERT explainers for Eshell test functions
  2022-08-14 21:20 bug#57216: 29.0.50; [PATCH] Provide ERT explainers for Eshell test functions Jim Porter
  2022-08-15  7:01 ` Lars Ingebrigtsen
@ 2022-08-15 11:12 ` Eli Zaretskii
  2022-08-16  3:49   ` Jim Porter
  1 sibling, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2022-08-15 11:12 UTC (permalink / raw)
  To: Jim Porter; +Cc: 57216

> From: Jim Porter <jporterbugs@gmail.com>
> Cc: eliz@gnu.org
> Date: Sun, 14 Aug 2022 14:20:25 -0700
> 
> It can be difficult to diagnose test failures in the Eshell ERT test 
> suite, since it doesn't print useful details like the command that was 
> executed. See bug#57129 for example.
> 
> Here are some patches to fix that. The failures now look like this:

Looks good, thank you very much for working on this important aspect
of the test suite.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#57216: 29.0.50; [PATCH] Provide ERT explainers for Eshell test functions
  2022-08-15 11:12 ` Eli Zaretskii
@ 2022-08-16  3:49   ` Jim Porter
  0 siblings, 0 replies; 5+ messages in thread
From: Jim Porter @ 2022-08-16  3:49 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 57216

On 8/15/2022 4:12 AM, Eli Zaretskii wrote:
> Looks good, thank you very much for working on this important aspect
> of the test suite.

Thanks, merged as cf873c1a090b95746cf2f2a9a24a5e4bd7cc2cd6.

Note that you might need to remove the *.elc files in test/lisp/eshell, 
since I updated eshell-tests-helpers.el, and the Makefiles aren't smart 
enough to recompile that before any of the tests.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#57216: 29.0.50; [PATCH] Provide ERT explainers for Eshell test functions
  2022-08-15  7:01 ` Lars Ingebrigtsen
@ 2022-08-16  3:52   ` Jim Porter
  0 siblings, 0 replies; 5+ messages in thread
From: Jim Porter @ 2022-08-16  3:52 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: eliz, 57216-done

On 8/15/2022 12:01 AM, Lars Ingebrigtsen wrote:
> Jim Porter <jporterbugs@gmail.com> writes:
> 
>> It can be difficult to diagnose test failures in the Eshell ERT test
>> suite, since it doesn't print useful details like the command that was
>> executed. See bug#57129 for example.
> 
> I'm generally not in favour of making ert tests less trivial (because
> that makes dealing with them less easy if you're not familiar with the
> specific harness), but in this case, it makes sense, I think.

Agreed. I've tried to keep the tests as simple as I can, though even for 
the simplest of the Eshell tests, I think it's useful to show this info. 
  99% of the tests are "run some Eshell command and make sure it does 
the right thing", and if it fails, the new failure output is probably 
enough to debug it without even looking at the test code.

(Closing this, since I merged the patch.)





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-16  3:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-14 21:20 bug#57216: 29.0.50; [PATCH] Provide ERT explainers for Eshell test functions Jim Porter
2022-08-15  7:01 ` Lars Ingebrigtsen
2022-08-16  3:52   ` Jim Porter
2022-08-15 11:12 ` Eli Zaretskii
2022-08-16  3:49   ` Jim Porter

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.