diff options
author | Jim Porter <jporterbugs@gmail.com> | 2022-08-14 13:48:22 -0700 |
---|---|---|
committer | Jim Porter <jporterbugs@gmail.com> | 2022-08-15 20:40:27 -0700 |
commit | cf873c1a090b95746cf2f2a9a24a5e4bd7cc2cd6 (patch) | |
tree | 5e8c9eb3498242e5f6fe208fdcb6b01dda0f47a4 /test | |
parent | c1f1be4b73072440518f02356998cf58ba127ebd (diff) | |
download | emacs-cf873c1a090b95746cf2f2a9a24a5e4bd7cc2cd6.tar.gz emacs-cf873c1a090b95746cf2f2a9a24a5e4bd7cc2cd6.tar.bz2 emacs-cf873c1a090b95746cf2f2a9a24a5e4bd7cc2cd6.zip |
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'.
Diffstat (limited to 'test')
-rw-r--r-- | test/lisp/eshell/esh-cmd-tests.el | 119 |
1 files changed, 55 insertions, 64 deletions
diff --git a/test/lisp/eshell/esh-cmd-tests.el b/test/lisp/eshell/esh-cmd-tests.el index c5d780a399d..3a582965d62 100644 --- a/test/lisp/eshell/esh-cmd-tests.el +++ b/test/lisp/eshell/esh-cmd-tests.el @@ -188,97 +188,88 @@ e.g. \"{(+ 1 2)} 3\" => 3" (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 |