2014-01-21 Michael Albinus <michael.albinus@gmx.de>
+ * 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.
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'.
(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))
(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
(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)
;; 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.