]> git.eshelyaron.com Git - emacs.git/commitdiff
New test with a larger number of events.
authorWolfgang Jenkner <wjenkner@inode.at>
Wed, 18 Nov 2015 18:24:27 +0000 (19:24 +0100)
committerWolfgang Jenkner <wjenkner@inode.at>
Wed, 18 Nov 2015 18:26:51 +0000 (19:26 +0100)
* test/automated/file-notify-tests.el (file-notify--test-with-events):
Make timeout heuristically depend on the number of events.

(file-notify-test06-many-events): Use it for new test.

test/automated/file-notify-tests.el

index 6946541b909309ee9f0331429b0740fa7116de81..f0068c547a5e2379f4c6e86ca8e2193da21b1c1e 100644 (file)
@@ -293,7 +293,8 @@ Don't wait longer than timeout seconds for the events to be delivered."
        (let (file-notify--test-events)
          ,@body
          (file-notify--wait-for-events
-          (file-notify--test-timeout)
+          ;; More events need more time.  Use some fudge factor.
+          (* (ceiling (length ,events) 100) (file-notify--test-timeout))
           (= (length ,events) (length file-notify--test-events)))
          (should (equal ,events (mapcar #'cadr file-notify--test-events)))
          (setq ,outer (append ,outer file-notify--test-events)))
@@ -637,6 +638,44 @@ Don't wait longer than timeout seconds for the events to be delivered."
 (file-notify--deftest-remote file-notify-test05-dir-validity
   "Check `file-notify-valid-p' via file notification for remote directories.")
 
+(ert-deftest file-notify-test06-many-events ()
+  "Check that events are not dropped."
+  (skip-unless (file-notify--test-local-enabled))
+  ;; Under cygwin there are so bad timings that it doesn't make sense to test.
+  (skip-unless (not (eq system-type 'cygwin)))
+  (setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
+  (make-directory file-notify--test-tmpfile)
+  (setq file-notify--test-desc
+        (file-notify-add-watch
+         file-notify--test-tmpfile
+         '(change) 'file-notify--test-event-handler))
+  (unwind-protect
+      (let ((n 1000)
+            x-file-list y-file-list
+            (default-directory file-notify--test-tmpfile))
+        (dotimes (i n)
+          (push (expand-file-name (format "x%d" i)) x-file-list)
+          (push (expand-file-name (format "y%d" i)) y-file-list))
+        (file-notify--test-with-events (make-list (+ n n) 'created)
+          (dolist (file x-file-list)
+            (write-region "" nil file nil 'no-message))
+          (dolist (file y-file-list)
+            (write-region "" nil file nil 'no-message)))
+        (file-notify--test-with-events (cond
+                                        ;; XXX Different results?
+                                        ((featurep 'kqueue)
+                                         (append (make-list n 'changed)
+                                                 (make-list n 'deleted)))
+                                        (t (make-list n 'renamed)))
+          (let ((x-file-list x-file-list)
+                (y-file-list y-file-list))
+            (while (and x-file-list y-file-list)
+              (rename-file (pop x-file-list) (pop y-file-list) t))))
+        (file-notify--test-with-events (make-list n 'deleted)
+          (dolist (file y-file-list)
+            (delete-file file))))
+    (file-notify--test-cleanup)))
+
 (defun file-notify-test-all (&optional interactive)
   "Run all tests for \\[file-notify]."
   (interactive "p")