diff options
Diffstat (limited to 'test/lisp/eshell')
| -rw-r--r-- | test/lisp/eshell/esh-cmd-tests.el | 283 | ||||
| -rw-r--r-- | test/lisp/eshell/esh-var-tests.el | 59 | ||||
| -rw-r--r-- | test/lisp/eshell/eshell-tests.el | 53 |
3 files changed, 341 insertions, 54 deletions
diff --git a/test/lisp/eshell/esh-cmd-tests.el b/test/lisp/eshell/esh-cmd-tests.el new file mode 100644 index 00000000000..e86985ec717 --- /dev/null +++ b/test/lisp/eshell/esh-cmd-tests.el | |||
| @@ -0,0 +1,283 @@ | |||
| 1 | ;;; esh-cmd-tests.el --- esh-cmd test suite -*- lexical-binding:t -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2022 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 10 | ;; (at your option) any later version. | ||
| 11 | |||
| 12 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | ;;; Commentary: | ||
| 21 | |||
| 22 | ;; Tests for Eshell's command invocation. | ||
| 23 | |||
| 24 | ;;; Code: | ||
| 25 | |||
| 26 | (require 'ert) | ||
| 27 | (require 'esh-mode) | ||
| 28 | (require 'eshell) | ||
| 29 | |||
| 30 | (require 'eshell-tests-helpers | ||
| 31 | (expand-file-name "eshell-tests-helpers" | ||
| 32 | (file-name-directory (or load-file-name | ||
| 33 | default-directory)))) | ||
| 34 | |||
| 35 | (defvar eshell-test-value nil) | ||
| 36 | |||
| 37 | ;;; Tests: | ||
| 38 | |||
| 39 | |||
| 40 | ;; Command invocation | ||
| 41 | |||
| 42 | (ert-deftest esh-cmd-test/simple-command-result () | ||
| 43 | "Test invocation with a simple command." | ||
| 44 | (should (equal (eshell-test-command-result "+ 1 2") 3))) | ||
| 45 | |||
| 46 | (ert-deftest esh-cmd-test/lisp-command () | ||
| 47 | "Test invocation with an elisp command." | ||
| 48 | (should (equal (eshell-test-command-result "(+ 1 2)") 3))) | ||
| 49 | |||
| 50 | (ert-deftest esh-cmd-test/lisp-command-with-quote () | ||
| 51 | "Test invocation with an elisp command containing a quote." | ||
| 52 | (should (equal (eshell-test-command-result "(eq 'foo nil)") nil))) | ||
| 53 | |||
| 54 | (ert-deftest esh-cmd-test/lisp-command-args () | ||
| 55 | "Test invocation with elisp and trailing args. | ||
| 56 | Test that trailing arguments outside the S-expression are | ||
| 57 | ignored. e.g. \"(+ 1 2) 3\" => 3" | ||
| 58 | (should (equal (eshell-test-command-result "(+ 1 2) 3") 3))) | ||
| 59 | |||
| 60 | (ert-deftest esh-cmd-test/subcommand () | ||
| 61 | "Test invocation with a simple subcommand." | ||
| 62 | (should (equal (eshell-test-command-result "{+ 1 2}") 3))) | ||
| 63 | |||
| 64 | (ert-deftest esh-cmd-test/subcommand-args () | ||
| 65 | "Test invocation with a subcommand and trailing args. | ||
| 66 | Test that trailing arguments outside the subcommand are ignored. | ||
| 67 | e.g. \"{+ 1 2} 3\" => 3" | ||
| 68 | (should (equal (eshell-test-command-result "{+ 1 2} 3") 3))) | ||
| 69 | |||
| 70 | (ert-deftest esh-cmd-test/subcommand-lisp () | ||
| 71 | "Test invocation with an elisp subcommand and trailing args. | ||
| 72 | Test that trailing arguments outside the subcommand are ignored. | ||
| 73 | e.g. \"{(+ 1 2)} 3\" => 3" | ||
| 74 | (should (equal (eshell-test-command-result "{(+ 1 2)} 3") 3))) | ||
| 75 | |||
| 76 | |||
| 77 | ;; Logical operators | ||
| 78 | |||
| 79 | (ert-deftest esh-cmd-test/and-operator () | ||
| 80 | "Test logical && operator." | ||
| 81 | (skip-unless (executable-find "[")) | ||
| 82 | (with-temp-eshell | ||
| 83 | (eshell-command-result-p "[ foo = foo ] && echo hi" | ||
| 84 | "hi\n") | ||
| 85 | (eshell-command-result-p "[ foo = bar ] && echo hi" | ||
| 86 | "\\`\\'"))) | ||
| 87 | |||
| 88 | (ert-deftest esh-cmd-test/or-operator () | ||
| 89 | "Test logical || operator." | ||
| 90 | (skip-unless (executable-find "[")) | ||
| 91 | (with-temp-eshell | ||
| 92 | (eshell-command-result-p "[ foo = foo ] || echo hi" | ||
| 93 | "\\`\\'") | ||
| 94 | (eshell-command-result-p "[ foo = bar ] || echo hi" | ||
| 95 | "hi\n"))) | ||
| 96 | |||
| 97 | |||
| 98 | ;; Control flow statements | ||
| 99 | |||
| 100 | (ert-deftest esh-cmd-test/for-loop () | ||
| 101 | "Test invocation of a for loop." | ||
| 102 | (with-temp-eshell | ||
| 103 | (eshell-command-result-p "for i in 5 { echo $i }" | ||
| 104 | "5\n"))) | ||
| 105 | |||
| 106 | (ert-deftest esh-cmd-test/for-loop-list () | ||
| 107 | "Test invocation of a for loop iterating over a list." | ||
| 108 | (with-temp-eshell | ||
| 109 | (eshell-command-result-p "for i in (list 1 2 (list 3 4)) { echo $i }" | ||
| 110 | "1\n2\n(3 4)\n"))) | ||
| 111 | |||
| 112 | (ert-deftest esh-cmd-test/for-loop-multiple-args () | ||
| 113 | "Test invocation of a for loop iterating over multiple arguments." | ||
| 114 | (with-temp-eshell | ||
| 115 | (eshell-command-result-p "for i in 1 2 (list 3 4) { echo $i }" | ||
| 116 | "1\n2\n3\n4\n"))) | ||
| 117 | |||
| 118 | (ert-deftest esh-cmd-test/for-name-loop () ; bug#15231 | ||
| 119 | "Test invocation of a for loop using `name'." | ||
| 120 | (let ((process-environment (cons "name" process-environment))) | ||
| 121 | (should (equal (eshell-test-command-result | ||
| 122 | "for name in 3 { echo $name }") | ||
| 123 | 3)))) | ||
| 124 | |||
| 125 | (ert-deftest esh-cmd-test/for-name-shadow-loop () ; bug#15372 | ||
| 126 | "Test invocation of a for loop using an env-var." | ||
| 127 | (let ((process-environment (cons "name=env-value" process-environment))) | ||
| 128 | (with-temp-eshell | ||
| 129 | (eshell-command-result-p | ||
| 130 | "echo $name; for name in 3 { echo $name }; echo $name" | ||
| 131 | "env-value\n3\nenv-value\n")))) | ||
| 132 | |||
| 133 | (ert-deftest esh-cmd-test/while-loop () | ||
| 134 | "Test invocation of a while loop." | ||
| 135 | (with-temp-eshell | ||
| 136 | (let ((eshell-test-value '(0 1 2))) | ||
| 137 | (eshell-command-result-p | ||
| 138 | (concat "while $eshell-test-value " | ||
| 139 | "{ setq eshell-test-value (cdr eshell-test-value) }") | ||
| 140 | "(1 2)\n(2)\n")))) | ||
| 141 | |||
| 142 | (ert-deftest esh-cmd-test/while-loop-lisp-form () | ||
| 143 | "Test invocation of a while loop using a Lisp form." | ||
| 144 | (with-temp-eshell | ||
| 145 | (let ((eshell-test-value 0)) | ||
| 146 | (eshell-command-result-p | ||
| 147 | (concat "while (/= eshell-test-value 3) " | ||
| 148 | "{ setq eshell-test-value (1+ eshell-test-value) }") | ||
| 149 | "1\n2\n3\n")))) | ||
| 150 | |||
| 151 | (ert-deftest esh-cmd-test/while-loop-ext-cmd () | ||
| 152 | "Test invocation of a while loop using an external command." | ||
| 153 | (skip-unless (executable-find "[")) | ||
| 154 | (with-temp-eshell | ||
| 155 | (let ((eshell-test-value 0)) | ||
| 156 | (eshell-command-result-p | ||
| 157 | (concat "while {[ $eshell-test-value -ne 3 ]} " | ||
| 158 | "{ setq eshell-test-value (1+ eshell-test-value) }") | ||
| 159 | "1\n2\n3\n")))) | ||
| 160 | |||
| 161 | (ert-deftest esh-cmd-test/until-loop () | ||
| 162 | "Test invocation of an until loop." | ||
| 163 | (with-temp-eshell | ||
| 164 | (let ((eshell-test-value nil)) | ||
| 165 | (eshell-command-result-p | ||
| 166 | (concat "until $eshell-test-value " | ||
| 167 | "{ setq eshell-test-value t }") | ||
| 168 | "t\n")))) | ||
| 169 | |||
| 170 | (ert-deftest esh-cmd-test/until-loop-lisp-form () | ||
| 171 | "Test invocation of an until loop using a Lisp form." | ||
| 172 | (skip-unless (executable-find "[")) | ||
| 173 | (with-temp-eshell | ||
| 174 | (let ((eshell-test-value 0)) | ||
| 175 | (eshell-command-result-p | ||
| 176 | (concat "until (= eshell-test-value 3) " | ||
| 177 | "{ setq eshell-test-value (1+ eshell-test-value) }") | ||
| 178 | "1\n2\n3\n")))) | ||
| 179 | |||
| 180 | (ert-deftest esh-cmd-test/until-loop-ext-cmd () | ||
| 181 | "Test invocation of an until loop using an external command." | ||
| 182 | (skip-unless (executable-find "[")) | ||
| 183 | (with-temp-eshell | ||
| 184 | (let ((eshell-test-value 0)) | ||
| 185 | (eshell-command-result-p | ||
| 186 | (concat "until {[ $eshell-test-value -eq 3 ]} " | ||
| 187 | "{ setq eshell-test-value (1+ eshell-test-value) }") | ||
| 188 | "1\n2\n3\n")))) | ||
| 189 | |||
| 190 | (ert-deftest esh-cmd-test/if-statement () | ||
| 191 | "Test invocation of an if statement." | ||
| 192 | (with-temp-eshell | ||
| 193 | (let ((eshell-test-value t)) | ||
| 194 | (eshell-command-result-p "if $eshell-test-value {echo yes}" | ||
| 195 | "yes\n")) | ||
| 196 | (let ((eshell-test-value nil)) | ||
| 197 | (eshell-command-result-p "if $eshell-test-value {echo yes}" | ||
| 198 | "\\`\\'")))) | ||
| 199 | |||
| 200 | (ert-deftest esh-cmd-test/if-else-statement () | ||
| 201 | "Test invocation of an if/else statement." | ||
| 202 | (with-temp-eshell | ||
| 203 | (let ((eshell-test-value t)) | ||
| 204 | (eshell-command-result-p "if $eshell-test-value {echo yes} {echo no}" | ||
| 205 | "yes\n")) | ||
| 206 | (let ((eshell-test-value nil)) | ||
| 207 | (eshell-command-result-p "if $eshell-test-value {echo yes} {echo no}" | ||
| 208 | "no\n")))) | ||
| 209 | |||
| 210 | (ert-deftest esh-cmd-test/if-else-statement-lisp-form () | ||
| 211 | "Test invocation of an if/else statement using a Lisp form." | ||
| 212 | (with-temp-eshell | ||
| 213 | (eshell-command-result-p "if (zerop 0) {echo yes} {echo no}" | ||
| 214 | "yes\n") | ||
| 215 | (eshell-command-result-p "if (zerop 1) {echo yes} {echo no}" | ||
| 216 | "no\n") | ||
| 217 | (let ((debug-on-error nil)) | ||
| 218 | (eshell-command-result-p "if (zerop \"foo\") {echo yes} {echo no}" | ||
| 219 | "no\n")))) | ||
| 220 | |||
| 221 | (ert-deftest esh-cmd-test/if-else-statement-lisp-form-2 () | ||
| 222 | "Test invocation of an if/else statement using a Lisp form. | ||
| 223 | This tests when `eshell-lisp-form-nil-is-failure' is nil." | ||
| 224 | (let ((eshell-lisp-form-nil-is-failure nil)) | ||
| 225 | (with-temp-eshell | ||
| 226 | (eshell-command-result-p "if (zerop 0) {echo yes} {echo no}" | ||
| 227 | "yes\n") | ||
| 228 | (eshell-command-result-p "if (zerop 1) {echo yes} {echo no}" | ||
| 229 | "yes\n") | ||
| 230 | (let ((debug-on-error nil)) | ||
| 231 | (eshell-command-result-p "if (zerop \"foo\") {echo yes} {echo no}" | ||
| 232 | "no\n"))))) | ||
| 233 | |||
| 234 | (ert-deftest esh-cmd-test/if-else-statement-ext-cmd () | ||
| 235 | "Test invocation of an if/else statement using an external command." | ||
| 236 | (skip-unless (executable-find "[")) | ||
| 237 | (with-temp-eshell | ||
| 238 | (eshell-command-result-p "if {[ foo = foo ]} {echo yes} {echo no}" | ||
| 239 | "yes\n") | ||
| 240 | (eshell-command-result-p "if {[ foo = bar ]} {echo yes} {echo no}" | ||
| 241 | "no\n"))) | ||
| 242 | |||
| 243 | (ert-deftest esh-cmd-test/unless-statement () | ||
| 244 | "Test invocation of an unless statement." | ||
| 245 | (with-temp-eshell | ||
| 246 | (let ((eshell-test-value t)) | ||
| 247 | (eshell-command-result-p "unless $eshell-test-value {echo no}" | ||
| 248 | "\\`\\'")) | ||
| 249 | (let ((eshell-test-value nil)) | ||
| 250 | (eshell-command-result-p "unless $eshell-test-value {echo no}" | ||
| 251 | "no\n")))) | ||
| 252 | |||
| 253 | (ert-deftest esh-cmd-test/unless-else-statement () | ||
| 254 | "Test invocation of an unless/else statement." | ||
| 255 | (with-temp-eshell | ||
| 256 | (let ((eshell-test-value t)) | ||
| 257 | (eshell-command-result-p "unless $eshell-test-value {echo no} {echo yes}" | ||
| 258 | "yes\n")) | ||
| 259 | (let ((eshell-test-value nil)) | ||
| 260 | (eshell-command-result-p "unless $eshell-test-value {echo no} {echo yes}" | ||
| 261 | "no\n")))) | ||
| 262 | |||
| 263 | (ert-deftest esh-cmd-test/unless-else-statement-lisp-form () | ||
| 264 | "Test invocation of an unless/else statement using a Lisp form." | ||
| 265 | (with-temp-eshell | ||
| 266 | (eshell-command-result-p "unless (zerop 0) {echo no} {echo yes}" | ||
| 267 | "yes\n") | ||
| 268 | (eshell-command-result-p "unless (zerop 1) {echo no} {echo yes}" | ||
| 269 | "no\n") | ||
| 270 | (let ((debug-on-error nil)) | ||
| 271 | (eshell-command-result-p "unless (zerop \"foo\") {echo no} {echo yes}" | ||
| 272 | "no\n")))) | ||
| 273 | |||
| 274 | (ert-deftest esh-cmd-test/unless-else-statement-ext-cmd () | ||
| 275 | "Test invocation of an unless/else statement using an external command." | ||
| 276 | (skip-unless (executable-find "[")) | ||
| 277 | (with-temp-eshell | ||
| 278 | (eshell-command-result-p "unless {[ foo = foo ]} {echo no} {echo yes}" | ||
| 279 | "yes\n") | ||
| 280 | (eshell-command-result-p "unless {[ foo = bar ]} {echo no} {echo yes}" | ||
| 281 | "no\n"))) | ||
| 282 | |||
| 283 | ;; esh-cmd-tests.el ends here | ||
diff --git a/test/lisp/eshell/esh-var-tests.el b/test/lisp/eshell/esh-var-tests.el index 54e701a6aab..0c094ee5a79 100644 --- a/test/lisp/eshell/esh-var-tests.el +++ b/test/lisp/eshell/esh-var-tests.el | |||
| @@ -500,18 +500,75 @@ inside double-quotes" | |||
| 500 | (eshell-command-result-p "echo $INSIDE_EMACS[, 1]" | 500 | (eshell-command-result-p "echo $INSIDE_EMACS[, 1]" |
| 501 | "eshell"))) | 501 | "eshell"))) |
| 502 | 502 | ||
| 503 | (ert-deftest esh-var-test/last-status-var-lisp-command () | ||
| 504 | "Test using the \"last exit status\" ($?) variable with a Lisp command" | ||
| 505 | (with-temp-eshell | ||
| 506 | (eshell-command-result-p "zerop 0; echo $?" | ||
| 507 | "t\n0\n") | ||
| 508 | (eshell-command-result-p "zerop 1; echo $?" | ||
| 509 | "0\n") | ||
| 510 | (let ((debug-on-error nil)) | ||
| 511 | (eshell-command-result-p "zerop foo; echo $?" | ||
| 512 | "1\n")))) | ||
| 513 | |||
| 514 | (ert-deftest esh-var-test/last-status-var-lisp-form () | ||
| 515 | "Test using the \"last exit status\" ($?) variable with a Lisp form" | ||
| 516 | (let ((eshell-lisp-form-nil-is-failure t)) | ||
| 517 | (with-temp-eshell | ||
| 518 | (eshell-command-result-p "(zerop 0); echo $?" | ||
| 519 | "t\n0\n") | ||
| 520 | (eshell-command-result-p "(zerop 1); echo $?" | ||
| 521 | "2\n") | ||
| 522 | (let ((debug-on-error nil)) | ||
| 523 | (eshell-command-result-p "(zerop \"foo\"); echo $?" | ||
| 524 | "1\n"))))) | ||
| 525 | |||
| 526 | (ert-deftest esh-var-test/last-status-var-lisp-form-2 () | ||
| 527 | "Test using the \"last exit status\" ($?) variable with a Lisp form. | ||
| 528 | This tests when `eshell-lisp-form-nil-is-failure' is nil." | ||
| 529 | (let ((eshell-lisp-form-nil-is-failure nil)) | ||
| 530 | (with-temp-eshell | ||
| 531 | (eshell-command-result-p "(zerop 0); echo $?" | ||
| 532 | "0\n") | ||
| 533 | (eshell-command-result-p "(zerop 0); echo $?" | ||
| 534 | "0\n") | ||
| 535 | (let ((debug-on-error nil)) | ||
| 536 | (eshell-command-result-p "(zerop \"foo\"); echo $?" | ||
| 537 | "1\n"))))) | ||
| 538 | |||
| 539 | (ert-deftest esh-var-test/last-status-var-ext-cmd () | ||
| 540 | "Test using the \"last exit status\" ($?) variable with an external command" | ||
| 541 | (skip-unless (executable-find "[")) | ||
| 542 | (with-temp-eshell | ||
| 543 | (eshell-command-result-p "[ foo = foo ]; echo $?" | ||
| 544 | "0\n") | ||
| 545 | (eshell-command-result-p "[ foo = bar ]; echo $?" | ||
| 546 | "1\n"))) | ||
| 547 | |||
| 503 | (ert-deftest esh-var-test/last-result-var () | 548 | (ert-deftest esh-var-test/last-result-var () |
| 504 | "Test using the \"last result\" ($$) variable" | 549 | "Test using the \"last result\" ($$) variable" |
| 505 | (with-temp-eshell | 550 | (with-temp-eshell |
| 506 | (eshell-command-result-p "+ 1 2; + $$ 2" | 551 | (eshell-command-result-p "+ 1 2; + $$ 2" |
| 507 | "3\n5\n"))) | 552 | "3\n5\n"))) |
| 508 | 553 | ||
| 509 | (ert-deftest esh-var-test/last-result-var2 () | 554 | (ert-deftest esh-var-test/last-result-var-twice () |
| 510 | "Test using the \"last result\" ($$) variable twice" | 555 | "Test using the \"last result\" ($$) variable twice" |
| 511 | (with-temp-eshell | 556 | (with-temp-eshell |
| 512 | (eshell-command-result-p "+ 1 2; + $$ $$" | 557 | (eshell-command-result-p "+ 1 2; + $$ $$" |
| 513 | "3\n6\n"))) | 558 | "3\n6\n"))) |
| 514 | 559 | ||
| 560 | (ert-deftest esh-var-test/last-result-var-ext-cmd () | ||
| 561 | "Test using the \"last result\" ($$) variable with an external command" | ||
| 562 | (skip-unless (executable-find "[")) | ||
| 563 | (with-temp-eshell | ||
| 564 | ;; MS-DOS/MS-Windows have an external command 'format', which we | ||
| 565 | ;; don't want here. | ||
| 566 | (let ((eshell-prefer-lisp-functions t)) | ||
| 567 | (eshell-command-result-p "[ foo = foo ]; format \"%s\" $$" | ||
| 568 | "t\n") | ||
| 569 | (eshell-command-result-p "[ foo = bar ]; format \"%s\" $$" | ||
| 570 | "nil\n")))) | ||
| 571 | |||
| 515 | (ert-deftest esh-var-test/last-result-var-split-indices () | 572 | (ert-deftest esh-var-test/last-result-var-split-indices () |
| 516 | "Test using the \"last result\" ($$) variable with split indices" | 573 | "Test using the \"last result\" ($$) variable with split indices" |
| 517 | (with-temp-eshell | 574 | (with-temp-eshell |
diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el index 5dc18775485..8423500ea7d 100644 --- a/test/lisp/eshell/eshell-tests.el +++ b/test/lisp/eshell/eshell-tests.el | |||
| @@ -36,59 +36,6 @@ | |||
| 36 | 36 | ||
| 37 | ;;; Tests: | 37 | ;;; Tests: |
| 38 | 38 | ||
| 39 | (ert-deftest eshell-test/simple-command-result () | ||
| 40 | "Test `eshell-command-result' with a simple command." | ||
| 41 | (should (equal (eshell-test-command-result "+ 1 2") 3))) | ||
| 42 | |||
| 43 | (ert-deftest eshell-test/lisp-command () | ||
| 44 | "Test `eshell-command-result' with an elisp command." | ||
| 45 | (should (equal (eshell-test-command-result "(+ 1 2)") 3))) | ||
| 46 | |||
| 47 | (ert-deftest eshell-test/lisp-command-with-quote () | ||
| 48 | "Test `eshell-command-result' with an elisp command containing a quote." | ||
| 49 | (should (equal (eshell-test-command-result "(eq 'foo nil)") nil))) | ||
| 50 | |||
| 51 | (ert-deftest eshell-test/for-loop () | ||
| 52 | "Test `eshell-command-result' with a for loop.." | ||
| 53 | (let ((process-environment (cons "foo" process-environment))) | ||
| 54 | (should (equal (eshell-test-command-result | ||
| 55 | "for foo in 5 { echo $foo }") 5)))) | ||
| 56 | |||
| 57 | (ert-deftest eshell-test/for-name-loop () ;Bug#15231 | ||
| 58 | "Test `eshell-command-result' with a for loop using `name'." | ||
| 59 | (let ((process-environment (cons "name" process-environment))) | ||
| 60 | (should (equal (eshell-test-command-result | ||
| 61 | "for name in 3 { echo $name }") 3)))) | ||
| 62 | |||
| 63 | (ert-deftest eshell-test/for-name-shadow-loop () ; bug#15372 | ||
| 64 | "Test `eshell-command-result' with a for loop using an env-var." | ||
| 65 | (let ((process-environment (cons "name=env-value" process-environment))) | ||
| 66 | (with-temp-eshell | ||
| 67 | (eshell-command-result-p "echo $name; for name in 3 { echo $name }; echo $name" | ||
| 68 | "env-value\n3\nenv-value\n")))) | ||
| 69 | |||
| 70 | (ert-deftest eshell-test/lisp-command-args () | ||
| 71 | "Test `eshell-command-result' with elisp and trailing args. | ||
| 72 | Test that trailing arguments outside the S-expression are | ||
| 73 | ignored. e.g. \"(+ 1 2) 3\" => 3" | ||
| 74 | (should (equal (eshell-test-command-result "(+ 1 2) 3") 3))) | ||
| 75 | |||
| 76 | (ert-deftest eshell-test/subcommand () | ||
| 77 | "Test `eshell-command-result' with a simple subcommand." | ||
| 78 | (should (equal (eshell-test-command-result "{+ 1 2}") 3))) | ||
| 79 | |||
| 80 | (ert-deftest eshell-test/subcommand-args () | ||
| 81 | "Test `eshell-command-result' with a subcommand and trailing args. | ||
| 82 | Test that trailing arguments outside the subcommand are ignored. | ||
| 83 | e.g. \"{+ 1 2} 3\" => 3" | ||
| 84 | (should (equal (eshell-test-command-result "{+ 1 2} 3") 3))) | ||
| 85 | |||
| 86 | (ert-deftest eshell-test/subcommand-lisp () | ||
| 87 | "Test `eshell-command-result' with an elisp subcommand and trailing args. | ||
| 88 | Test that trailing arguments outside the subcommand are ignored. | ||
| 89 | e.g. \"{(+ 1 2)} 3\" => 3" | ||
| 90 | (should (equal (eshell-test-command-result "{(+ 1 2)} 3") 3))) | ||
| 91 | |||
| 92 | (ert-deftest eshell-test/pipe-headproc () | 39 | (ert-deftest eshell-test/pipe-headproc () |
| 93 | "Check that piping a non-process to a process command waits for the process" | 40 | "Check that piping a non-process to a process command waits for the process" |
| 94 | (skip-unless (executable-find "cat")) | 41 | (skip-unless (executable-find "cat")) |