emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-25 5d17ae7: Improve file-notify-test08-watched-file-


From: Michael Albinus
Subject: [Emacs-diffs] emacs-25 5d17ae7: Improve file-notify-test08-watched-file-in-watched-dir
Date: Sat, 20 Feb 2016 13:04:44 +0000

branch: emacs-25
commit 5d17ae7d467c2d6146a5792d676621aa3d69b21a
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>

    Improve file-notify-test08-watched-file-in-watched-dir
    
    * test/automated/file-notify-tests.el (file-notify--test-desc2):
    New variable.
    (file-notify--test-cleanup): Use it.
    (file-notify--test-event-handler): Enable trace.
    (file-notify-test08-watched-file-in-watched-dir): Tag it as
    :expensive-test.  Rewrite callbacks to use
    `file-notify--test-event-handler'.  Read events in loop.  Check
    `file-notify--test-results'.
    (file-notify-test08-watched-file-in-watched-dir): Fix docstring.
---
 test/automated/file-notify-tests.el |   54 ++++++++++++++++++++++-------------
 1 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/test/automated/file-notify-tests.el 
b/test/automated/file-notify-tests.el
index affe34a..1817484 100644
--- a/test/automated/file-notify-tests.el
+++ b/test/automated/file-notify-tests.el
@@ -59,6 +59,7 @@
 (defvar file-notify--test-tmpfile1 nil)
 (defvar file-notify--test-desc nil)
 (defvar file-notify--test-desc1 nil)
+(defvar file-notify--test-desc2 nil)
 (defvar file-notify--test-results nil)
 (defvar file-notify--test-event nil)
 (defvar file-notify--test-events nil)
@@ -79,6 +80,7 @@ It is different for local and remote file notification 
libraries.")
   "Cleanup after a test."
   (file-notify-rm-watch file-notify--test-desc)
   (file-notify-rm-watch file-notify--test-desc1)
+  (file-notify-rm-watch file-notify--test-desc2)
 
   (ignore-errors
     (delete-file (file-newest-backup file-notify--test-tmpfile)))
@@ -99,6 +101,7 @@ It is different for local and remote file notification 
libraries.")
         file-notify--test-tmpfile1 nil
         file-notify--test-desc nil
         file-notify--test-desc1 nil
+        file-notify--test-desc2 nil
         file-notify--test-results nil
         file-notify--test-events nil)
   (when file-notify--test-event
@@ -278,7 +281,7 @@ and the event to `file-notify--test-events'."
     (unless (string-match
             (regexp-quote ".#")
             (file-notify--event-file-name file-notify--test-event))
-      ;;(message "file-notify--test-event-handler %S" file-notify--test-event)
+      (message "file-notify--test-event-handler %S" file-notify--test-event)
       (setq file-notify--test-events
            (append file-notify--test-events `(,file-notify--test-event))
            file-notify--test-results
@@ -552,8 +555,8 @@ longer than timeout seconds for the events to be delivered."
          (let (file-notify--test-events)
            (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.
+        ;; Check the global sequence just to make sure that all
+        ;; results are as expected.
         (should file-notify--test-results)
         (dolist (result file-notify--test-results)
           (when (ert-test-failed-p result)
@@ -948,6 +951,7 @@ descriptors that were issued when registering the watches.  
This
 test caters for the situation in bug#22736 where the callback for
 the directory received events for the file with the descriptor of
 the file watch."
+  :tags '(:expensive-test)
   (skip-unless (file-notify--test-local-enabled))
 
   (unwind-protect
@@ -957,42 +961,52 @@ the file watch."
         (setq file-notify--test-tmpfile1
               (let ((temporary-file-directory file-notify--test-tmpfile))
                 (make-temp-file "file")))
-       (cl-flet ((dir-callback
-                   (ev)
-                   (should (equal file-notify--test-desc (car ev))))
-                  (file-callback
-                   (ev)
-                   (should (equal file-notify--test-desc1 (car ev)))))
+       (cl-flet ((dir-callback (event)
+                   (message "dir-callback %s" event)
+                   (let ((file-notify--test-desc file-notify--test-desc1))
+                     (file-notify--test-event-handler event)))
+                  (file-callback (event)
+                   (message "file-callback %s" event)
+                   (let ((file-notify--test-desc file-notify--test-desc2))
+                     (file-notify--test-event-handler event))))
           (should
-           (setq file-notify--test-desc
+           (setq file-notify--test-desc1
                  (file-notify-add-watch
                   file-notify--test-tmpfile
                   '(change attribute-change) #'dir-callback)))
           (should
-           (setq file-notify--test-desc1
+           (setq file-notify--test-desc2
                  (file-notify-add-watch
                   file-notify--test-tmpfile1
                   '(change attribute-change) #'file-callback)))
-          (should (file-notify-valid-p file-notify--test-desc))
           (should (file-notify-valid-p file-notify--test-desc1))
+          (should (file-notify-valid-p file-notify--test-desc2))
           (dotimes (i 100)
+            (read-event nil nil file-notify--test-read-event-timeout)
             (if (< 0 (random))
                 (write-region
                  "any text" nil file-notify--test-tmpfile1 t 'no-message)
               (let ((temporary-file-directory file-notify--test-tmpfile))
-                (make-temp-file "fileX")))))
-        ;; After saving the buffer, the descriptor is still valid.
-        (should (file-notify-valid-p file-notify--test-desc))
-        (should (file-notify-valid-p file-notify--test-desc1))
-       (delete-file file-notify--test-tmpfile1)
-        (delete-directory file-notify--test-tmpfile))
+                (make-temp-file "fileX"))))
+          ;; After saving the buffer, the descriptor is still valid.
+          (should (file-notify-valid-p file-notify--test-desc1))
+          (should (file-notify-valid-p file-notify--test-desc2))
+          (delete-file file-notify--test-tmpfile1)
+          (delete-directory file-notify--test-tmpfile 'recursive))
+
+        ;; Check the global sequence just to make sure that all
+        ;; results are as expected.
+        (should file-notify--test-results)
+        (dolist (result file-notify--test-results)
+          (when (ert-test-failed-p result)
+            (ert-fail
+             (cadr (ert-test-result-with-condition-condition result))))))
 
     ;; Cleanup.
     (file-notify--test-cleanup)))
 
 (file-notify--deftest-remote file-notify-test08-watched-file-in-watched-dir
-  "Checks what `file-notify-test08-watched-file-in-watched-dir'
-checks, just for a remote directory and file.")
+  "Check `file-notify-test08-watched-file-in-watched-dir' for remote files.")
 
 (defun file-notify-test-all (&optional interactive)
   "Run all tests for \\[file-notify]."



reply via email to

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