aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2015-10-23 13:14:09 +0200
committerMichael Albinus2015-10-23 13:14:09 +0200
commit71d6acff1cabbf983c8191d02f084faf3f56d788 (patch)
tree10d7aab22f279cee48a9bb436bf56074a859be04
parent0f7334147d23ad2792523f59a968fb44c820fa35 (diff)
downloademacs-71d6acff1cabbf983c8191d02f084faf3f56d788.tar.gz
emacs-71d6acff1cabbf983c8191d02f084faf3f56d788.zip
Fix Bug#21669
* lisp/filenotify.el (file-notify-rm-watch): Improve check for calling low-level functions. * test/automated/file-notify-tests.el (file-notify--test-timeout): Decrase to 6 seconds for remote directories. (file-notify-test02-events): Expect different number of `attribute-changed' events for the local and remote cases. Apply short delays between the operations, in order to receive all events in the remote case. Combine `attribute-change' tests. (Bug#21669)
-rw-r--r--lisp/filenotify.el4
-rw-r--r--test/automated/file-notify-tests.el53
2 files changed, 31 insertions, 26 deletions
diff --git a/lisp/filenotify.el b/lisp/filenotify.el
index a07f99adcbf..b9f59dedfde 100644
--- a/lisp/filenotify.el
+++ b/lisp/filenotify.el
@@ -333,7 +333,9 @@ DESCRIPTOR should be an object returned by `file-notify-add-watch'."
333 333
334 (when (stringp dir) 334 (when (stringp dir)
335 ;; Call low-level function. 335 ;; Call low-level function.
336 (when (null (cdr registered)) 336 (when (or (not file)
337 (and (= (length (cdr registered)) 1)
338 (assoc file (cdr registered))))
337 (condition-case nil 339 (condition-case nil
338 (if handler 340 (if handler
339 ;; A file name handler could exist even if there is no local 341 ;; A file name handler could exist even if there is no local
diff --git a/test/automated/file-notify-tests.el b/test/automated/file-notify-tests.el
index 17636486153..8441d6d7468 100644
--- a/test/automated/file-notify-tests.el
+++ b/test/automated/file-notify-tests.el
@@ -63,7 +63,7 @@
63(defvar file-notify--test-events nil) 63(defvar file-notify--test-events nil)
64(defun file-notify--test-timeout () 64(defun file-notify--test-timeout ()
65 "Timeout to wait for arriving events, in seconds." 65 "Timeout to wait for arriving events, in seconds."
66 (if (file-remote-p temporary-file-directory) 10 3)) 66 (if (file-remote-p temporary-file-directory) 6 3))
67 67
68(defun file-notify--test-cleanup () 68(defun file-notify--test-cleanup ()
69 "Cleanup after a test." 69 "Cleanup after a test."
@@ -325,38 +325,41 @@ Don't wait longer than TIMEOUT seconds for the events to be delivered."
325 file-notify--test-tmpfile 325 file-notify--test-tmpfile
326 '(attribute-change) 'file-notify--test-event-handler)) 326 '(attribute-change) 'file-notify--test-event-handler))
327 (file-notify--test-with-events 327 (file-notify--test-with-events
328 (file-notify--test-timeout) '(attribute-changed) 328 (file-notify--test-timeout)
329 (write-region 329 (if (file-remote-p temporary-file-directory)
330 "any text" nil file-notify--test-tmpfile nil 'no-message) 330 ;; In the remote case, `write-region' raises also an
331 (set-file-modes file-notify--test-tmpfile 000) 331 ;; `attribute-changed' event.
332 (delete-file file-notify--test-tmpfile)) 332 '(attribute-changed attribute-changed attribute-changed)
333 (file-notify-rm-watch file-notify--test-desc) 333 '(attribute-changed attribute-changed))
334 334 ;; We must use short delays between the operations.
335 ;; With gfilenotify, there are timing issues with attribute 335 ;; Otherwise, not all events arrive us in the remote case.
336 ;; changes in a short time period. So we apply 2 tests.
337 (setq file-notify--test-desc
338 (file-notify-add-watch
339 file-notify--test-tmpfile
340 '(attribute-change) 'file-notify--test-event-handler))
341 (file-notify--test-with-events
342 (file-notify--test-timeout) '(attribute-changed)
343 (write-region 336 (write-region
344 "any text" nil file-notify--test-tmpfile nil 'no-message) 337 "any text" nil file-notify--test-tmpfile nil 'no-message)
338 (sleep-for 0.1)
345 (set-file-modes file-notify--test-tmpfile 000) 339 (set-file-modes file-notify--test-tmpfile 000)
340 (sleep-for 0.1)
341 (set-file-times file-notify--test-tmpfile '(0 0))
342 (sleep-for 0.1)
346 (delete-file file-notify--test-tmpfile)) 343 (delete-file file-notify--test-tmpfile))
347 (file-notify-rm-watch file-notify--test-desc)) 344 (file-notify-rm-watch file-notify--test-desc))
348 345
349 ;; Check the global sequence again just to make sure that 346 ;; Check the global sequence again just to make sure that
350 ;; `file-notify--test-events' has been set correctly. 347 ;; `file-notify--test-events' has been set correctly.
351 (should (equal (mapcar #'cadr file-notify--test-events) 348 (should (equal
352 (if (eq file-notify--library 'w32notify) 349 (mapcar #'cadr file-notify--test-events)
353 '(created changed deleted 350 (if (eq file-notify--library 'w32notify)
354 created changed changed deleted 351 '(created changed deleted
355 created changed renamed) 352 created changed changed deleted
356 '(created changed deleted 353 created changed renamed)
357 created changed deleted 354 (if (file-remote-p temporary-file-directory)
358 created changed renamed 355 '(created changed deleted
359 attribute-changed attribute-changed)))) 356 created changed deleted
357 created changed renamed
358 attribute-changed attribute-changed attribute-changed)
359 '(created changed deleted
360 created changed deleted
361 created changed renamed
362 attribute-changed attribute-changed)))))
360 (should file-notify--test-results) 363 (should file-notify--test-results)
361 (dolist (result file-notify--test-results) 364 (dolist (result file-notify--test-results)
362 ;;(message "%s" (ert-test-result-messages result)) 365 ;;(message "%s" (ert-test-result-messages result))