summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2017-01-03 09:50:41 +0100
committerMichael Albinus <michael.albinus@gmx.de>2017-01-03 09:50:41 +0100
commit975b2acfe6a4e246631c372063d7bdef0f832d3d (patch)
tree980981f1027245219c75498b2b8be2cd93ffc2b2
parent1d714e41ea73af89b56fb4bf19f8f0c3f443c268 (diff)
downloademacs-975b2acfe6a4e246631c372063d7bdef0f832d3d.tar.gz
Finish work on filenotify-tests.el
* test/lisp/filenotify-tests.el (file-notify--test-monitors): New variable. (file-notify--test-cleanup, file-notify--test-monitor): Use it. (file-notify--test-read-event, file-notify-test02-events) (file-notify-test04-file-validity): Handle "gvfs-monitor-dir.exe". (file-notify-test03-autorevert) (file-notify-test08-watched-file-in-watched-dir): Set `file-notify--test-desc' for proper work of `file-notify--test-monitor'. (Bug#21804)
-rw-r--r--test/lisp/filenotify-tests.el84
1 files changed, 70 insertions, 14 deletions
diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el
index 2c085b34de9..d237d0cc06e 100644
--- a/test/lisp/filenotify-tests.el
+++ b/test/lisp/filenotify-tests.el
@@ -63,6 +63,7 @@
(defvar file-notify--test-results nil)
(defvar file-notify--test-event nil)
(defvar file-notify--test-events nil)
+(defvar file-notify--test-monitors nil)
(defun file-notify--test-read-event ()
"Read one event.
@@ -78,6 +79,7 @@ There are different timeouts for local and remote file notification libraries."
(memq (file-notify--test-monitor)
'(GFamFileMonitor GPollFileMonitor)))
7)
+ ((string-equal (file-notify--test-library) "gvfs-monitor-dir.exe") 1)
((file-remote-p temporary-file-directory) 0.1)
(t 0.01))))
@@ -153,7 +155,8 @@ Return nil when any other file notification watch is still active."
file-notify--test-desc1 nil
file-notify--test-desc2 nil
file-notify--test-results nil
- file-notify--test-events nil))
+ file-notify--test-events nil
+ file-notify--test-monitors nil))
(setq password-cache-expiry nil
tramp-verbose 0
@@ -210,10 +213,16 @@ remote host, or nil."
"The used monitor for the test, as a symbol.
This returns only for the local case and gfilenotify; otherwise it is nil.
`file-notify--test-desc' must be a valid watch descriptor."
- (and file-notify--test-desc
- (null (file-remote-p temporary-file-directory))
- (functionp 'gfile-monitor-name)
- (gfile-monitor-name file-notify--test-desc)))
+ ;; We cache the result, because after `file-notify-rm-watch',
+ ;; `gfile-monitor-name' does not return a proper result anymore.
+ ;; But we still need this information.
+ (unless (file-remote-p temporary-file-directory)
+ (or (cdr (assq file-notify--test-desc file-notify--test-monitors))
+ (when (functionp 'gfile-monitor-name)
+ (add-to-list 'file-notify--test-monitors
+ (cons file-notify--test-desc
+ (gfile-monitor-name file-notify--test-desc)))
+ (cdr (assq file-notify--test-desc file-notify--test-monitors))))))
(defmacro file-notify--deftest-remote (test docstring)
"Define ert `TEST-remote' for remote files."
@@ -444,6 +453,12 @@ delivered."
'(change) #'file-notify--test-event-handler)))
(file-notify--test-with-events
(cond
+ ;; gvfs-monitor-dir on cygwin does not detect the
+ ;; `created' event reliably.
+ ((string-equal
+ (file-notify--test-library) "gvfs-monitor-dir.exe")
+ '((deleted stopped)
+ (created deleted stopped)))
;; cygwin does not raise a `changed' event.
((eq system-type 'cygwin)
'(created deleted stopped))
@@ -463,9 +478,15 @@ delivered."
file-notify--test-tmpfile
'(change) #'file-notify--test-event-handler)))
(file-notify--test-with-events
- ;; There could be one or two `changed' events.
- '((changed deleted stopped)
- (changed changed deleted stopped))
+ (cond
+ ;; gvfs-monitor-dir on cygwin does not detect the
+ ;; `changed' event reliably.
+ ((string-equal (file-notify--test-library) "gvfs-monitor-dir.exe")
+ '((deleted stopped)
+ (changed deleted stopped)))
+ ;; There could be one or two `changed' events.
+ (t '((changed deleted stopped)
+ (changed changed deleted stopped))))
(write-region
"another text" nil file-notify--test-tmpfile nil 'no-message)
(file-notify--test-read-event)
@@ -489,6 +510,12 @@ delivered."
;; events for the watched directory.
((string-equal (file-notify--test-library) "w32notify")
'(created changed deleted))
+ ;; gvfs-monitor-dir on cygwin does not detect the
+ ;; `created' event reliably.
+ ((string-equal
+ (file-notify--test-library) "gvfs-monitor-dir.exe")
+ '((deleted stopped)
+ (created deleted stopped)))
;; There are two `deleted' events, for the file and for
;; the directory. Except for cygwin and kqueue. And
;; cygwin does not raise a `changed' event.
@@ -522,6 +549,12 @@ delivered."
'(created changed created changed
changed changed changed
deleted deleted))
+ ;; gvfs-monitor-dir on cygwin does not detect the
+ ;; `created' event reliably.
+ ((string-equal
+ (file-notify--test-library) "gvfs-monitor-dir.exe")
+ '((deleted stopped)
+ (created created deleted stopped)))
;; There are three `deleted' events, for two files and
;; for the directory. Except for cygwin and kqueue.
((eq system-type 'cygwin)
@@ -559,6 +592,12 @@ delivered."
;; events for the watched directory.
((string-equal (file-notify--test-library) "w32notify")
'(created changed renamed deleted))
+ ;; gvfs-monitor-dir on cygwin does not detect the
+ ;; `created' event reliably.
+ ((string-equal
+ (file-notify--test-library) "gvfs-monitor-dir.exe")
+ '((deleted stopped)
+ (created deleted stopped)))
;; There are two `deleted' events, for the file and for
;; the directory. Except for cygwin and kqueue. And
;; cygwin raises `created' and `deleted' events instead
@@ -578,8 +617,7 @@ delivered."
(file-notify-rm-watch file-notify--test-desc))
;; Check attribute change. Does not work for cygwin.
- (unless (and (eq system-type 'cygwin)
- (not (file-remote-p temporary-file-directory)))
+ (unless (eq system-type 'cygwin)
(setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
(write-region
"any text" nil file-notify--test-tmpfile nil 'no-message)
@@ -654,6 +692,11 @@ delivered."
(while (null auto-revert-notify-watch-descriptor)
(sleep-for 1)))
+ ;; `file-notify--test-monitor' needs to know
+ ;; `file-notify--test-desc' in order to compute proper
+ ;; timeouts.
+ (setq file-notify--test-desc auto-revert-notify-watch-descriptor)
+
;; Check, that file notification has been used.
(should auto-revert-mode)
(should auto-revert-use-notify)
@@ -748,9 +791,15 @@ delivered."
'(change) #'file-notify--test-event-handler)))
(should (file-notify-valid-p file-notify--test-desc))
(file-notify--test-with-events
- ;; There could be one or two `changed' events.
- '((changed deleted stopped)
- (changed changed deleted stopped))
+ (cond
+ ;; gvfs-monitor-dir on cygwin does not detect the
+ ;; `changed' event reliably.
+ ((string-equal (file-notify--test-library) "gvfs-monitor-dir.exe")
+ '((deleted stopped)
+ (changed deleted stopped)))
+ ;; There could be one or two `changed' events.
+ (t '((changed deleted stopped)
+ (changed changed deleted stopped))))
(write-region
"another text" nil file-notify--test-tmpfile nil 'no-message)
(file-notify--test-read-event)
@@ -781,6 +830,11 @@ delivered."
;; for the watched directory.
((string-equal (file-notify--test-library) "w32notify")
'(created changed deleted))
+ ;; gvfs-monitor-dir on cygwin does not detect the `created'
+ ;; event reliably.
+ ((string-equal (file-notify--test-library) "gvfs-monitor-dir.exe")
+ '((deleted stopped)
+ (created deleted stopped)))
;; There are two `deleted' events, for the file and for the
;; directory. Except for cygwin and kqueue. And cygwin
;; does not raise a `changed' event.
@@ -1043,7 +1097,9 @@ the file watch."
(setq file-notify--test-desc1
(file-notify-add-watch
file-notify--test-tmpfile
- '(change) #'dir-callback)))
+ '(change) #'dir-callback)
+ ;; This is needed for `file-notify--test-monitor'.
+ file-notify--test-desc file-notify--test-desc1))
(should
(setq file-notify--test-desc2
(file-notify-add-watch