]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix Bug#21669
authorMichael Albinus <michael.albinus@gmx.de>
Fri, 23 Oct 2015 11:14:09 +0000 (13:14 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Fri, 23 Oct 2015 11:14:09 +0000 (13:14 +0200)
* 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)

lisp/filenotify.el
test/automated/file-notify-tests.el

index a07f99adcbf5a5aafad8d3e444bc72db4e501aa0..b9f59dedfde88765c6325b1fffd8748f942c1e86 100644 (file)
@@ -333,7 +333,9 @@ DESCRIPTOR should be an object returned by `file-notify-add-watch'."
 
     (when (stringp dir)
       ;; Call low-level function.
-      (when (null (cdr registered))
+      (when (or (not file)
+                (and (= (length (cdr registered)) 1)
+                     (assoc file (cdr registered))))
         (condition-case nil
             (if handler
                 ;; A file name handler could exist even if there is no local
index 17636486153e6353b1ea3ba72688dae4f12dd5b4..8441d6d7468aa0649d582b9ec98bf29c1bea55dc 100644 (file)
@@ -63,7 +63,7 @@
 (defvar file-notify--test-events nil)
 (defun file-notify--test-timeout ()
   "Timeout to wait for arriving events, in seconds."
-  (if (file-remote-p temporary-file-directory) 10 3))
+  (if (file-remote-p temporary-file-directory) 6 3))
 
 (defun file-notify--test-cleanup ()
   "Cleanup after a test."
@@ -325,38 +325,41 @@ Don't wait longer than TIMEOUT seconds for the events to be delivered."
                  file-notify--test-tmpfile
                  '(attribute-change) 'file-notify--test-event-handler))
           (file-notify--test-with-events
-              (file-notify--test-timeout) '(attribute-changed)
-            (write-region
-             "any text" nil file-notify--test-tmpfile nil 'no-message)
-            (set-file-modes file-notify--test-tmpfile 000)
-            (delete-file file-notify--test-tmpfile))
-          (file-notify-rm-watch file-notify--test-desc)
-
-          ;; With gfilenotify, there are timing issues with attribute
-          ;; changes in a short time period.  So we apply 2 tests.
-          (setq file-notify--test-desc
-                (file-notify-add-watch
-                 file-notify--test-tmpfile
-                 '(attribute-change) 'file-notify--test-event-handler))
-          (file-notify--test-with-events
-              (file-notify--test-timeout) '(attribute-changed)
+              (file-notify--test-timeout)
+              (if (file-remote-p temporary-file-directory)
+                  ;; In the remote case, `write-region' raises also an
+                  ;; `attribute-changed' event.
+                  '(attribute-changed attribute-changed attribute-changed)
+                '(attribute-changed attribute-changed))
+            ;; We must use short delays between the operations.
+            ;; Otherwise, not all events arrive us in the remote case.
             (write-region
              "any text" nil file-notify--test-tmpfile nil 'no-message)
+            (sleep-for 0.1)
             (set-file-modes file-notify--test-tmpfile 000)
+            (sleep-for 0.1)
+            (set-file-times file-notify--test-tmpfile '(0 0))
+            (sleep-for 0.1)
             (delete-file file-notify--test-tmpfile))
           (file-notify-rm-watch file-notify--test-desc))
 
         ;; Check the global sequence again just to make sure that
         ;; `file-notify--test-events' has been set correctly.
-        (should (equal (mapcar #'cadr file-notify--test-events)
-                       (if (eq file-notify--library 'w32notify)
-                           '(created changed deleted
-                                     created changed changed deleted
-                                     created changed renamed)
-                         '(created changed deleted
-                                   created changed deleted
-                                   created changed renamed
-                                   attribute-changed attribute-changed))))
+        (should (equal
+                 (mapcar #'cadr file-notify--test-events)
+                 (if (eq file-notify--library 'w32notify)
+                     '(created changed deleted
+                       created changed changed deleted
+                       created changed renamed)
+                   (if (file-remote-p temporary-file-directory)
+                       '(created changed deleted
+                         created changed deleted
+                         created changed renamed
+                         attribute-changed attribute-changed attribute-changed)
+                     '(created changed deleted
+                       created changed deleted
+                       created changed renamed
+                       attribute-changed attribute-changed)))))
         (should file-notify--test-results)
         (dolist (result file-notify--test-results)
           ;;(message "%s" (ert-test-result-messages result))