emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 71d6acf: Fix Bug#21669


From: Michael Albinus
Subject: [Emacs-diffs] master 71d6acf: Fix Bug#21669
Date: Fri, 23 Oct 2015 11:14:21 +0000

branch: master
commit 71d6acff1cabbf983c8191d02f084faf3f56d788
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>

    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)
---
 lisp/filenotify.el                  |    4 ++-
 test/automated/file-notify-tests.el |   53 ++++++++++++++++++----------------
 2 files changed, 31 insertions(+), 26 deletions(-)

diff --git a/lisp/filenotify.el b/lisp/filenotify.el
index a07f99a..b9f59de 100644
--- a/lisp/filenotify.el
+++ b/lisp/filenotify.el
@@ -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
diff --git a/test/automated/file-notify-tests.el 
b/test/automated/file-notify-tests.el
index 1763648..8441d6d 100644
--- a/test/automated/file-notify-tests.el
+++ b/test/automated/file-notify-tests.el
@@ -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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]