From: Michael Albinus Date: Tue, 21 Jan 2014 13:31:39 +0000 (+0100) Subject: * automated/file-notify-tests.el X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~311 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=63389c254e73b53a253676ff45e8b089e45c1f31;p=emacs.git * automated/file-notify-tests.el (file-notify--test-local-enabled): Fix error in logic. (file-notify--wait-for-events): New defmacro. (file-notify-test02-events): Make short breaks between file operations. Use `file-notify--wait-for-events'. Check, that events have arrived. (file-notify-test03-autorevert): Use `file-notify--wait-for-events'. --- diff --git a/test/ChangeLog b/test/ChangeLog index e4cabe0032f..21d3e54af80 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,5 +1,12 @@ 2014-01-21 Michael Albinus + * automated/file-notify-tests.el + (file-notify--test-local-enabled): Fix error in logic. + (file-notify--wait-for-events): New defmacro. + (file-notify-test02-events): Make short breaks between file operations. + Use `file-notify--wait-for-events'. Check, that events have arrived. + (file-notify-test03-autorevert): Use `file-notify--wait-for-events'. + * automated/comint-testsuite.el (comint-testsuite-password-strings): Add localized examples. diff --git a/test/automated/file-notify-tests.el b/test/automated/file-notify-tests.el index 9d901e04d44..4845b62d04b 100644 --- a/test/automated/file-notify-tests.el +++ b/test/automated/file-notify-tests.el @@ -67,7 +67,7 @@ This is needed for local `temporary-file-directory' only, in the remote case we return always `t'." (or file-notify--library - (not (file-remote-p temporary-file-directory)))) + (file-remote-p temporary-file-directory))) (defvar file-notify--test-remote-enabled-checked nil "Cached result of `file-notify--test-remote-enabled'. @@ -187,6 +187,16 @@ Save the result in `file-notify--test-results', for later analysis." (expand-file-name (make-temp-name "file-notify-test") temporary-file-directory)) +(defmacro file-notify--wait-for-events (timeout until) + "Wait for file notification events until form UNTIL is true. +TIMEOUT is the maximum time to wait for." + `(with-timeout (,timeout (ignore)) + (while (null ,until) + ;; glib events, and remote events. + (accept-process-output nil 0.1) + ;; inotify events. + (read-event nil nil 0.1)))) + (ert-deftest file-notify-test02-events () "Check file creation/removal notifications." (skip-unless (file-notify--test-local-enabled)) @@ -205,6 +215,7 @@ Save the result in `file-notify--test-results', for later analysis." (write-region "any text" nil file-notify--test-tmpfile nil 'no-message) (delete-file file-notify--test-tmpfile) + (sit-for 0.1 'nodisplay) ;; Check copy and rename. (write-region @@ -212,18 +223,21 @@ Save the result in `file-notify--test-results', for later analysis." (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1) (delete-file file-notify--test-tmpfile) (delete-file file-notify--test-tmpfile1) + (sit-for 0.1 'nodisplay) (write-region "any text" nil file-notify--test-tmpfile nil 'no-message) (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1) - (delete-file file-notify--test-tmpfile1)) + (delete-file file-notify--test-tmpfile1) + (sit-for 0.1 'nodisplay)) ;; Wait for events, and exit. - (sit-for 5 'nodisplay) + (file-notify--wait-for-events 5 file-notify--test-results) (file-notify-rm-watch desc) (ignore-errors (delete-file file-notify--test-tmpfile)) (ignore-errors (delete-file file-notify--test-tmpfile1)))) + (should file-notify--test-results) (dolist (result file-notify--test-results) ;(message "%s" (ert-test-result-messages result)) (when (ert-test-failed-p result) @@ -278,14 +292,10 @@ This test is skipped in batch mode." ;; Check, that the buffer has been reverted. (with-current-buffer (get-buffer-create "*Messages*") - (with-timeout (timeout (ignore)) - (while - (null (string-match - (format "Reverting buffer `%s'." (buffer-name buf)) - (buffer-string))) - ;; We must trigger the process filter to run. - (when remote (accept-process-output nil 1)) - (sit-for 1 'nodisplay)))) + (file-notify--wait-for-events + timeout + (string-match (format "Reverting buffer `%s'." (buffer-name buf)) + (buffer-string)))) (should (string-match "another text" (buffer-string))))) ;; Exit.