aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2013-09-16 16:58:28 -0400
committerGlenn Morris2013-09-16 16:58:28 -0400
commit0c2a2b57fe7b740b56cac4aed7b848fb87c2c00f (patch)
tree6f38058a7846849ae53835ca8087074f00939979
parent8d95f3a69cc3268338a0d29514810c9452b338f3 (diff)
downloademacs-0c2a2b57fe7b740b56cac4aed7b848fb87c2c00f.tar.gz
emacs-0c2a2b57fe7b740b56cac4aed7b848fb87c2c00f.zip
* test/automated/eshell.el (eshell-match-result):
Return a more informative failure than simply "false". Update callers.
-rw-r--r--test/ChangeLog3
-rw-r--r--test/automated/eshell.el32
2 files changed, 16 insertions, 19 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 82141d75a53..000f8e257f1 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,5 +1,8 @@
12013-09-16 Glenn Morris <rgm@gnu.org> 12013-09-16 Glenn Morris <rgm@gnu.org>
2 2
3 * automated/eshell.el (eshell-match-result):
4 Return a more informative failure than simply "false". Update callers.
5
3 * automated/eshell.el (eshell-test/for-name-shadow-loop): 6 * automated/eshell.el (eshell-test/for-name-shadow-loop):
4 Test value before and after loop as well as during. 7 Test value before and after loop as well as during.
5 8
diff --git a/test/automated/eshell.el b/test/automated/eshell.el
index 41c7b254752..3cc3e92d1e5 100644
--- a/test/automated/eshell.el
+++ b/test/automated/eshell.el
@@ -47,13 +47,11 @@
47 (funcall (or func 'eshell-send-input))) 47 (funcall (or func 'eshell-send-input)))
48 48
49(defun eshell-match-result (regexp) 49(defun eshell-match-result (regexp)
50 "Insert a command at the end of the buffer." 50 "Check that text after `eshell-last-input-end' matches REGEXP."
51 (goto-char eshell-last-input-end) 51 (goto-char eshell-last-input-end)
52 (looking-at regexp)) 52 (should (string-match-p regexp (buffer-substring-no-properties
53 (point) (point-max)))))
53 54
54;; FIXME this does not return informative failure messages, just t or nil.
55;; It should return the expected buffer contents and the actual one,
56;; so that we can see what form any failure took.
57(defun eshell-command-result-p (text regexp &optional func) 55(defun eshell-command-result-p (text regexp &optional func)
58 "Insert a command at the end of the buffer." 56 "Insert a command at the end of the buffer."
59 (eshell-insert-command text func) 57 (eshell-insert-command text func)
@@ -93,9 +91,8 @@
93 "Test `eshell-command-result' with a for loop using an env-var." 91 "Test `eshell-command-result' with a for loop using an env-var."
94 (let ((process-environment (cons "name=env-value" process-environment))) 92 (let ((process-environment (cons "name=env-value" process-environment)))
95 (with-temp-eshell 93 (with-temp-eshell
96 (should 94 (eshell-command-result-p "echo $name; for name in 3 { echo $name }; echo $name"
97 (eshell-command-result-p "echo $name; for name in 3 { echo $name }; echo $name" 95 "env-value\n3\nenv-value\n"))))
98 "env-value\n3\nenv-value\n")))))
99 96
100(ert-deftest eshell-test/lisp-command-args () 97(ert-deftest eshell-test/lisp-command-args ()
101 "Test `eshell-command-result' with elisp and trailing args. 98 "Test `eshell-command-result' with elisp and trailing args.
@@ -154,23 +151,20 @@ e.g. \"{(+ 1 2)} 3\" => 3"
154(ert-deftest eshell-test/last-result-var () 151(ert-deftest eshell-test/last-result-var ()
155 "Test using the \"last result\" ($$) variable" 152 "Test using the \"last result\" ($$) variable"
156 (with-temp-eshell 153 (with-temp-eshell
157 (should 154 (eshell-command-result-p "+ 1 2; + $$ 2"
158 (eshell-command-result-p "+ 1 2; + $$ 2" 155 "3\n5\n")))
159 "3\n5\n"))))
160 156
161(ert-deftest eshell-test/last-result-var2 () 157(ert-deftest eshell-test/last-result-var2 ()
162 "Test using the \"last result\" ($$) variable twice" 158 "Test using the \"last result\" ($$) variable twice"
163 (with-temp-eshell 159 (with-temp-eshell
164 (should 160 (eshell-command-result-p "+ 1 2; + $$ $$"
165 (eshell-command-result-p "+ 1 2; + $$ $$" 161 "3\n6\n")))
166 "3\n6\n"))))
167 162
168(ert-deftest eshell-test/last-arg-var () 163(ert-deftest eshell-test/last-arg-var ()
169 "Test using the \"last arg\" ($_) variable" 164 "Test using the \"last arg\" ($_) variable"
170 (with-temp-eshell 165 (with-temp-eshell
171 (should 166 (eshell-command-result-p "+ 1 2; + $_ 4"
172 (eshell-command-result-p "+ 1 2; + $_ 4" 167 "3\n6\n")))
173 "3\n6\n"))))
174 168
175(ert-deftest eshell-test/command-running-p () 169(ert-deftest eshell-test/command-running-p ()
176 "Modeline should show no command running" 170 "Modeline should show no command running"
@@ -204,14 +198,14 @@ e.g. \"{(+ 1 2)} 3\" => 3"
204 (> count 0)) 198 (> count 0))
205 (sit-for 1) 199 (sit-for 1)
206 (setq count (1- count)))) 200 (setq count (1- count))))
207 (should (eshell-match-result "alpha\n")))) 201 (eshell-match-result "alpha\n")))
208 202
209(ert-deftest eshell-test/flush-output () 203(ert-deftest eshell-test/flush-output ()
210 "Test flushing of previous output" 204 "Test flushing of previous output"
211 (with-temp-eshell 205 (with-temp-eshell
212 (eshell-insert-command "echo alpha") 206 (eshell-insert-command "echo alpha")
213 (eshell-kill-output) 207 (eshell-kill-output)
214 (should (eshell-match-result (regexp-quote "*** output flushed ***\n"))) 208 (eshell-match-result (regexp-quote "*** output flushed ***\n"))
215 (should (forward-line)) 209 (should (forward-line))
216 (should (= (point) eshell-last-output-start)))) 210 (should (= (point) eshell-last-output-start))))
217 211