aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWolfgang Jenkner2015-11-18 19:24:27 +0100
committerWolfgang Jenkner2015-11-18 19:26:51 +0100
commit0d45fc135cb2ac17aa776cc5bd5b339bf20514ae (patch)
treeea0990efb8f25716dbfda19779f8da26ba28d952
parent5f08a72c8bf88d4f6f564c5890ec937f59605463 (diff)
downloademacs-0d45fc135cb2ac17aa776cc5bd5b339bf20514ae.tar.gz
emacs-0d45fc135cb2ac17aa776cc5bd5b339bf20514ae.zip
New test with a larger number of events.
* 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.
-rw-r--r--test/automated/file-notify-tests.el41
1 files changed, 40 insertions, 1 deletions
diff --git a/test/automated/file-notify-tests.el b/test/automated/file-notify-tests.el
index 6946541b909..f0068c547a5 100644
--- a/test/automated/file-notify-tests.el
+++ b/test/automated/file-notify-tests.el
@@ -293,7 +293,8 @@ Don't wait longer than timeout seconds for the events to be delivered."
293 (let (file-notify--test-events) 293 (let (file-notify--test-events)
294 ,@body 294 ,@body
295 (file-notify--wait-for-events 295 (file-notify--wait-for-events
296 (file-notify--test-timeout) 296 ;; More events need more time. Use some fudge factor.
297 (* (ceiling (length ,events) 100) (file-notify--test-timeout))
297 (= (length ,events) (length file-notify--test-events))) 298 (= (length ,events) (length file-notify--test-events)))
298 (should (equal ,events (mapcar #'cadr file-notify--test-events))) 299 (should (equal ,events (mapcar #'cadr file-notify--test-events)))
299 (setq ,outer (append ,outer file-notify--test-events))) 300 (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."
637(file-notify--deftest-remote file-notify-test05-dir-validity 638(file-notify--deftest-remote file-notify-test05-dir-validity
638 "Check `file-notify-valid-p' via file notification for remote directories.") 639 "Check `file-notify-valid-p' via file notification for remote directories.")
639 640
641(ert-deftest file-notify-test06-many-events ()
642 "Check that events are not dropped."
643 (skip-unless (file-notify--test-local-enabled))
644 ;; Under cygwin there are so bad timings that it doesn't make sense to test.
645 (skip-unless (not (eq system-type 'cygwin)))
646 (setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
647 (make-directory file-notify--test-tmpfile)
648 (setq file-notify--test-desc
649 (file-notify-add-watch
650 file-notify--test-tmpfile
651 '(change) 'file-notify--test-event-handler))
652 (unwind-protect
653 (let ((n 1000)
654 x-file-list y-file-list
655 (default-directory file-notify--test-tmpfile))
656 (dotimes (i n)
657 (push (expand-file-name (format "x%d" i)) x-file-list)
658 (push (expand-file-name (format "y%d" i)) y-file-list))
659 (file-notify--test-with-events (make-list (+ n n) 'created)
660 (dolist (file x-file-list)
661 (write-region "" nil file nil 'no-message))
662 (dolist (file y-file-list)
663 (write-region "" nil file nil 'no-message)))
664 (file-notify--test-with-events (cond
665 ;; XXX Different results?
666 ((featurep 'kqueue)
667 (append (make-list n 'changed)
668 (make-list n 'deleted)))
669 (t (make-list n 'renamed)))
670 (let ((x-file-list x-file-list)
671 (y-file-list y-file-list))
672 (while (and x-file-list y-file-list)
673 (rename-file (pop x-file-list) (pop y-file-list) t))))
674 (file-notify--test-with-events (make-list n 'deleted)
675 (dolist (file y-file-list)
676 (delete-file file))))
677 (file-notify--test-cleanup)))
678
640(defun file-notify-test-all (&optional interactive) 679(defun file-notify-test-all (&optional interactive)
641 "Run all tests for \\[file-notify]." 680 "Run all tests for \\[file-notify]."
642 (interactive "p") 681 (interactive "p")