*** /tmp/ediffpZId9s	2021-03-21 13:38:20.876372597 +0100
--- /usr/local/src/emacs-27/test/lisp/filenotify-tests.el	2021-03-21 13:36:24.497655703 +0100
***************
*** 105,115 ****
     (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)))
       7)
      ((string-equal (file-notify--test-library) "gvfs-monitor-dir.exe") 1)
      ((file-remote-p temporary-file-directory) 0.1)
--- 105,115 ----
     (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 and
!     ;; GFamDirectoryMonitor case, at least on cygwin.
      ((and (string-equal (file-notify--test-library) "gfilenotify")
            (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)
***************
*** 455,461 ****

    (unwind-protect
        ;; Check, that removing watch descriptors out of order do not
!       ;; 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)
--- 455,461 ----

    (unwind-protect
        ;; Check, that removing watch descriptors out of order do not
!       ;; 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)
***************
*** 542,547 ****
--- 542,551 ----
  	    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)
***************
*** 550,571 ****
              (or result
                  (if (eq (car elt) :random)
                      (equal (sort (cdr elt) 'string-lessp)
!                            (sort (mapcar #'file-notify--test-event-action
!                                          file-notify--test-events)
                                   'string-lessp))
!                   (equal elt (mapcar #'file-notify--test-event-action
!                                      file-notify--test-events))))))))

  (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))
      (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)))

  (put 'file-notify--test-with-actions-check 'ert-explainer
       'file-notify--test-with-actions-explainer)
--- 554,578 ----
              (or result
                  (if (eq (car elt) :random)
                      (equal (sort (cdr elt) 'string-lessp)
!                            (sort (file-notify--test-event-actions)
                                   'string-lessp))
!                   (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"
!               (file-notify--test-event-actions) (car actions))
      (format
       "Received actions do not match any sequence of expected actions\n%s\n%s"
!      (file-notify--test-event-actions) actions)))

  (put 'file-notify--test-with-actions-check 'ert-explainer
       'file-notify--test-with-actions-explainer)
***************
*** 635,640 ****
--- 642,650 ----
               ;; cygwin does not raise a `changed' event.
               ((eq system-type 'cygwin)
                '(created deleted stopped))
+ 	     ;; GFamDirectoryMonitor does not report the `changed' event.
+ 	     ((equal (file-notify--test-monitor) 'GFamDirectoryMonitor)
+ 	      '(created deleted stopped))
               (t '(created changed deleted stopped)))
            (write-region
             "another text" nil file-notify--test-tmpfile nil 'no-message)
***************
*** 665,670 ****
--- 675,685 ----
  	     ((string-equal (file-notify--test-library) "gvfs-monitor-dir.exe")
  	      '((deleted stopped)
  		(changed deleted stopped)))
+ 	     ;; GFamDirectoryMonitor does not detect the `changed'
+              ;; event reliably.
+ 	     ((equal (file-notify--test-monitor) 'GFamDirectoryMonitor)
+ 	      '((deleted stopped)
+ 		(changed deleted stopped)))
  	     ;; There could be one or two `changed' events.
  	     (t '((changed deleted stopped)
  		  (changed changed deleted stopped))))
***************
*** 713,718 ****
--- 728,736 ----
  	     ;; cygwin does not raise a `changed' event.
  	     ((eq system-type 'cygwin)
  	      '(created deleted stopped))
+ 	     ;; GFamDirectoryMonitor does not report the `changed' event.
+ 	     ((equal (file-notify--test-monitor) 'GFamDirectoryMonitor)
+ 	      '(created deleted stopped))
  	     ((string-equal (file-notify--test-library) "kqueue")
  	      '(created changed deleted stopped))
  	     (t '(created changed deleted deleted stopped)))
***************
*** 755,763 ****
  	      '((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)
  	      '(created created changed changed deleted stopped))
  	     ((string-equal (file-notify--test-library) "kqueue")
  	      '(created changed created changed deleted stopped))
               ;; On emba, `deleted' and `stopped' events of the
--- 773,784 ----
  	      '((deleted stopped)
  		(created created deleted stopped)))
  	     ;; There are three `deleted' events, for two files and
! 	     ;; for the directory.  Except for cygwin,
! 	     ;; GFamDirectoryMonitor and kqueue.
  	     ((eq system-type 'cygwin)
  	      '(created created changed changed deleted stopped))
+ 	     ((equal (file-notify--test-monitor) 'GFamDirectoryMonitor)
+ 	      '(created created changed changed deleted stopped))
  	     ((string-equal (file-notify--test-library) "kqueue")
  	      '(created changed created changed deleted stopped))
               ;; On emba, `deleted' and `stopped' events of the
***************
*** 813,823 ****
               ((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)
  	      '(created created deleted deleted stopped))
  	     ((string-equal (file-notify--test-library) "kqueue")
  	      '(created changed renamed deleted stopped))
  	     (t '(created changed renamed deleted deleted stopped)))
--- 834,847 ----
               ((getenv "EMACS_EMBA_CI")
                '(created changed renamed deleted))
  	     ;; There are two `deleted' events, for the file and for
! 	     ;; the directory.  Except for cygwin,
! 	     ;; GFamDirectoryMonitor and kqueue.  And cygwin and
! 	     ;; GFamDirectoryMonitor raise `created' and `deleted'
! 	     ;; events instead of a `renamed' event.
  	     ((eq system-type 'cygwin)
  	      '(created created deleted deleted stopped))
+ 	     ((equal (file-notify--test-monitor) 'GFamDirectoryMonitor)
+ 	      '(created created deleted deleted stopped))
  	     ((string-equal (file-notify--test-library) "kqueue")
  	      '(created changed renamed deleted stopped))
  	     (t '(created changed renamed deleted deleted stopped)))
***************
*** 837,844 ****
      (file-notify--test-cleanup))

    (unwind-protect
!       ;; Check attribute change.  Does not work for cygwin.
!       (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)
--- 861,870 ----
      (file-notify--test-cleanup))

    (unwind-protect
!       ;; Check attribute change.  Does not work for cygwin and
!       ;; GFamDirectoryMonitor.
!       (unless (or (eq system-type 'cygwin)
!                   (equal (file-notify--test-monitor) 'GFamDirectoryMonitor))
  	(setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
  	(write-region
  	 "any text" nil file-notify--test-tmpfile nil 'no-message)
***************
*** 951,957 ****

  	    ;; 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.
              (ert-with-message-capture captured-messages
                (sleep-for (if (eq system-type 'cygwin) 3 2))
                (write-region
--- 977,983 ----

  	    ;; 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.
              (ert-with-message-capture captured-messages
                (sleep-for (if (eq system-type 'cygwin) 3 2))
                (write-region
***************
*** 1021,1026 ****
--- 1047,1057 ----
  	     ((string-equal (file-notify--test-library) "gvfs-monitor-dir.exe")
  	      '((deleted stopped)
  		(changed deleted stopped)))
+ 	     ;; GFamDirectoryMonitor does not detect the `changed'
+              ;; event reliably.
+ 	     ((equal (file-notify--test-monitor) 'GFamDirectoryMonitor)
+ 	      '((deleted stopped)
+ 	        (changed deleted stopped)))
  	     ;; There could be one or two `changed' events.
  	     (t '((changed deleted stopped)
  		  (changed changed deleted stopped))))
***************
*** 1064,1073 ****
  	        '((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)
  	        '(created deleted stopped))
  	       ((string-equal (file-notify--test-library) "kqueue")
  	        '(created changed deleted stopped))
  	       (t '(created changed deleted deleted stopped)))
--- 1095,1107 ----
  	        '((deleted stopped)
  	          (created deleted stopped)))
  	       ;; There are two `deleted' events, for the file and for
! 	       ;; the directory.  Except for cygwin,
! 	       ;; GFamDirectoryMonitor and kqueue.  And cygwin and
! 	       ;; GFamDirectoryMonitor do not raise a `changed' event.
  	       ((eq system-type 'cygwin)
  	        '(created deleted stopped))
+ 	       ((equal (file-notify--test-monitor) 'GFamDirectoryMonitor)
+ 	        '(created deleted stopped))
  	       ((string-equal (file-notify--test-library) "kqueue")
  	        '(created changed deleted stopped))
  	       (t '(created changed deleted deleted stopped)))
***************
*** 1286,1291 ****
--- 1320,1328 ----
               ;; On cygwin we only get the `changed' event.
               ((eq system-type 'cygwin)
                '(changed))
+ 	     ;; GFamDirectoryMonitor reports only the `changed' event.
+ 	     ((equal (file-notify--test-monitor) 'GFamDirectoryMonitor)
+ 	      '(changed))
               (t '(renamed created changed)))
            ;; The file is renamed when creating a backup.  It shall
            ;; still be watched.
