summaryrefslogtreecommitdiff
path: root/test/src/process-tests.el
diff options
context:
space:
mode:
authorNoam Postavsky <npostavs@gmail.com>2019-08-22 20:48:19 -0400
committerNoam Postavsky <npostavs@gmail.com>2019-08-24 12:16:26 -0400
commitaa49aa884053d0e8b33efe265f2aade19d1f3f3d (patch)
tree6c38d6d2452c5b05a92dfe9ab29c037ab7c04040 /test/src/process-tests.el
parente2efcabdc6f4a07acfc9b6c143eb4469ec26ac02 (diff)
downloademacs-aa49aa884053d0e8b33efe265f2aade19d1f3f3d.tar.gz
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 @@
(concat invocation-directory invocation-name)
"-Q" "--batch" "--eval"
(prin1-to-string
- '(let (s)
- (while (setq s (read-from-minibuffer "$ "))
+ '(let ((s nil) (count 0))
+ (while (setq s (read-from-minibuffer
+ (format "%d> " count)))
(princ s)
- (princ "\n")))))))
+ (princ "\n")
+ (setq count (1+ count))))))))
(set-process-query-on-exit-flag proc nil)
(send-string proc "one\n")
- (should
- (accept-process-output proc 1)) ; Read "one".
- (should (equal (buffer-string) "$ one\n$ "))
+ (while (not (equal (buffer-substring
+ (line-beginning-position) (point-max))
+ "1> "))
+ (accept-process-output proc)) ; Read "one".
+ (should (equal (buffer-string) "0> one\n1> "))
(set-process-filter proc t) ; Stop reading from proc.
(send-string proc "two\n")
(should-not
(accept-process-output proc 1)) ; Can't read "two" yet.
- (should (equal (buffer-string) "$ one\n$ "))
+ (should (equal (buffer-string) "0> one\n1> "))
(set-process-filter proc nil) ; Resume reading from proc.
- (should
- (accept-process-output proc 1)) ; Read "two" from proc.
- (should (equal (buffer-string) "$ one\n$ two\n$ ")))))
+ (while (not (equal (buffer-substring
+ (line-beginning-position) (point-max))
+ "2> "))
+ (accept-process-output proc)) ; Read "Two".
+ (should (equal (buffer-string) "0> one\n1> two\n2> ")))))
(ert-deftest start-process-should-not-modify-arguments ()
"`start-process' must not modify its arguments in-place."