diff options
| author | Noam Postavsky | 2019-08-22 20:48:19 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2019-09-01 14:40:00 -0400 |
| commit | 7e527af72cae65fdb3f61c7d92907cfdfd1e6ea3 (patch) | |
| tree | 8d15f308adf9794a6b4cd13d1368b1259bc8a330 | |
| parent | 8e420c09bcef1bf2a08b03deb74d5c663d898e33 (diff) | |
| download | emacs-7e527af72cae65fdb3f61c7d92907cfdfd1e6ea3.tar.gz emacs-7e527af72cae65fdb3f61c7d92907cfdfd1e6ea3.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.
(cherry picked from commit aa49aa884053d0e8b33efe265f2aade19d1f3f3d)
| -rw-r--r-- | test/src/process-tests.el | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/test/src/process-tests.el b/test/src/process-tests.el index 7a6762a9226..ef057af6b79 100644 --- a/test/src/process-tests.el +++ b/test/src/process-tests.el | |||
| @@ -154,24 +154,30 @@ | |||
| 154 | (concat invocation-directory invocation-name) | 154 | (concat invocation-directory invocation-name) |
| 155 | "-Q" "--batch" "--eval" | 155 | "-Q" "--batch" "--eval" |
| 156 | (prin1-to-string | 156 | (prin1-to-string |
| 157 | '(let (s) | 157 | '(let ((s nil) (count 0)) |
| 158 | (while (setq s (read-from-minibuffer "$ ")) | 158 | (while (setq s (read-from-minibuffer |
| 159 | (format "%d> " count))) | ||
| 159 | (princ s) | 160 | (princ s) |
| 160 | (princ "\n"))))))) | 161 | (princ "\n") |
| 162 | (setq count (1+ count)))))))) | ||
| 161 | (set-process-query-on-exit-flag proc nil) | 163 | (set-process-query-on-exit-flag proc nil) |
| 162 | (send-string proc "one\n") | 164 | (send-string proc "one\n") |
| 163 | (should | 165 | (while (not (equal (buffer-substring |
| 164 | (accept-process-output proc 1)) ; Read "one". | 166 | (line-beginning-position) (point-max)) |
| 165 | (should (equal (buffer-string) "$ one\n$ ")) | 167 | "1> ")) |
| 168 | (accept-process-output proc)) ; Read "one". | ||
| 169 | (should (equal (buffer-string) "0> one\n1> ")) | ||
| 166 | (set-process-filter proc t) ; Stop reading from proc. | 170 | (set-process-filter proc t) ; Stop reading from proc. |
| 167 | (send-string proc "two\n") | 171 | (send-string proc "two\n") |
| 168 | (should-not | 172 | (should-not |
| 169 | (accept-process-output proc 1)) ; Can't read "two" yet. | 173 | (accept-process-output proc 1)) ; Can't read "two" yet. |
| 170 | (should (equal (buffer-string) "$ one\n$ ")) | 174 | (should (equal (buffer-string) "0> one\n1> ")) |
| 171 | (set-process-filter proc nil) ; Resume reading from proc. | 175 | (set-process-filter proc nil) ; Resume reading from proc. |
| 172 | (should | 176 | (while (not (equal (buffer-substring |
| 173 | (accept-process-output proc 1)) ; Read "two" from proc. | 177 | (line-beginning-position) (point-max)) |
| 174 | (should (equal (buffer-string) "$ one\n$ two\n$ "))))) | 178 | "2> ")) |
| 179 | (accept-process-output proc)) ; Read "Two". | ||
| 180 | (should (equal (buffer-string) "0> one\n1> two\n2> "))))) | ||
| 175 | 181 | ||
| 176 | (ert-deftest start-process-should-not-modify-arguments () | 182 | (ert-deftest start-process-should-not-modify-arguments () |
| 177 | "`start-process' must not modify its arguments in-place." | 183 | "`start-process' must not modify its arguments in-place." |