aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorKen Brown2016-12-26 13:24:43 -0500
committerKen Brown2016-12-27 08:37:11 -0500
commiteff237503c321dd96e6bd509a5e34a9f1f6c75d9 (patch)
tree8992f2d88ad49270a4de0dc61de95df650b301dd /test
parent5d8bb89f0fa7d5f2824a914ce2b7c3841112c7a1 (diff)
downloademacs-eff237503c321dd96e6bd509a5e34a9f1f6c75d9.tar.gz
emacs-eff237503c321dd96e6bd509a5e34a9f1f6c75d9.zip
Improve filenotify-tests.el on Cygwin (Bug #21804)
* test/lisp/filenotify-tests.el [CYGWIN] (file-notify--test-read-event-timeout): Increase. (file-notify--test-with-events): Add delay before executing body. (file-notify-test02-events, file-notify-test04-file-validity): Adjust expected results.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/filenotify-tests.el78
1 files changed, 39 insertions, 39 deletions
diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el
index 0e6e58e7b80..1ed764fb976 100644
--- a/test/lisp/filenotify-tests.el
+++ b/test/lisp/filenotify-tests.el
@@ -64,7 +64,11 @@
64(defvar file-notify--test-event nil) 64(defvar file-notify--test-event nil)
65(defvar file-notify--test-events nil) 65(defvar file-notify--test-events nil)
66 66
67(defconst file-notify--test-read-event-timeout 0.01 67(defconst file-notify--test-read-event-timeout
68 (cond
69 ;; Some events take several seconds to arrive on cygwin.
70 ((eq system-type 'cygwin) 7)
71 (t 0.01))
68 "Timeout for `read-event' calls. 72 "Timeout for `read-event' calls.
69It is different for local and remote file notification libraries.") 73It is different for local and remote file notification libraries.")
70 74
@@ -388,6 +392,10 @@ delivered."
388 (not (input-pending-p))) 392 (not (input-pending-p)))
389 (setq file-notify--test-events nil 393 (setq file-notify--test-events nil
390 file-notify--test-results nil) 394 file-notify--test-results nil)
395 ;; cygwin needs a delay between setting a watch and beginning
396 ;; file activity, or else the first event is not sent.
397 (if (eq system-type 'cygwin)
398 (sleep-for 1))
391 ,@body 399 ,@body
392 (file-notify--wait-for-events 400 (file-notify--wait-for-events
393 ;; More events need more time. Use some fudge factor. 401 ;; More events need more time. Use some fudge factor.
@@ -409,10 +417,9 @@ delivered."
409 (unwind-protect 417 (unwind-protect
410 (progn 418 (progn
411 ;; Check file creation, change and deletion. It doesn't work 419 ;; Check file creation, change and deletion. It doesn't work
412 ;; for cygwin and kqueue, because we don't use an implicit 420 ;; for kqueue, because we don't use an implicit directory
413 ;; directory monitor (kqueue), or the timings are too bad (cygwin). 421 ;; monitor.
414 (unless (or (eq system-type 'cygwin) 422 (unless (string-equal (file-notify--test-library) "kqueue")
415 (string-equal (file-notify--test-library) "kqueue"))
416 (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)) 423 (setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
417 (should 424 (should
418 (setq file-notify--test-desc 425 (setq file-notify--test-desc
@@ -421,9 +428,9 @@ delivered."
421 '(change) #'file-notify--test-event-handler))) 428 '(change) #'file-notify--test-event-handler)))
422 (file-notify--test-with-events 429 (file-notify--test-with-events
423 (cond 430 (cond
424 ;; cygwin recognizes only `deleted' and `stopped' events. 431 ;; cygwin does not raise a `changed' event.
425 ((eq system-type 'cygwin) 432 ((eq system-type 'cygwin)
426 '(deleted stopped)) 433 '(created deleted stopped))
427 (t '(created changed deleted stopped))) 434 (t '(created changed deleted stopped)))
428 (write-region 435 (write-region
429 "another text" nil file-notify--test-tmpfile nil 'no-message) 436 "another text" nil file-notify--test-tmpfile nil 'no-message)
@@ -440,13 +447,9 @@ delivered."
440 file-notify--test-tmpfile 447 file-notify--test-tmpfile
441 '(change) #'file-notify--test-event-handler))) 448 '(change) #'file-notify--test-event-handler)))
442 (file-notify--test-with-events 449 (file-notify--test-with-events
443 (cond 450 ;; There could be one or two `changed' events.
444 ;; cygwin recognizes only `deleted' and `stopped' events. 451 '((changed deleted stopped)
445 ((eq system-type 'cygwin) 452 (changed changed deleted stopped))
446 '(deleted stopped))
447 ;; There could be one or two `changed' events.
448 (t '((changed deleted stopped)
449 (changed changed deleted stopped))))
450 (write-region 453 (write-region
451 "another text" nil file-notify--test-tmpfile nil 'no-message) 454 "another text" nil file-notify--test-tmpfile nil 'no-message)
452 (read-event nil nil file-notify--test-read-event-timeout) 455 (read-event nil nil file-notify--test-read-event-timeout)
@@ -470,11 +473,11 @@ delivered."
470 ;; events for the watched directory. 473 ;; events for the watched directory.
471 ((string-equal (file-notify--test-library) "w32notify") 474 ((string-equal (file-notify--test-library) "w32notify")
472 '(created changed deleted)) 475 '(created changed deleted))
473 ;; cygwin recognizes only `deleted' and `stopped' events.
474 ((eq system-type 'cygwin)
475 '(deleted stopped))
476 ;; There are two `deleted' events, for the file and for 476 ;; There are two `deleted' events, for the file and for
477 ;; the directory. Except for kqueue. 477 ;; the directory. Except for cygwin and kqueue. And
478 ;; cygwin does not raise a `changed' event.
479 ((eq system-type 'cygwin)
480 '(created deleted stopped))
478 ((string-equal (file-notify--test-library) "kqueue") 481 ((string-equal (file-notify--test-library) "kqueue")
479 '(created changed deleted stopped)) 482 '(created changed deleted stopped))
480 (t '(created changed deleted deleted stopped))) 483 (t '(created changed deleted deleted stopped)))
@@ -503,11 +506,10 @@ delivered."
503 '(created changed created changed 506 '(created changed created changed
504 changed changed changed 507 changed changed changed
505 deleted deleted)) 508 deleted deleted))
506 ;; cygwin recognizes only `deleted' and `stopped' events.
507 ((eq system-type 'cygwin)
508 '(deleted stopped))
509 ;; There are three `deleted' events, for two files and 509 ;; There are three `deleted' events, for two files and
510 ;; for the directory. Except for kqueue. 510 ;; for the directory. Except for cygwin and kqueue.
511 ((eq system-type 'cygwin)
512 '(created created changed changed deleted stopped))
511 ((string-equal (file-notify--test-library) "kqueue") 513 ((string-equal (file-notify--test-library) "kqueue")
512 '(created changed created changed deleted stopped)) 514 '(created changed created changed deleted stopped))
513 (t '(created changed created changed 515 (t '(created changed created changed
@@ -541,11 +543,12 @@ delivered."
541 ;; events for the watched directory. 543 ;; events for the watched directory.
542 ((string-equal (file-notify--test-library) "w32notify") 544 ((string-equal (file-notify--test-library) "w32notify")
543 '(created changed renamed deleted)) 545 '(created changed renamed deleted))
544 ;; cygwin recognizes only `deleted' and `stopped' events.
545 ((eq system-type 'cygwin)
546 '(deleted stopped))
547 ;; There are two `deleted' events, for the file and for 546 ;; There are two `deleted' events, for the file and for
548 ;; the directory. Except for kqueue. 547 ;; the directory. Except for cygwin and kqueue. And
548 ;; cygwin raises `created' and `deleted' events instead
549 ;; of a `renamed' event.
550 ((eq system-type 'cygwin)
551 '(created created deleted deleted stopped))
549 ((string-equal (file-notify--test-library) "kqueue") 552 ((string-equal (file-notify--test-library) "kqueue")
550 '(created changed renamed deleted stopped)) 553 '(created changed renamed deleted stopped))
551 (t '(created changed renamed deleted deleted stopped))) 554 (t '(created changed renamed deleted deleted stopped)))
@@ -728,13 +731,9 @@ delivered."
728 '(change) #'file-notify--test-event-handler))) 731 '(change) #'file-notify--test-event-handler)))
729 (should (file-notify-valid-p file-notify--test-desc)) 732 (should (file-notify-valid-p file-notify--test-desc))
730 (file-notify--test-with-events 733 (file-notify--test-with-events
731 (cond
732 ;; cygwin recognizes only `deleted' and `stopped' events.
733 ((eq system-type 'cygwin)
734 '(deleted stopped))
735 ;; There could be one or two `changed' events. 734 ;; There could be one or two `changed' events.
736 (t '((changed deleted stopped) 735 '((changed deleted stopped)
737 (changed changed deleted stopped)))) 736 (changed changed deleted stopped))
738 (write-region 737 (write-region
739 "another text" nil file-notify--test-tmpfile nil 'no-message) 738 "another text" nil file-notify--test-tmpfile nil 'no-message)
740 (read-event nil nil file-notify--test-read-event-timeout) 739 (read-event nil nil file-notify--test-read-event-timeout)
@@ -765,11 +764,11 @@ delivered."
765 ;; for the watched directory. 764 ;; for the watched directory.
766 ((string-equal (file-notify--test-library) "w32notify") 765 ((string-equal (file-notify--test-library) "w32notify")
767 '(created changed deleted)) 766 '(created changed deleted))
768 ;; cygwin recognizes only `deleted' and `stopped' events.
769 ((eq system-type 'cygwin)
770 '(deleted stopped))
771 ;; There are two `deleted' events, for the file and for the 767 ;; There are two `deleted' events, for the file and for the
772 ;; directory. Except for kqueue. 768 ;; directory. Except for cygwin and kqueue. And cygwin
769 ;; does not raise a `changed' event.
770 ((eq system-type 'cygwin)
771 '(created deleted stopped))
773 ((string-equal (file-notify--test-library) "kqueue") 772 ((string-equal (file-notify--test-library) "kqueue")
774 '(created changed deleted stopped)) 773 '(created changed deleted stopped))
775 (t '(created changed deleted deleted stopped))) 774 (t '(created changed deleted deleted stopped)))
@@ -1172,9 +1171,10 @@ the file watch."
1172;; the missing directory monitor. 1171;; the missing directory monitor.
1173;; * For w32notify, no `deleted' and `stopped' events arrive when a 1172;; * For w32notify, no `deleted' and `stopped' events arrive when a
1174;; directory is removed. 1173;; directory is removed.
1175;; * For w32notify, no `attribute-changed' events arrive. Its sends 1174;; * For cygwin and w32notify, no `attribute-changed' events arrive.
1176;; `changed' events instead. 1175;; They send `changed' events instead.
1177;; * Check, why cygwin recognizes only `deleted' and `stopped' events. 1176;; * cygwin does not send all expected `changed' and `deleted' events.
1177;; Probably due to timing issues.
1178 1178
1179(provide 'file-notify-tests) 1179(provide 'file-notify-tests)
1180;;; filenotify-tests.el ends here 1180;;; filenotify-tests.el ends here