aboutsummaryrefslogtreecommitdiffstats
path: root/test/src/process-tests.el
diff options
context:
space:
mode:
authorNoam Postavsky2019-08-22 20:48:19 -0400
committerNoam Postavsky2019-08-24 12:16:26 -0400
commitaa49aa884053d0e8b33efe265f2aade19d1f3f3d (patch)
tree6c38d6d2452c5b05a92dfe9ab29c037ab7c04040 /test/src/process-tests.el
parente2efcabdc6f4a07acfc9b6c143eb4469ec26ac02 (diff)
downloademacs-aa49aa884053d0e8b33efe265f2aade19d1f3f3d.tar.gz
emacs-aa49aa884053d0e8b33efe265f2aade19d1f3f3d.zip
Fix non-deterministic process test
* test/src/process-tests.el (set-process-filter-t): Don't assume subprocess output will come in a single chunk, keep waiting for more data until next "prompt" is read from subprocess.
Diffstat (limited to 'test/src/process-tests.el')
-rw-r--r--test/src/process-tests.el26
1 files changed, 16 insertions, 10 deletions
diff --git a/test/src/process-tests.el b/test/src/process-tests.el
index 82eeee1150a..158c036aaa7 100644
--- a/test/src/process-tests.el
+++ b/test/src/process-tests.el
@@ -155,24 +155,30 @@
155 (concat invocation-directory invocation-name) 155 (concat invocation-directory invocation-name)
156 "-Q" "--batch" "--eval" 156 "-Q" "--batch" "--eval"
157 (prin1-to-string 157 (prin1-to-string
158 '(let (s) 158 '(let ((s nil) (count 0))
159 (while (setq s (read-from-minibuffer "$ ")) 159 (while (setq s (read-from-minibuffer
160 (format "%d> " count)))
160 (princ s) 161 (princ s)
161 (princ "\n"))))))) 162 (princ "\n")
163 (setq count (1+ count))))))))
162 (set-process-query-on-exit-flag proc nil) 164 (set-process-query-on-exit-flag proc nil)
163 (send-string proc "one\n") 165 (send-string proc "one\n")
164 (should 166 (while (not (equal (buffer-substring
165 (accept-process-output proc 1)) ; Read "one". 167 (line-beginning-position) (point-max))
166 (should (equal (buffer-string) "$ one\n$ ")) 168 "1> "))
169 (accept-process-output proc)) ; Read "one".
170 (should (equal (buffer-string) "0> one\n1> "))
167 (set-process-filter proc t) ; Stop reading from proc. 171 (set-process-filter proc t) ; Stop reading from proc.
168 (send-string proc "two\n") 172 (send-string proc "two\n")
169 (should-not 173 (should-not
170 (accept-process-output proc 1)) ; Can't read "two" yet. 174 (accept-process-output proc 1)) ; Can't read "two" yet.
171 (should (equal (buffer-string) "$ one\n$ ")) 175 (should (equal (buffer-string) "0> one\n1> "))
172 (set-process-filter proc nil) ; Resume reading from proc. 176 (set-process-filter proc nil) ; Resume reading from proc.
173 (should 177 (while (not (equal (buffer-substring
174 (accept-process-output proc 1)) ; Read "two" from proc. 178 (line-beginning-position) (point-max))
175 (should (equal (buffer-string) "$ one\n$ two\n$ "))))) 179 "2> "))
180 (accept-process-output proc)) ; Read "Two".
181 (should (equal (buffer-string) "0> one\n1> two\n2> ")))))
176 182
177(ert-deftest start-process-should-not-modify-arguments () 183(ert-deftest start-process-should-not-modify-arguments ()
178 "`start-process' must not modify its arguments in-place." 184 "`start-process' must not modify its arguments in-place."