]> git.eshelyaron.com Git - emacs.git/commitdiff
Make comint-tests more robust (bug#38813)
authorMattias Engdegård <mattiase@acm.org>
Mon, 30 Dec 2019 13:10:02 +0000 (14:10 +0100)
committerMattias Engdegård <mattiase@acm.org>
Mon, 30 Dec 2019 20:00:27 +0000 (21:00 +0100)
* test/lisp/comint-tests.el (comint-test-no-password-function)
(comint-test-password-function-with-value)
(comint-test-password-function-with-nil):
Call accept-process-output as many times as needed, with a slightly
more generous timeout (100 ms), after sending the Password: prompt to
the process, since there must be time for some back-and-forth
communication.  Also clear the process-query-on-exit flag, since it
doesn't go well with noninteractive tests.

test/lisp/comint-tests.el

index c04134599f6f87f4aa5ae66810412dc8ef03bbc7..4c1c5cc5e20f3bcd6587ed525e80d5ef58aa2eee 100644 (file)
@@ -64,10 +64,10 @@ alter normal password flow."
         (with-temp-buffer
           (make-comint-in-buffer "test-comint-password" (current-buffer) cat)
           (let ((proc (get-buffer-process (current-buffer))))
+            (set-process-query-on-exit-flag proc nil)
             (comint-send-string proc "Password: ")
-            (accept-process-output proc 0 1 t)
             (comint-send-eof)
-            (accept-process-output proc 0 1 t)
+            (while (accept-process-output proc 0.1 nil t))
             (should (string-equal (buffer-substring-no-properties (point-min) (point-max))
                                   "Password: PaSsWoRd123\n"))
             (when (process-live-p proc)
@@ -87,10 +87,10 @@ flow.  Hook function returns alternative password."
         (with-temp-buffer
           (make-comint-in-buffer "test-comint-password" (current-buffer) cat)
           (let ((proc (get-buffer-process (current-buffer))))
+            (set-process-query-on-exit-flag proc nil)
             (comint-send-string proc "Password: ")
-            (accept-process-output proc 0 1 t)
             (comint-send-eof)
-            (accept-process-output proc 0 1 t)
+            (while (accept-process-output proc 0.1 nil t))
             (should (string-equal (buffer-substring-no-properties (point-min) (point-max))
                                   "Password: MaGiC-PaSsWoRd789\n"))
             (when (process-live-p proc)
@@ -110,10 +110,10 @@ password flow if it returns a nil value."
         (with-temp-buffer
           (make-comint-in-buffer "test-comint-password" (current-buffer) cat)
           (let ((proc (get-buffer-process (current-buffer))))
+            (set-process-query-on-exit-flag proc nil)
             (comint-send-string proc "Password: ")
-            (accept-process-output proc 0 1 t)
             (comint-send-eof)
-            (accept-process-output proc 0 1 t)
+            (while (accept-process-output proc 0.1 nil t))
             (should (string-equal (buffer-substring-no-properties (point-min) (point-max))
                                   "Password: PaSsWoRd456\n"))
             (when (process-live-p proc)