]> git.eshelyaron.com Git - emacs.git/commitdiff
Don’t assume ordering in make-process/mix-stderr
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 21 May 2018 19:30:09 +0000 (12:30 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 21 May 2018 19:31:54 +0000 (12:31 -0700)
* test/src/process-tests.el (process-tests--mixable): New function.
(make-process/mix-stderr): Don’t assume stdout is merged before
stderr.  POSIX does not require this, and the assumption failed to
hold on my Fedora 28 platform.  See Bug#31214.

test/src/process-tests.el

index e83a67290b24bab4f96943c83a7123e385f72d61..551b34ff37193fe0799cdba8f81f0fccbf8e4bb0 100644 (file)
               (should-not (process-query-on-exit-flag process))))
         (kill-process process)))))
 
+;; Return t if OUTPUT could have been generated by merging the INPUTS somehow.
+(defun process-tests--mixable (output &rest inputs)
+  (while (and output (let ((ins inputs))
+                       (while (and ins (not (eq (car (car ins)) (car output))))
+                         (setq ins (cdr ins)))
+                       (if ins
+                           (setcar ins (cdr (car ins))))
+                       ins))
+    (setq output (cdr output)))
+  (not (apply #'append output inputs)))
+
 (ert-deftest make-process/mix-stderr ()
   "Check that `make-process' mixes the output streams if STDERR is nil."
   (skip-unless (executable-find "bash"))
         (accept-process-output process))
       (should (eq (process-status process) 'exit))
       (should (eq (process-exit-status process) 0))
-      (should (equal (buffer-string) "stdout\nstderr\n")))))
+      (should (process-tests--mixable (string-to-list (buffer-string))
+                                      (string-to-list "stdout\n")
+                                      (string-to-list "stderr\n"))))))
 
 (provide 'process-tests)
 ;; process-tests.el ends here.