Commit 7e527af7 authored by Noam Postavsky's avatar Noam Postavsky
Browse files

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.

(cherry picked from commit aa49aa88)
parent 8e420c09
Pipeline #3026 passed with stage
in 25 minutes and 29 seconds
...@@ -154,24 +154,30 @@ ...@@ -154,24 +154,30 @@
(concat invocation-directory invocation-name) (concat invocation-directory invocation-name)
"-Q" "--batch" "--eval" "-Q" "--batch" "--eval"
(prin1-to-string (prin1-to-string
'(let (s) '(let ((s nil) (count 0))
(while (setq s (read-from-minibuffer "$ ")) (while (setq s (read-from-minibuffer
(format "%d> " count)))
(princ s) (princ s)
(princ "\n"))))))) (princ "\n")
(setq count (1+ count))))))))
(set-process-query-on-exit-flag proc nil) (set-process-query-on-exit-flag proc nil)
(send-string proc "one\n") (send-string proc "one\n")
(should (while (not (equal (buffer-substring
(accept-process-output proc 1)) ; Read "one". (line-beginning-position) (point-max))
(should (equal (buffer-string) "$ one\n$ ")) "1> "))
(accept-process-output proc)) ; Read "one".
(should (equal (buffer-string) "0> one\n1> "))
(set-process-filter proc t) ; Stop reading from proc. (set-process-filter proc t) ; Stop reading from proc.
(send-string proc "two\n") (send-string proc "two\n")
(should-not (should-not
(accept-process-output proc 1)) ; Can't read "two" yet. (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. (set-process-filter proc nil) ; Resume reading from proc.
(should (while (not (equal (buffer-substring
(accept-process-output proc 1)) ; Read "two" from proc. (line-beginning-position) (point-max))
(should (equal (buffer-string) "$ one\n$ two\n$ "))))) "2> "))
(accept-process-output proc)) ; Read "Two".
(should (equal (buffer-string) "0> one\n1> two\n2> ")))))
(ert-deftest start-process-should-not-modify-arguments () (ert-deftest start-process-should-not-modify-arguments ()
"`start-process' must not modify its arguments in-place." "`start-process' must not modify its arguments in-place."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment