(cond
;; gio/gpollfilemonitor.c declares POLL_TIME_SECS 5. So we must
;; wait at least this time in the GPollFileMonitor case. A
- ;; similar timeout seems to be needed in the GFamFileMonitor case,
- ;; at least on Cygwin.
- ((and (string-equal (file-notify--test-library) "gfilenotify")
- (memq (file-notify--test-monitor)
- '(GFamFileMonitor GPollFileMonitor)))
+ ;; similar timeout seems to be needed in the
+ ;; GFam{File,Directory}Monitor case.
+ ((memq (file-notify--test-monitor)
+ '(GFamFileMonitor GFamDirectoryMonitor GPollFileMonitor))
7)
((string-equal (file-notify--test-library) "gvfs-monitor-dir.exe") 1)
((file-remote-p temporary-file-directory) 0.1)
(cond
((file-remote-p temporary-file-directory) 6)
((string-equal (file-notify--test-library) "w32notify") 4)
- ((eq system-type 'cygwin) 6)
+ ((eq system-type 'cygwin) 7)
(t 3)))
(defmacro file-notify--test-wait-for-events (timeout until)
;; `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))
+ (or (alist-get 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))))))
+ (alist-get file-notify--test-desc file-notify--test-monitors)))))
(defmacro file-notify--deftest-remote (test docstring &optional unstable)
"Define ert `TEST-remote' for remote files.
(unwind-protect
;; Check, that removing watch descriptors out of order do not
- ;; harm. This fails on Cygwin because of timing issues unless a
+ ;; harm. This fails on cygwin because of timing issues unless a
;; long `sit-for' is added before the call to
;; `file-notify--test-read-event'.
(unless (eq system-type 'cygwin)
file-notify--test-results
(append file-notify--test-results `(,result))))))
+(defun file-notify--test-event-actions ()
+ "Helper function to return retrieved actions, as list."
+ (mapcar #'file-notify--test-event-action file-notify--test-events))
+
(defun file-notify--test-with-actions-check (actions)
"Check whether received actions match one of the ACTIONS alternatives."
(let (result)
(or result
(if (eq (car elt) :random)
(equal (sort (cdr elt) 'string-lessp)
- (sort (mapcar #'file-notify--test-event-action
- file-notify--test-events)
+ (sort (file-notify--test-event-actions)
'string-lessp))
- (equal elt (mapcar #'file-notify--test-event-action
- file-notify--test-events))))))))
+ (equal elt (file-notify--test-event-actions))))))
+ ;; Do not report result in case we debug. Write messages instead.
+ (if file-notify-debug
+ (prog1 t
+ (if result
+ (message "Success\n%s" (file-notify--test-event-actions))
+ (message (file-notify--test-with-actions-explainer actions))))
+ result)))
(defun file-notify--test-with-actions-explainer (actions)
"Explain why `file-notify--test-with-actions-check' fails."
(if (null (cdr actions))
(format "Received actions do not match expected actions\n%s\n%s"
- (mapcar #'file-notify--test-event-action file-notify--test-events)
- (car actions))
+ (file-notify--test-event-actions) (car actions))
(format
"Received actions do not match any sequence of expected actions\n%s\n%s"
- (mapcar #'file-notify--test-event-action file-notify--test-events)
- actions)))
+ (file-notify--test-event-actions) actions)))
(put 'file-notify--test-with-actions-check 'ert-explainer
'file-notify--test-with-actions-explainer)
(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))
+ ;; GFam{File,Directory}Monitor do not report the `changed' event.
+ ((memq (file-notify--test-monitor)
+ '(GFamFileMonitor GFamDirectoryMonitor))
+ '(created deleted stopped))
(t '(created changed deleted stopped)))
(write-region
"another text" nil file-notify--test-tmpfile nil 'no-message)
((string-equal (file-notify--test-library) "gvfs-monitor-dir.exe")
'((deleted stopped)
(changed deleted stopped)))
+ ;; GFam{File,Directory}Monitor do not detect the
+ ;; `changed' event reliably.
+ ((memq (file-notify--test-monitor)
+ '(GFamFileMonitor GFamDirectoryMonitor))
+ '((deleted stopped)
+ (changed deleted stopped)))
;; There could be one or two `changed' events.
(t '((changed deleted stopped)
(changed changed deleted stopped))))
((getenv "EMACS_EMBA_CI")
'(created changed deleted))
;; 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.
- ((eq system-type 'cygwin)
+ ;; the directory. Except for GFam{File,Directory}Monitor
+ ;; and kqueue. And GFam{File,Directory}Monitor do not
+ ;; raise a `changed' event.
+ ((memq (file-notify--test-monitor)
+ '(GFamFileMonitor GFamDirectoryMonitor))
'(created deleted stopped))
((string-equal (file-notify--test-library) "kqueue")
'(created changed deleted stopped))
'((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)
+ ;; for the directory. Except for
+ ;; GFam{File,Directory}Monitor and kqueue.
+ ((memq (file-notify--test-monitor)
+ '(GFamFileMonitor GFamDirectoryMonitor))
'(created created changed changed deleted stopped))
((string-equal (file-notify--test-library) "kqueue")
'(created changed created changed deleted stopped))
((getenv "EMACS_EMBA_CI")
'(created changed renamed deleted))
;; 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
- ;; of a `renamed' event.
- ((eq system-type 'cygwin)
+ ;; the directory. Except for GFam{File,Directory}Monitor
+ ;; and kqueue. And GFam{File,Directory}Monitor raise
+ ;; `created' and `deleted' events instead of a `renamed'
+ ;; event.
+ ((memq (file-notify--test-monitor)
+ '(GFamFileMonitor GFamDirectoryMonitor))
'(created created deleted deleted stopped))
((string-equal (file-notify--test-library) "kqueue")
'(created changed renamed deleted stopped))
(file-notify--test-cleanup))
(unwind-protect
- ;; Check attribute change. Does not work for cygwin.
- (unless (eq system-type 'cygwin)
+ ;; Check attribute change. Does not work for GFam{File,Directory}Monitor.
+ (progn
(setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
(write-region
"any text" nil file-notify--test-tmpfile nil 'no-message)
(file-notify--test-add-watch
file-notify--test-tmpfile
'(attribute-change) #'file-notify--test-event-handler)))
- (file-notify--test-with-actions
- (cond
- ;; w32notify does not distinguish between `changed' and
- ;; `attribute-changed'. Under MS Windows 7, we get four
- ;; `changed' events, and under MS Windows 10 just two.
- ;; Strange.
- ((string-equal (file-notify--test-library) "w32notify")
- '((changed changed)
- (changed changed changed changed)))
- ;; For kqueue and in the remote case, `write-region'
- ;; raises also an `attribute-changed' event.
- ((or (string-equal (file-notify--test-library) "kqueue")
- (file-remote-p temporary-file-directory))
- '(attribute-changed attribute-changed attribute-changed))
- (t '(attribute-changed attribute-changed)))
- (write-region
- "any text" nil file-notify--test-tmpfile nil 'no-message)
- (file-notify--test-read-event)
- (set-file-modes file-notify--test-tmpfile 000)
- (file-notify--test-read-event)
- (set-file-times file-notify--test-tmpfile '(0 0))
- (file-notify--test-read-event)
- (delete-file file-notify--test-tmpfile))
+ (unless (memq (file-notify--test-monitor)
+ '(GFamFileMonitor GFamDirectoryMonitor))
+ (file-notify--test-with-actions
+ (cond
+ ;; w32notify does not distinguish between `changed' and
+ ;; `attribute-changed'. Under MS Windows 7, we get
+ ;; four `changed' events, and under MS Windows 10 just
+ ;; two. Strange.
+ ((string-equal (file-notify--test-library) "w32notify")
+ '((changed changed)
+ (changed changed changed changed)))
+ ;; For kqueue and in the remote case, `write-region'
+ ;; raises also an `attribute-changed' event.
+ ((or (string-equal (file-notify--test-library) "kqueue")
+ (file-remote-p temporary-file-directory))
+ '(attribute-changed attribute-changed attribute-changed))
+ (t '(attribute-changed attribute-changed)))
+ (write-region
+ "any text" nil file-notify--test-tmpfile nil 'no-message)
+ (file-notify--test-read-event)
+ (set-file-modes file-notify--test-tmpfile 000)
+ (file-notify--test-read-event)
+ (set-file-times file-notify--test-tmpfile '(0 0))
+ (file-notify--test-read-event)
+ (delete-file file-notify--test-tmpfile)))
(file-notify-rm-watch file-notify--test-desc)
;; The environment shall be cleaned up.
;; Modify file. We wait for two seconds, in order to
;; have another timestamp. One second seems to be too
- ;; short. And Cygwin sporadically requires more than two.
+ ;; short. And cygwin sporadically requires more than two.
(ert-with-message-capture captured-messages
(sleep-for (if (eq system-type 'cygwin) 3 2))
(write-region
((string-equal (file-notify--test-library) "gvfs-monitor-dir.exe")
'((deleted stopped)
(changed deleted stopped)))
+ ;; GFam{File,Directory}Monitor do not detect the
+ ;; `changed' event reliably.
+ ((memq (file-notify--test-monitor)
+ '(GFamFileMonitor GFamDirectoryMonitor))
+ '((deleted stopped)
+ (changed deleted stopped)))
;; There could be one or two `changed' events.
(t '((changed deleted stopped)
(changed changed deleted stopped))))
'((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.
- ((eq system-type 'cygwin)
+ ;; the directory. Except for
+ ;; GFam{File,Directory}Monitor and kqueue. And
+ ;; GFam{File,Directory}Monitor do not raise a `changed'
+ ;; event.
+ ((memq (file-notify--test-monitor)
+ '(GFamFileMonitor GFamDirectoryMonitor))
'(created deleted stopped))
((string-equal (file-notify--test-library) "kqueue")
'(created changed deleted stopped))
(dotimes (_i n)
(setq r (append '(deleted renamed) r)))
r))
- ;; cygwin fires `changed' and `deleted' events, sometimes
- ;; in random order.
- ((eq system-type 'cygwin)
+ ;; GFam{File,Directory}Monitor fire `changed' and
+ ;; `deleted' events, sometimes in random order.
+ ((memq (file-notify--test-monitor)
+ '(GFamFileMonitor GFamDirectoryMonitor))
(let (r)
(dotimes (_i n)
(setq r (append '(changed deleted) r)))
(should (file-notify-valid-p file-notify--test-desc))
(file-notify--test-with-actions
(cond
- ;; On cygwin we only get the `changed' event.
- ((eq system-type 'cygwin)
- '(changed))
+ ;; GFam{File,Directory}Monitor report only the `changed' event.
+ ((memq (file-notify--test-monitor)
+ '(GFamFileMonitor GFamDirectoryMonitor))
+ '(changed))
(t '(renamed created changed)))
;; The file is renamed when creating a backup. It shall
;; still be watched.
;; Now we delete the directory.
(file-notify--test-with-actions
(cond
- ;; In kqueue and for cygwin, just one `deleted' event for
- ;; the directory is received.
- ((or (eq system-type 'cygwin)
- (string-equal (file-notify--test-library) "kqueue"))
+ ;; GFam{File,Directory}Monitor and kqueue raise just one
+ ;; `deleted' event for the directory.
+ ((memq (file-notify--test-monitor)
+ '(GFamFileMonitor GFamDirectoryMonitor))
+ '(deleted stopped))
+ ((string-equal (file-notify--test-library) "kqueue")
'(deleted stopped))
(t (append
;; The directory monitor raises a `deleted' event for