aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTassilo Horn2016-02-20 08:33:11 +0100
committerTassilo Horn2016-02-20 08:44:51 +0100
commit2a75f64dd2cdc714da70321e61ca38e79af8b100 (patch)
tree1d1d53e92dfa1ca078f854dc1d6d49a79a5a17f7
parentc9bccf72cbaed5ca2fb5b829687886db92fa6d6b (diff)
downloademacs-2a75f64dd2cdc714da70321e61ca38e79af8b100.tar.gz
emacs-2a75f64dd2cdc714da70321e61ca38e79af8b100.zip
New filenotify test for bug#22736
* test/automated/file-notify-tests.el (file-notify-test08-watched-file-in-watched-dir): (file-notify--test-desc1): New filenotify test for bug#22736
-rw-r--r--test/automated/file-notify-tests.el56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/automated/file-notify-tests.el b/test/automated/file-notify-tests.el
index a8521828c0e..affe34aef3f 100644
--- a/test/automated/file-notify-tests.el
+++ b/test/automated/file-notify-tests.el
@@ -58,6 +58,7 @@
58(defvar file-notify--test-tmpfile nil) 58(defvar file-notify--test-tmpfile nil)
59(defvar file-notify--test-tmpfile1 nil) 59(defvar file-notify--test-tmpfile1 nil)
60(defvar file-notify--test-desc nil) 60(defvar file-notify--test-desc nil)
61(defvar file-notify--test-desc1 nil)
61(defvar file-notify--test-results nil) 62(defvar file-notify--test-results nil)
62(defvar file-notify--test-event nil) 63(defvar file-notify--test-event nil)
63(defvar file-notify--test-events nil) 64(defvar file-notify--test-events nil)
@@ -77,6 +78,7 @@ It is different for local and remote file notification libraries.")
77(defun file-notify--test-cleanup () 78(defun file-notify--test-cleanup ()
78 "Cleanup after a test." 79 "Cleanup after a test."
79 (file-notify-rm-watch file-notify--test-desc) 80 (file-notify-rm-watch file-notify--test-desc)
81 (file-notify-rm-watch file-notify--test-desc1)
80 82
81 (ignore-errors 83 (ignore-errors
82 (delete-file (file-newest-backup file-notify--test-tmpfile))) 84 (delete-file (file-newest-backup file-notify--test-tmpfile)))
@@ -96,6 +98,7 @@ It is different for local and remote file notification libraries.")
96 (setq file-notify--test-tmpfile nil 98 (setq file-notify--test-tmpfile nil
97 file-notify--test-tmpfile1 nil 99 file-notify--test-tmpfile1 nil
98 file-notify--test-desc nil 100 file-notify--test-desc nil
101 file-notify--test-desc1 nil
99 file-notify--test-results nil 102 file-notify--test-results nil
100 file-notify--test-events nil) 103 file-notify--test-events nil)
101 (when file-notify--test-event 104 (when file-notify--test-event
@@ -938,6 +941,59 @@ longer than timeout seconds for the events to be delivered."
938(file-notify--deftest-remote file-notify-test07-backup 941(file-notify--deftest-remote file-notify-test07-backup
939 "Check that backup keeps file notification for remote files.") 942 "Check that backup keeps file notification for remote files.")
940 943
944(ert-deftest file-notify-test08-watched-file-in-watched-dir ()
945 "Watches a directory and a file in that directory separately.
946Checks that the callbacks are only called with events with
947descriptors that were issued when registering the watches. This
948test caters for the situation in bug#22736 where the callback for
949the directory received events for the file with the descriptor of
950the file watch."
951 (skip-unless (file-notify--test-local-enabled))
952
953 (unwind-protect
954 (progn
955 (setq file-notify--test-tmpfile
956 (make-temp-file "dir" t))
957 (setq file-notify--test-tmpfile1
958 (let ((temporary-file-directory file-notify--test-tmpfile))
959 (make-temp-file "file")))
960 (cl-flet ((dir-callback
961 (ev)
962 (should (equal file-notify--test-desc (car ev))))
963 (file-callback
964 (ev)
965 (should (equal file-notify--test-desc1 (car ev)))))
966 (should
967 (setq file-notify--test-desc
968 (file-notify-add-watch
969 file-notify--test-tmpfile
970 '(change attribute-change) #'dir-callback)))
971 (should
972 (setq file-notify--test-desc1
973 (file-notify-add-watch
974 file-notify--test-tmpfile1
975 '(change attribute-change) #'file-callback)))
976 (should (file-notify-valid-p file-notify--test-desc))
977 (should (file-notify-valid-p file-notify--test-desc1))
978 (dotimes (i 100)
979 (if (< 0 (random))
980 (write-region
981 "any text" nil file-notify--test-tmpfile1 t 'no-message)
982 (let ((temporary-file-directory file-notify--test-tmpfile))
983 (make-temp-file "fileX")))))
984 ;; After saving the buffer, the descriptor is still valid.
985 (should (file-notify-valid-p file-notify--test-desc))
986 (should (file-notify-valid-p file-notify--test-desc1))
987 (delete-file file-notify--test-tmpfile1)
988 (delete-directory file-notify--test-tmpfile))
989
990 ;; Cleanup.
991 (file-notify--test-cleanup)))
992
993(file-notify--deftest-remote file-notify-test08-watched-file-in-watched-dir
994 "Checks what `file-notify-test08-watched-file-in-watched-dir'
995checks, just for a remote directory and file.")
996
941(defun file-notify-test-all (&optional interactive) 997(defun file-notify-test-all (&optional interactive)
942 "Run all tests for \\[file-notify]." 998 "Run all tests for \\[file-notify]."
943 (interactive "p") 999 (interactive "p")