*** /tmp/ediffmmNEZ6 2021-03-22 15:43:13.464939528 +0100 --- /home/albinus/src/emacs-27/test/lisp/filenotify-tests.el 2021-03-22 15:41:35.740131740 +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,114 ---- (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 ! ;; 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) *************** *** 263,274 **** ;; `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 &optional unstable) "Define ert `TEST-remote' for remote files. --- 262,273 ---- ;; `gfile-monitor-name' does not return a proper result anymore. ;; But we still need this information. (unless (file-remote-p temporary-file-directory) ! (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))) ! (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. *************** *** 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) --- 454,460 ---- (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 **** --- 541,550 ---- 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) --- 553,577 ---- (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) *************** *** 632,640 **** (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)) (t '(created changed deleted stopped))) (write-region "another text" nil file-notify--test-tmpfile nil 'no-message) --- 638,647 ---- (file-notify--test-library) "gvfs-monitor-dir.exe") '((deleted stopped) (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) *************** *** 665,670 **** --- 672,683 ---- ((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)))) *************** *** 709,717 **** ((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) '(created deleted stopped)) ((string-equal (file-notify--test-library) "kqueue") '(created changed deleted stopped)) --- 722,732 ---- ((getenv "EMACS_EMBA_CI") '(created changed deleted)) ;; There are two `deleted' events, for the file and for ! ;; 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)) *************** *** 755,762 **** '((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)) --- 770,779 ---- '((deleted stopped) (created created deleted stopped))) ;; There are three `deleted' events, for two files and ! ;; 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)) *************** *** 813,822 **** ((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)) --- 830,841 ---- ((getenv "EMACS_EMBA_CI") '(created changed renamed deleted)) ;; There are two `deleted' events, for the file and for ! ;; 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)) *************** *** 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) --- 856,863 ---- (file-notify--test-cleanup)) (unwind-protect ! ;; 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) *************** *** 847,875 **** (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)) (file-notify-rm-watch file-notify--test-desc) ;; The environment shall be cleaned up. --- 866,896 ---- (file-notify--test-add-watch file-notify--test-tmpfile '(attribute-change) #'file-notify--test-event-handler))) ! (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. *************** *** 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 --- 972,978 ---- ;; 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 **** --- 1042,1053 ---- ((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)))) *************** *** 1064,1072 **** '((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)) --- 1091,1102 ---- '((deleted stopped) (created deleted stopped))) ;; There are two `deleted' events, for the file and for ! ;; 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)) *************** *** 1169,1175 **** file-notify--test-tmpfile '(change) #'file-notify--test-event-handler))) (unwind-protect ! (let ((n 1000) source-file-list target-file-list (default-directory file-notify--test-tmpfile)) (dotimes (i n) --- 1199,1205 ---- file-notify--test-tmpfile '(change) #'file-notify--test-event-handler))) (unwind-protect ! (let ((n 10);00) source-file-list target-file-list (default-directory file-notify--test-tmpfile)) (dotimes (i n) *************** *** 1283,1291 **** (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)) (t '(renamed created changed))) ;; The file is renamed when creating a backup. It shall ;; still be watched. --- 1313,1322 ---- (should (file-notify-valid-p file-notify--test-desc)) (file-notify--test-with-actions (cond ! ;; 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. *************** *** 1355,1361 **** (should (file-notify-valid-p file-notify--test-desc1)) (should (file-notify-valid-p file-notify--test-desc2)) (should-not (equal file-notify--test-desc1 file-notify--test-desc2)) ! (let ((n 100)) ;; Run the test. (file-notify--test-with-actions ;; There could be one or two `changed' events. --- 1386,1392 ---- (should (file-notify-valid-p file-notify--test-desc1)) (should (file-notify-valid-p file-notify--test-desc2)) (should-not (equal file-notify--test-desc1 file-notify--test-desc2)) ! (let ((n 10));0)) ;; Run the test. (file-notify--test-with-actions ;; There could be one or two `changed' events.