aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMichael Albinus2025-07-05 19:21:48 +0200
committerMichael Albinus2025-07-05 19:21:48 +0200
commitaa8afabd493ce67924685bc6cfafec551380a094 (patch)
treea70a7e0ce5a993cd9d327c74aa44eac87831b957 /test
parent0a1db9b57322884df0bf677b96d8568e194521d3 (diff)
downloademacs-aa8afabd493ce67924685bc6cfafec551380a094.tar.gz
emacs-aa8afabd493ce67924685bc6cfafec551380a094.zip
Add file notification handler for Tramp's "smb" method.
* etc/NEWS: Mention new file notification handler for Tramp "smb". * lisp/filenotify.el (file-notify--expand-file-name): Fix the remote case. (file-notify-callback): Extend for "smb-notify". (file-notify--call-handler): Fix debug message. * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-file-notify-add-watch): * lisp/net/tramp-sh.el (tramp-sh-gio-monitor-process-filter): Use connection property "file-monitor". * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): Use `tramp-smb-handle-file-notify-add-watch'. (tramp-smb-handle-delete-directory): Do not error if there is a pending deletion of a directory under file-watch. (tramp-smb-handle-file-notify-add-watch) (tramp-smb-notify-process-filter): New defuns. (tramp-smb-send-command): New optional argument NOOUTPUT. (tramp-smb-wait-for-output): Improve debug message. * lisp/net/tramp.el (tramp-directory-watched): New defun. (tramp-accept-process-output, tramp-wait-for-regexp): Improve debug message. * test/lisp/filenotify-tests.el (top): Filter also for "smb-notify". Set some other Tramp related variables. (file-notify--test-wait-for-events) (file-notify--test-with-actions-check) (file-notify--test-with-actions): Add debug message. (file-notify--test-cleanup, file-notify--deftest-remote): Keep Tramp debugs buffer. (file-notify--test-monitor): Check for "smb-notify". (file-notify--deftest-remote): Call `file-notify-rm-all-watches'. (file-notify--test-make-temp-name): Use a better name for parent directory. (file-notify--test-event-handler): Use `string-match-p'. (file-notify--test-with-actions): Check also for the `stopped' event as limit. (file-notify-test03-events, file-notify-test04-autorevert) (file-notify-test05-file-validity) (file-notify-test07-many-events, file-notify-test08-backup) (file-notify-test09-watched-file-in-watched-dir): Adapt tests for "smb-notify". (file-notify-test12-unmount): Skip for "smb-notify".
Diffstat (limited to 'test')
-rw-r--r--test/lisp/filenotify-tests.el170
1 files changed, 134 insertions, 36 deletions
diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el
index 8744dc4987a..dada26fc618 100644
--- a/test/lisp/filenotify-tests.el
+++ b/test/lisp/filenotify-tests.el
@@ -37,7 +37,7 @@
37;; of a respective command. The first command found is used. In 37;; of a respective command. The first command found is used. In
38;; order to use a dedicated one, the environment variable 38;; order to use a dedicated one, the environment variable
39;; $REMOTE_FILE_NOTIFY_LIBRARY shall be set, possible values are 39;; $REMOTE_FILE_NOTIFY_LIBRARY shall be set, possible values are
40;; "inotifywait", "gio-monitor" and "gvfs-monitor-dir". 40;; "inotifywait", "gio-monitor", "gvfs-monitor-dir", and "smb-notify".
41 41
42;; Local file-notify libraries are auto-detected during Emacs 42;; Local file-notify libraries are auto-detected during Emacs
43;; configuration. This can be changed with a respective configuration 43;; configuration. This can be changed with a respective configuration
@@ -58,7 +58,7 @@
58 58
59;; Filter suppressed remote file-notify libraries. 59;; Filter suppressed remote file-notify libraries.
60(when (stringp (getenv "REMOTE_FILE_NOTIFY_LIBRARY")) 60(when (stringp (getenv "REMOTE_FILE_NOTIFY_LIBRARY"))
61 (dolist (lib '("inotifywait" "gio-monitor" "gvfs-monitor-dir")) 61 (dolist (lib '("inotifywait" "gio-monitor" "gvfs-monitor-dir" "smb-notify"))
62 (unless (string-equal (getenv "REMOTE_FILE_NOTIFY_LIBRARY") lib) 62 (unless (string-equal (getenv "REMOTE_FILE_NOTIFY_LIBRARY") lib)
63 (add-to-list 'tramp-connection-properties `(nil ,lib nil))))) 63 (add-to-list 'tramp-connection-properties `(nil ,lib nil)))))
64 64
@@ -104,6 +104,9 @@ There are different timeouts for local and remote file notification libraries."
104TIMEOUT is the maximum time to wait for, in seconds." 104TIMEOUT is the maximum time to wait for, in seconds."
105 `(with-timeout (,timeout (ignore)) 105 `(with-timeout (,timeout (ignore))
106 (while (null ,until) 106 (while (null ,until)
107 (when file-notify-debug
108 (message "file-notify--test-wait-for-events received: %s"
109 (file-notify--test-event-actions)))
107 (file-notify--test-wait-event)))) 110 (file-notify--test-wait-event))))
108 111
109(defun file-notify--test-no-descriptors () 112(defun file-notify--test-no-descriptors ()
@@ -159,7 +162,7 @@ Return nil when any other file notification watch is still active."
159 (ignore-errors 162 (ignore-errors
160 (when (file-remote-p temporary-file-directory) 163 (when (file-remote-p temporary-file-directory)
161 (tramp-cleanup-connection 164 (tramp-cleanup-connection
162 (tramp-dissect-file-name temporary-file-directory) nil 'keep-password))) 165 (tramp-dissect-file-name temporary-file-directory) t 'keep-password)))
163 166
164 (when (hash-table-p file-notify-descriptors) 167 (when (hash-table-p file-notify-descriptors)
165 (clrhash file-notify-descriptors)) 168 (clrhash file-notify-descriptors))
@@ -176,9 +179,13 @@ Return nil when any other file notification watch is still active."
176 file-notify--test-events nil 179 file-notify--test-events nil
177 file-notify--test-monitors nil)) 180 file-notify--test-monitors nil))
178 181
179(setq file-notify-debug nil 182(setq auth-source-cache-expiry nil
183 auth-source-save-behavior nil
184 file-notify-debug nil
180 password-cache-expiry nil 185 password-cache-expiry nil
181 ;; tramp-verbose (if (getenv "EMACS_EMBA_CI") 10 0) 186 remote-file-name-inhibit-cache nil
187 tramp-allow-unsafe-temporary-files t
188 tramp-cache-read-persistent-data t ;; For auth-sources.
182 tramp-verbose 0 189 tramp-verbose 0
183 ;; When the remote user id is 0, Tramp refuses unsafe temporary files. 190 ;; When the remote user id is 0, Tramp refuses unsafe temporary files.
184 tramp-allow-unsafe-temporary-files 191 tramp-allow-unsafe-temporary-files
@@ -241,13 +248,17 @@ watch descriptor."
241 ;; We cache the result, because after `file-notify-rm-watch', 248 ;; We cache the result, because after `file-notify-rm-watch',
242 ;; `gfile-monitor-name' does not return a proper result anymore. 249 ;; `gfile-monitor-name' does not return a proper result anymore.
243 ;; But we still need this information. So far, we know the monitors 250 ;; But we still need this information. So far, we know the monitors
244 ;; GFamFileMonitor (gfilenotify on cygwin), GFamDirectoryMonitor 251 ;; - GFamFileMonitor (gfilenotify on cygwin)
245 ;; (gfilenotify on Solaris), GInotifyFileMonitor (gfilenotify and 252 ;; - GFamDirectoryMonitor (gfilenotify on Solaris)
246 ;; gio on GNU/Linux), GKqueueFileMonitor (gfilenotify and gio on 253 ;; - GInotifyFileMonitor (gfilenotify and gio on GNU/Linux)
247 ;; FreeBSD) and GPollFileMonitor (gio on cygwin). 254 ;; - GKqueueFileMonitor (gfilenotify and gio on FreeBSD)
255 ;; - GPollFileMonitor (gio on cygwin)
256 ;; - SMBSamba (smb-notify on Samba server)
257 ;; - SMBWindows (smb-notify on MS Windows).
248 (when file-notify--test-desc 258 (when file-notify--test-desc
249 (or (alist-get file-notify--test-desc file-notify--test-monitors) 259 (or (alist-get file-notify--test-desc file-notify--test-monitors)
250 (when (member (file-notify--test-library) '("gfilenotify" "gio")) 260 (when (member
261 (file-notify--test-library) '("gfilenotify" "gio" "smb-notify"))
251 (add-to-list 262 (add-to-list
252 'file-notify--test-monitors 263 'file-notify--test-monitors
253 (cons file-notify--test-desc 264 (cons file-notify--test-desc
@@ -255,10 +266,10 @@ watch descriptor."
255 ;; `file-notify--test-desc' is the connection process. 266 ;; `file-notify--test-desc' is the connection process.
256 (progn 267 (progn
257 (while (not (tramp-connection-property-p 268 (while (not (tramp-connection-property-p
258 file-notify--test-desc "gio-file-monitor")) 269 file-notify--test-desc "file-monitor"))
259 (accept-process-output file-notify--test-desc 0)) 270 (accept-process-output file-notify--test-desc 0))
260 (tramp-get-connection-property 271 (tramp-get-connection-property
261 file-notify--test-desc "gio-file-monitor" nil)) 272 file-notify--test-desc "file-monitor" nil))
262 (and (functionp 'gfile-monitor-name) 273 (and (functionp 'gfile-monitor-name)
263 (gfile-monitor-name file-notify--test-desc))))) 274 (gfile-monitor-name file-notify--test-desc)))))
264 ;; If we don't know the monitor, there are good chances the 275 ;; If we don't know the monitor, there are good chances the
@@ -282,7 +293,8 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
282 ;; Needs further investigation. 293 ;; Needs further investigation.
283 (skip-when (string-equal (file-notify--test-library) "gio")) 294 (skip-when (string-equal (file-notify--test-library) "gio"))
284 (tramp-cleanup-connection 295 (tramp-cleanup-connection
285 (tramp-dissect-file-name temporary-file-directory) nil 'keep-password) 296 (tramp-dissect-file-name temporary-file-directory) t 'keep-password)
297 (file-notify-rm-all-watches)
286 (funcall (ert-test-body ert-test))))) 298 (funcall (ert-test-body ert-test)))))
287 299
288(ert-deftest file-notify-test00-availability () 300(ert-deftest file-notify-test00-availability ()
@@ -315,7 +327,7 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
315 (unless (stringp file-notify--test-tmpdir) 327 (unless (stringp file-notify--test-tmpdir)
316 (setq file-notify--test-tmpdir 328 (setq file-notify--test-tmpdir
317 (expand-file-name 329 (expand-file-name
318 (make-temp-name "file-notify-test") temporary-file-directory))) 330 (make-temp-name "file-notify-test-parent") temporary-file-directory)))
319 (unless (file-directory-p file-notify--test-tmpdir) 331 (unless (file-directory-p file-notify--test-tmpdir)
320 (make-directory file-notify--test-tmpdir)) 332 (make-directory file-notify--test-tmpdir))
321 (expand-file-name 333 (expand-file-name
@@ -558,7 +570,7 @@ and the event to `file-notify--test-events'."
558 (result 570 (result
559 (ert-run-test (make-ert-test :body 'file-notify--test-event-test)))) 571 (ert-run-test (make-ert-test :body 'file-notify--test-event-test))))
560 ;; Do not add lock files, this would confuse the checks. 572 ;; Do not add lock files, this would confuse the checks.
561 (unless (string-match 573 (unless (string-match-p
562 (regexp-quote ".#") 574 (regexp-quote ".#")
563 (file-notify--test-event-file file-notify--test-event)) 575 (file-notify--test-event-file file-notify--test-event))
564 (when file-notify-debug 576 (when file-notify-debug
@@ -575,6 +587,8 @@ and the event to `file-notify--test-events'."
575 587
576(defun file-notify--test-with-actions-check (actions) 588(defun file-notify--test-with-actions-check (actions)
577 "Check whether received actions match one of the ACTIONS alternatives." 589 "Check whether received actions match one of the ACTIONS alternatives."
590 (when file-notify-debug
591 (message "file-notify--test-with-actions-check"))
578 (let (result) 592 (let (result)
579 (dolist (elt actions result) 593 (dolist (elt actions result)
580 (setq result 594 (setq result
@@ -632,11 +646,14 @@ delivered."
632 (not (input-pending-p))) 646 (not (input-pending-p)))
633 (setq file-notify--test-events nil 647 (setq file-notify--test-events nil
634 file-notify--test-results nil) 648 file-notify--test-results nil)
649 (when file-notify-debug
650 (message "file-notify--test-with-actions expected: %s" actions))
635 ,@body 651 ,@body
636 (file-notify--test-wait-for-events 652 (file-notify--test-wait-for-events
637 ;; More actions need more time. Use some fudge factor. 653 ;; More actions need more time. Use some fudge factor.
638 (* (ceiling max-length 100) (file-notify--test-timeout)) 654 (* (ceiling max-length 100) (file-notify--test-timeout))
639 (= max-length (length file-notify--test-events))) 655 (or (= max-length (length file-notify--test-events))
656 (memq 'stopped (file-notify--test-event-actions))))
640 ;; Check the result sequence just to make sure that all actions 657 ;; Check the result sequence just to make sure that all actions
641 ;; are as expected. 658 ;; are as expected.
642 (dolist (result file-notify--test-results) 659 (dolist (result file-notify--test-results)
@@ -666,6 +683,9 @@ delivered."
666 '(change) #'file-notify--test-event-handler))) 683 '(change) #'file-notify--test-event-handler)))
667 (file-notify--test-with-actions 684 (file-notify--test-with-actions
668 (cond 685 (cond
686 ;; SMBSamba reports three `changed' events.
687 ((eq (file-notify--test-monitor) 'SMBSamba)
688 '(created changed changed changed deleted stopped))
669 ;; GFam{File,Directory}Monitor, GKqueueFileMonitor and 689 ;; GFam{File,Directory}Monitor, GKqueueFileMonitor and
670 ;; GPollFileMonitor do not report the `changed' event. 690 ;; GPollFileMonitor do not report the `changed' event.
671 ((memq (file-notify--test-monitor) 691 ((memq (file-notify--test-monitor)
@@ -697,6 +717,9 @@ delivered."
697 '(change) #'file-notify--test-event-handler))) 717 '(change) #'file-notify--test-event-handler)))
698 (file-notify--test-with-actions 718 (file-notify--test-with-actions
699 (cond 719 (cond
720 ;; SMBSamba reports four `changed' events.
721 ((eq (file-notify--test-monitor) 'SMBSamba)
722 '(changed changed changed changed deleted stopped))
700 ;; GFam{File,Directory}Monitor and GPollFileMonitor do 723 ;; GFam{File,Directory}Monitor and GPollFileMonitor do
701 ;; not detect the `changed' event reliably. 724 ;; not detect the `changed' event reliably.
702 ((memq (file-notify--test-monitor) 725 ((memq (file-notify--test-monitor)
@@ -739,6 +762,9 @@ delivered."
739 ;; events for the watched directory. 762 ;; events for the watched directory.
740 ((string-equal (file-notify--test-library) "w32notify") 763 ((string-equal (file-notify--test-library) "w32notify")
741 '(created changed deleted)) 764 '(created changed deleted))
765 ;; SMBSamba reports three `changed' events.
766 ((eq (file-notify--test-monitor) 'SMBSamba)
767 '(created changed changed changed deleted deleted stopped))
742 ;; On emba, `deleted' and `stopped' events of the 768 ;; On emba, `deleted' and `stopped' events of the
743 ;; directory are not detected. 769 ;; directory are not detected.
744 ((getenv "EMACS_EMBA_CI") 770 ((getenv "EMACS_EMBA_CI")
@@ -789,6 +815,10 @@ delivered."
789 '(created changed created changed 815 '(created changed created changed
790 changed changed changed 816 changed changed changed
791 deleted deleted)) 817 deleted deleted))
818 ;; SMBSamba reports three `changed' events.
819 ((eq (file-notify--test-monitor) 'SMBSamba)
820 '(created changed changed changed created changed changed changed
821 deleted deleted deleted stopped))
792 ;; There are three `deleted' events, for two files and 822 ;; There are three `deleted' events, for two files and
793 ;; for the directory. Except for 823 ;; for the directory. Except for
794 ;; GFam{File,Directory}Monitor, GPollFileMonitor and 824 ;; GFam{File,Directory}Monitor, GPollFileMonitor and
@@ -843,6 +873,10 @@ delivered."
843 ;; events for the watched directory. 873 ;; events for the watched directory.
844 ((string-equal (file-notify--test-library) "w32notify") 874 ((string-equal (file-notify--test-library) "w32notify")
845 '(created changed renamed deleted)) 875 '(created changed renamed deleted))
876 ;; SMBSamba reports three `changed' events.
877 ((eq (file-notify--test-monitor) 'SMBSamba)
878 '(created changed changed changed
879 renamed changed changed deleted deleted stopped))
846 ;; On emba, `deleted' and `stopped' events of the 880 ;; On emba, `deleted' and `stopped' events of the
847 ;; directory are not detected. 881 ;; directory are not detected.
848 ((getenv "EMACS_EMBA_CI") 882 ((getenv "EMACS_EMBA_CI")
@@ -897,6 +931,14 @@ delivered."
897 ((string-equal (file-notify--test-library) "w32notify") 931 ((string-equal (file-notify--test-library) "w32notify")
898 '((changed changed) 932 '((changed changed)
899 (changed changed changed changed))) 933 (changed changed changed changed)))
934 ;; SMBWindows does not distinguish between `changed' and
935 ;; `attribute-changed'.
936 ((eq (file-notify--test-monitor) 'SMBWindows)
937 '(changed changed))
938 ;; SMBSamba does not distinguish between `changed' and
939 ;; `attribute-changed'.
940 ((eq (file-notify--test-monitor) 'SMBSamba)
941 '(changed changed changed changed))
900 ;; GFam{File,Directory}Monitor, GKqueueFileMonitor and 942 ;; GFam{File,Directory}Monitor, GKqueueFileMonitor and
901 ;; GPollFileMonitor do not report the `attribute-changed' 943 ;; GPollFileMonitor do not report the `attribute-changed'
902 ;; event. 944 ;; event.
@@ -948,6 +990,7 @@ delivered."
948 (timeout (if (file-remote-p temporary-file-directory) 990 (timeout (if (file-remote-p temporary-file-directory)
949 60 ; FIXME: can this be shortened? 991 60 ; FIXME: can this be shortened?
950 (* auto-revert-interval 2.5))) 992 (* auto-revert-interval 2.5)))
993 (text-quoting-style 'grave)
951 buf) 994 buf)
952 (auto-revert-set-timer) 995 (auto-revert-set-timer)
953 (unwind-protect 996 (unwind-protect
@@ -995,10 +1038,11 @@ delivered."
995 ;; Check, that the buffer has been reverted. 1038 ;; Check, that the buffer has been reverted.
996 (file-notify--test-wait-for-events 1039 (file-notify--test-wait-for-events
997 timeout 1040 timeout
998 (string-match 1041 (string-match-p
999 (format-message "Reverting buffer `%s'." (buffer-name buf)) 1042 (rx bol "Reverting buffer `"
1043 (literal (buffer-name buf)) "'" eol)
1000 captured-messages)) 1044 captured-messages))
1001 (should (string-match "another text" (buffer-string))))) 1045 (should (string-match-p "another text" (buffer-string)))))
1002 1046
1003 ;; Stop file notification. Autorevert shall still work via polling. 1047 ;; Stop file notification. Autorevert shall still work via polling.
1004 (file-notify-rm-watch auto-revert-notify-watch-descriptor) 1048 (file-notify-rm-watch auto-revert-notify-watch-descriptor)
@@ -1020,10 +1064,11 @@ delivered."
1020 ;; Check, that the buffer has been reverted. 1064 ;; Check, that the buffer has been reverted.
1021 (file-notify--test-wait-for-events 1065 (file-notify--test-wait-for-events
1022 timeout 1066 timeout
1023 (string-match 1067 (string-match-p
1024 (format-message "Reverting buffer `%s'." (buffer-name buf)) 1068 (rx bol "Reverting buffer `"
1069 (literal (buffer-name buf)) "'" eol)
1025 captured-messages)) 1070 captured-messages))
1026 (should (string-match "foo bla" (buffer-string))))) 1071 (should (string-match-p "foo bla" (buffer-string)))))
1027 1072
1028 ;; Stop autorevert, in order to cleanup descriptor. 1073 ;; Stop autorevert, in order to cleanup descriptor.
1029 (auto-revert-mode -1)) 1074 (auto-revert-mode -1))
@@ -1077,6 +1122,9 @@ delivered."
1077 (should (file-notify-valid-p file-notify--test-desc)) 1122 (should (file-notify-valid-p file-notify--test-desc))
1078 (file-notify--test-with-actions 1123 (file-notify--test-with-actions
1079 (cond 1124 (cond
1125 ;; SMBSamba reports three `changed' events.
1126 ((eq (file-notify--test-monitor) 'SMBSamba)
1127 '(changed changed changed changed deleted stopped))
1080 ;; GFam{File,Directory}Monitor do not 1128 ;; GFam{File,Directory}Monitor do not
1081 ;; detect the `changed' event reliably. 1129 ;; detect the `changed' event reliably.
1082 ((memq (file-notify--test-monitor) 1130 ((memq (file-notify--test-monitor)
@@ -1093,6 +1141,7 @@ delivered."
1093 "another text" nil file-notify--test-tmpfile nil 'no-message) 1141 "another text" nil file-notify--test-tmpfile nil 'no-message)
1094 (file-notify--test-wait-event) 1142 (file-notify--test-wait-event)
1095 (delete-file file-notify--test-tmpfile)) 1143 (delete-file file-notify--test-tmpfile))
1144 (file-notify--test-wait-event)
1096 ;; After deleting the file, the descriptor is not valid anymore. 1145 ;; After deleting the file, the descriptor is not valid anymore.
1097 (should-not (file-notify-valid-p file-notify--test-desc)) 1146 (should-not (file-notify-valid-p file-notify--test-desc))
1098 (file-notify-rm-watch file-notify--test-desc) 1147 (file-notify-rm-watch file-notify--test-desc)
@@ -1122,6 +1171,9 @@ delivered."
1122 ;; events for the watched directory. 1171 ;; events for the watched directory.
1123 ((string-equal (file-notify--test-library) "w32notify") 1172 ((string-equal (file-notify--test-library) "w32notify")
1124 '(created changed deleted)) 1173 '(created changed deleted))
1174 ;; SMBSamba reports three `changed' events.
1175 ((eq (file-notify--test-monitor) 'SMBSamba)
1176 '(created changed changed changed deleted deleted stopped))
1125 ;; There are two `deleted' events, for the file and for 1177 ;; There are two `deleted' events, for the file and for
1126 ;; the directory. Except for 1178 ;; the directory. Except for
1127 ;; GFam{File,Directory}Monitor, GPollFileMonitor and 1179 ;; GFam{File,Directory}Monitor, GPollFileMonitor and
@@ -1247,7 +1299,14 @@ delivered."
1247 (push (expand-file-name (format "y%d" i)) target-file-list)) 1299 (push (expand-file-name (format "y%d" i)) target-file-list))
1248 (push (expand-file-name (format "y%d" i)) source-file-list) 1300 (push (expand-file-name (format "y%d" i)) source-file-list)
1249 (push (expand-file-name (format "x%d" i)) target-file-list))) 1301 (push (expand-file-name (format "x%d" i)) target-file-list)))
1250 (file-notify--test-with-actions (make-list (+ n n) 'created) 1302 (file-notify--test-with-actions
1303 (cond
1304 ;; SMBSamba fires both `created' and `changed' events.
1305 ((eq (file-notify--test-monitor) 'SMBSamba)
1306 (let (r)
1307 (dotimes (_i (+ n n) r)
1308 (setq r (append '(created changed) r)))))
1309 (t (make-list (+ n n) 'created)))
1251 (let ((source-file-list source-file-list) 1310 (let ((source-file-list source-file-list)
1252 (target-file-list target-file-list)) 1311 (target-file-list target-file-list))
1253 (while (and source-file-list target-file-list) 1312 (while (and source-file-list target-file-list)
@@ -1260,18 +1319,26 @@ delivered."
1260 ;; w32notify fires both `deleted' and `renamed' events. 1319 ;; w32notify fires both `deleted' and `renamed' events.
1261 ((string-equal (file-notify--test-library) "w32notify") 1320 ((string-equal (file-notify--test-library) "w32notify")
1262 (let (r) 1321 (let (r)
1263 (dotimes (_i n) 1322 (dotimes (_i n r)
1264 (setq r (append '(deleted renamed) r))) 1323 (setq r (append '(deleted renamed) r)))))
1265 r)) 1324 ;; SMBWindows fires both `changed' and `deleted' events.
1266 ;; GFam{File,Directory}Monitor and GPollFileMonitor fire 1325 ((eq (file-notify--test-monitor) 'SMBWindows)
1326 (let (r)
1327 (dotimes (_i n r)
1328 (setq r (append '(changed deleted) r)))))
1329 ;; SMBSamba fires both `changed' and `deleted' events.
1330 ((eq (file-notify--test-monitor) 'SMBSamba)
1331 (let (r)
1332 (dotimes (_i n r)
1333 (setq r (append '(changed changed deleted) r)))))
1334 ;; GFam{File,Directory}Monitor and GPollFileMonitor fire
1267 ;; `changed' and `deleted' events, sometimes in random 1335 ;; `changed' and `deleted' events, sometimes in random
1268 ;; order. 1336 ;; order.
1269 ((memq (file-notify--test-monitor) 1337 ((memq (file-notify--test-monitor)
1270 '(GFamFileMonitor GFamDirectoryMonitor GPollFileMonitor)) 1338 '(GFamFileMonitor GFamDirectoryMonitor GPollFileMonitor))
1271 (let (r) 1339 (let (r)
1272 (dotimes (_i n) 1340 (dotimes (_i n (cons :random r))
1273 (setq r (append '(changed deleted) r))) 1341 (setq r (append '(changed deleted) r)))))
1274 (cons :random r)))
1275 (t (make-list n 'renamed))) 1342 (t (make-list n 'renamed)))
1276 (let ((source-file-list source-file-list) 1343 (let ((source-file-list source-file-list)
1277 (target-file-list target-file-list)) 1344 (target-file-list target-file-list))
@@ -1315,6 +1382,9 @@ delivered."
1315 (should (file-notify-valid-p file-notify--test-desc)) 1382 (should (file-notify-valid-p file-notify--test-desc))
1316 (file-notify--test-with-actions 1383 (file-notify--test-with-actions
1317 (cond 1384 (cond
1385 ;; SMBSamba reports four `changed' events.
1386 ((eq (file-notify--test-monitor) 'SMBSamba)
1387 '(changed changed changed changed))
1318 ;; GKqueueFileMonitor does not report the `changed' event. 1388 ;; GKqueueFileMonitor does not report the `changed' event.
1319 ((eq (file-notify--test-monitor) 'GKqueueFileMonitor) '()) 1389 ((eq (file-notify--test-monitor) 'GKqueueFileMonitor) '())
1320 ;; There could be one or two `changed' events. 1390 ;; There could be one or two `changed' events.
@@ -1354,6 +1424,12 @@ delivered."
1354 (should (file-notify-valid-p file-notify--test-desc)) 1424 (should (file-notify-valid-p file-notify--test-desc))
1355 (file-notify--test-with-actions 1425 (file-notify--test-with-actions
1356 (cond 1426 (cond
1427 ;; SMBWindows reports two `changed' events.
1428 ((eq (file-notify--test-monitor) 'SMBWindows)
1429 '(changed changed))
1430 ;; SMBSamba reports four `changed' events.
1431 ((eq (file-notify--test-monitor) 'SMBSamba)
1432 '(changed changed changed changed))
1357 ;; GFam{File,Directory}Monitor and GPollFileMonitor 1433 ;; GFam{File,Directory}Monitor and GPollFileMonitor
1358 ;; report only the `changed' event. 1434 ;; report only the `changed' event.
1359 ((memq (file-notify--test-monitor) 1435 ((memq (file-notify--test-monitor)
@@ -1438,7 +1514,27 @@ the file watch."
1438 (file-notify--test-with-actions 1514 (file-notify--test-with-actions
1439 ;; There could be one or two `changed' events. 1515 ;; There could be one or two `changed' events.
1440 (list 1516 (list
1441 ;; cygwin. 1517 ;; SMBSamba. Sometimes, tha last `changed' event is
1518 ;; missing, so we add two alternatives.
1519 (append
1520 '(:random)
1521 ;; Just the file monitor.
1522 (make-list (* (/ n 2) 5) 'changed)
1523 ;; Just the directory monitor. Strange, not all
1524 ;; `changed' events do arrive.
1525 (make-list (1- (* (/ n 2) 10)) 'changed)
1526 (make-list (/ n 2) 'created)
1527 (make-list (/ n 2) 'created))
1528 (append
1529 '(:random)
1530 ;; Just the file monitor.
1531 (make-list (* (/ n 2) 5) 'changed)
1532 ;; Just the directory monitor. This is the alternative
1533 ;; with all `changed' events.
1534 (make-list (* (/ n 2) 10) 'changed)
1535 (make-list (/ n 2) 'created)
1536 (make-list (/ n 2) 'created))
1537 ;; cygwin.
1442 (append 1538 (append
1443 '(:random) 1539 '(:random)
1444 (make-list (/ n 2) 'changed) 1540 (make-list (/ n 2) 'changed)
@@ -1482,7 +1578,9 @@ the file watch."
1482 ;; directory and the file monitor. The `stopped' event is 1578 ;; directory and the file monitor. The `stopped' event is
1483 ;; from the file monitor. It's undecided in which order the 1579 ;; from the file monitor. It's undecided in which order the
1484 ;; directory and the file monitor are triggered. 1580 ;; directory and the file monitor are triggered.
1485 (file-notify--test-with-actions '(:random deleted deleted stopped) 1581 (file-notify--test-with-actions
1582 '((:random deleted deleted stopped)
1583 (:random deleted deleted deleted stopped))
1486 (delete-file file-notify--test-tmpfile1)) 1584 (delete-file file-notify--test-tmpfile1))
1487 (should (file-notify-valid-p file-notify--test-desc1)) 1585 (should (file-notify-valid-p file-notify--test-desc1))
1488 (should-not (file-notify-valid-p file-notify--test-desc2)) 1586 (should-not (file-notify-valid-p file-notify--test-desc2))
@@ -1715,8 +1813,8 @@ the file watch."
1715 "Check that file notification stop after unmounting the filesystem." 1813 "Check that file notification stop after unmounting the filesystem."
1716 :tags '(:expensive-test) 1814 :tags '(:expensive-test)
1717 (skip-unless (file-notify--test-local-enabled)) 1815 (skip-unless (file-notify--test-local-enabled))
1718 ;; This test does not work for w32notify. 1816 ;; This test does not work for w32notify snd smb-notify.
1719 (skip-when (string-equal (file-notify--test-library) "w32notify")) 1817 (skip-when (member (file-notify--test-library) '("w32notify" "smb-notify")))
1720 1818
1721 (unwind-protect 1819 (unwind-protect
1722 (progn 1820 (progn
@@ -1789,8 +1887,8 @@ the file watch."
1789;; the missing directory monitor. 1887;; the missing directory monitor.
1790;; * For w32notify, no `deleted' and `stopped' events arrive when a 1888;; * For w32notify, no `deleted' and `stopped' events arrive when a
1791;; directory is removed. 1889;; directory is removed.
1792;; * For cygwin and w32notify, no `attribute-changed' events arrive. 1890;; * For cygwin, w32notify, and smb-notify, no `attribute-changed'
1793;; They send `changed' events instead. 1891;; events arrive. They send `changed' events instead.
1794;; * cygwin does not send all expected `changed' and `deleted' events. 1892;; * cygwin does not send all expected `changed' and `deleted' events.
1795;; Probably due to timing issues. 1893;; Probably due to timing issues.
1796 1894