Skip to content

Commit aa49aa8

Browse files
committed
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.
1 parent e2efcab commit aa49aa8

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

test/src/process-tests.el

+16-10
Original file line numberDiff line numberDiff line change
@@ -155,24 +155,30 @@
155155
(concat invocation-directory invocation-name)
156156
"-Q" "--batch" "--eval"
157157
(prin1-to-string
158-
'(let (s)
159-
(while (setq s (read-from-minibuffer "$ "))
158+
'(let ((s nil) (count 0))
159+
(while (setq s (read-from-minibuffer
160+
(format "%d> " count)))
160161
(princ s)
161-
(princ "\n")))))))
162+
(princ "\n")
163+
(setq count (1+ count))))))))
162164
(set-process-query-on-exit-flag proc nil)
163165
(send-string proc "one\n")
164-
(should
165-
(accept-process-output proc 1)) ; Read "one".
166-
(should (equal (buffer-string) "$ one\n$ "))
166+
(while (not (equal (buffer-substring
167+
(line-beginning-position) (point-max))
168+
"1> "))
169+
(accept-process-output proc)) ; Read "one".
170+
(should (equal (buffer-string) "0> one\n1> "))
167171
(set-process-filter proc t) ; Stop reading from proc.
168172
(send-string proc "two\n")
169173
(should-not
170174
(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> "))
172176
(set-process-filter proc nil) ; Resume reading from proc.
173-
(should
174-
(accept-process-output proc 1)) ; Read "two" from proc.
175-
(should (equal (buffer-string) "$ one\n$ two\n$ ")))))
177+
(while (not (equal (buffer-substring
178+
(line-beginning-position) (point-max))
179+
"2> "))
180+
(accept-process-output proc)) ; Read "Two".
181+
(should (equal (buffer-string) "0> one\n1> two\n2> ")))))
176182

177183
(ert-deftest start-process-should-not-modify-arguments ()
178184
"`start-process' must not modify its arguments in-place."

0 commit comments

Comments
 (0)