aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMichael Albinus2016-06-06 18:25:28 +0200
committerMichael Albinus2016-06-06 18:25:28 +0200
commitc0462e120d064cb5943b31a9c8dfec1c62712a9f (patch)
treef4f857a8dac28c120db51d2b3579fb5e09d66b86 /test
parent66d5c75e2dd9f4204b51a5d3299456ecc4ea6842 (diff)
downloademacs-c0462e120d064cb5943b31a9c8dfec1c62712a9f.tar.gz
emacs-c0462e120d064cb5943b31a9c8dfec1c62712a9f.zip
Some fixes in filenotify-tests.el for cygwin
* test/lisp/filenotify-tests.el (file-notify--test-timeout): Reintroduce value for cygwin, it's needed on slow systems. (file-notify--wait-for-events): Move up definition. (file-notify--test-no-descriptors): Use `file-notify--wait-for-events'. (file-notify--test-with-events-check, file-notify--test-with-events) (file-notify-test08-watched-file-in-watched-dir): Use :random rather than `random. (file-notify-test06-many-events): Do not skip for cygwin.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/filenotify-tests.el38
1 files changed, 22 insertions, 16 deletions
diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el
index a7f89cfcc9f..518a1eb1f5a 100644
--- a/test/lisp/filenotify-tests.el
+++ b/test/lisp/filenotify-tests.el
@@ -73,14 +73,23 @@ It is different for local and remote file notification libraries.")
73 (cond 73 (cond
74 ((file-remote-p temporary-file-directory) 6) 74 ((file-remote-p temporary-file-directory) 6)
75 ((string-equal (file-notify--test-library) "w32notify") 4) 75 ((string-equal (file-notify--test-library) "w32notify") 4)
76 ((eq system-type 'cygwin) 6)
76 (t 3))) 77 (t 3)))
77 78
79(defmacro file-notify--wait-for-events (timeout until)
80 "Wait for and return file notification events until form UNTIL is true.
81TIMEOUT is the maximum time to wait for, in seconds."
82 `(with-timeout (,timeout (ignore))
83 (while (null ,until)
84 (read-event nil nil file-notify--test-read-event-timeout))))
85
78(defun file-notify--test-no-descriptors () 86(defun file-notify--test-no-descriptors ()
79 "Check that `file-notify-descriptors' is an empty hash table. 87 "Check that `file-notify-descriptors' is an empty hash table.
80Return nil when any other file notification watch is still active." 88Return nil when any other file notification watch is still active."
81 ;; Give read events a last chance. 89 ;; Give read events a last chance.
82 (unless (zerop (hash-table-count file-notify-descriptors)) 90 (file-notify--wait-for-events
83 (read-event nil nil file-notify--test-read-event-timeout)) 91 (file-notify--test-timeout)
92 (zerop (hash-table-count file-notify-descriptors)))
84 ;; Now check. 93 ;; Now check.
85 (zerop (hash-table-count file-notify-descriptors))) 94 (zerop (hash-table-count file-notify-descriptors)))
86 95
@@ -331,20 +340,13 @@ and the event to `file-notify--test-events'."
331 (expand-file-name 340 (expand-file-name
332 (make-temp-name "file-notify-test") temporary-file-directory)) 341 (make-temp-name "file-notify-test") temporary-file-directory))
333 342
334(defmacro file-notify--wait-for-events (timeout until)
335 "Wait for and return file notification events until form UNTIL is true.
336TIMEOUT is the maximum time to wait for, in seconds."
337 `(with-timeout (,timeout (ignore))
338 (while (null ,until)
339 (read-event nil nil file-notify--test-read-event-timeout))))
340
341(defun file-notify--test-with-events-check (events) 343(defun file-notify--test-with-events-check (events)
342 "Check whether received events match one of the EVENTS alternatives." 344 "Check whether received events match one of the EVENTS alternatives."
343 (let (result) 345 (let (result)
344 (dolist (elt events result) 346 (dolist (elt events result)
345 (setq result 347 (setq result
346 (or result 348 (or result
347 (if (eq (car elt) 'random) 349 (if (eq (car elt) :random)
348 (equal (sort (cdr elt) 'string-lessp) 350 (equal (sort (cdr elt) 'string-lessp)
349 (sort (mapcar #'cadr file-notify--test-events) 351 (sort (mapcar #'cadr file-notify--test-events)
350 'string-lessp)) 352 'string-lessp))
@@ -366,7 +368,7 @@ TIMEOUT is the maximum time to wait for, in seconds."
366 "Run BODY collecting events and then compare with EVENTS. 368 "Run BODY collecting events and then compare with EVENTS.
367EVENTS is either a simple list of events, or a list of lists of 369EVENTS is either a simple list of events, or a list of lists of
368events, which represent different possible results. The first 370events, which represent different possible results. The first
369event of a list could be the pseudo event `random', which is 371event of a list could be the pseudo event `:random', which is
370just an indicator for comparison. 372just an indicator for comparison.
371 373
372Don't wait longer than timeout seconds for the events to be 374Don't wait longer than timeout seconds for the events to be
@@ -377,7 +379,7 @@ delivered."
377 (apply 379 (apply
378 'max 380 'max
379 (mapcar 381 (mapcar
380 (lambda (x) (length (if (eq (car x) 'random) (cdr x) x))) 382 (lambda (x) (length (if (eq (car x) :random) (cdr x) x)))
381 events))) 383 events)))
382 create-lockfiles) 384 create-lockfiles)
383 ;; Flush pending events. 385 ;; Flush pending events.
@@ -862,8 +864,6 @@ delivered."
862 "Check that events are not dropped." 864 "Check that events are not dropped."
863 :tags '(:expensive-test) 865 :tags '(:expensive-test)
864 (skip-unless (file-notify--test-local-enabled)) 866 (skip-unless (file-notify--test-local-enabled))
865 ;; Under cygwin events arrive in random order. Impossible to define a test.
866 (skip-unless (not (eq system-type 'cygwin)))
867 867
868 (should 868 (should
869 (setq file-notify--test-tmpfile 869 (setq file-notify--test-tmpfile
@@ -902,6 +902,12 @@ delivered."
902 (let (r) 902 (let (r)
903 (dotimes (_i n r) 903 (dotimes (_i n r)
904 (setq r (append '(deleted renamed) r))))) 904 (setq r (append '(deleted renamed) r)))))
905 ;; cygwin fires `changed' and `deleted' events, sometimes
906 ;; in random order.
907 ((eq system-type 'cygwin)
908 (let ((r '(:random)))
909 (dotimes (_i n r)
910 (setq r (append r '(changed deleted))))))
905 (t (make-list n 'renamed))) 911 (t (make-list n 'renamed)))
906 (let ((source-file-list source-file-list) 912 (let ((source-file-list source-file-list)
907 (target-file-list target-file-list)) 913 (target-file-list target-file-list))
@@ -1090,7 +1096,7 @@ the file watch."
1090 events))) 1096 events)))
1091 ;; gvfs-monitor-dir returns the events in random order. 1097 ;; gvfs-monitor-dir returns the events in random order.
1092 (when (string-equal "gvfs-monitor-dir" (file-notify--test-library)) 1098 (when (string-equal "gvfs-monitor-dir" (file-notify--test-library))
1093 (setq events (cons 'random events))) 1099 (setq events (cons :random events)))
1094 1100
1095 ;; Run the test. 1101 ;; Run the test.
1096 (file-notify--test-with-events events 1102 (file-notify--test-with-events events
@@ -1109,7 +1115,7 @@ the file watch."
1109 ;; directory and the file monitor. The `stopped' event is 1115 ;; directory and the file monitor. The `stopped' event is
1110 ;; from the file monitor. It's undecided in which order the 1116 ;; from the file monitor. It's undecided in which order the
1111 ;; the directory and the file monitor are triggered. 1117 ;; the directory and the file monitor are triggered.
1112 (file-notify--test-with-events '(random deleted deleted stopped) 1118 (file-notify--test-with-events '(:random deleted deleted stopped)
1113 (delete-file file-notify--test-tmpfile1)) 1119 (delete-file file-notify--test-tmpfile1))
1114 (should (file-notify-valid-p file-notify--test-desc1)) 1120 (should (file-notify-valid-p file-notify--test-desc1))
1115 (should-not (file-notify-valid-p file-notify--test-desc2)) 1121 (should-not (file-notify-valid-p file-notify--test-desc2))