diff options
| author | Michael Albinus | 2015-11-18 13:47:25 +0000 |
|---|---|---|
| committer | Michael Albinus | 2015-11-25 15:07:11 +0100 |
| commit | 65ba5a98d47f4305f95f960efdf424684754a11d (patch) | |
| tree | 644b229abb093a6024446bf4655d1aa0b460b453 | |
| parent | 13f3508443e4f5c48d40e4dbb11eaf875a5b2042 (diff) | |
| download | emacs-65ba5a98d47f4305f95f960efdf424684754a11d.tar.gz emacs-65ba5a98d47f4305f95f960efdf424684754a11d.zip | |
Further fixes for kqueue.
* lisp/filenotify.el (file-notify-callback): Raise also event if
directory name matches.
(file-notify-add-watch): Add `create' to the flags for `kqueue'.
* src/kqueue.c (kqueue_generate_event): Use watch_object as
argument instead of ident. Remove callback argument. Adapt
callees. Check actions whether they are monitored flags.
* test/automated/file-notify-tests.el (file-notify--test-library):
New defun.
(file-notify-test00-availability, file-notify-test02-events)
(file-notify-test04-file-validity)
(file-notify-test05-dir-validity): Use it.
(file-notify-test02-events, file-notify-test04-file-validity): Add
`read-event' calls between different file actions, in order to
give the backends a chance to rais an event. Needed especially
for kqueue. In case of deleting a directory, there are two
`deleted' events.
| -rw-r--r-- | lisp/filenotify.el | 6 | ||||
| -rw-r--r-- | src/kqueue.c | 81 | ||||
| -rw-r--r-- | test/automated/file-notify-tests.el | 59 |
3 files changed, 91 insertions, 55 deletions
diff --git a/lisp/filenotify.el b/lisp/filenotify.el index eb869cf66a9..5072bf414bf 100644 --- a/lisp/filenotify.el +++ b/lisp/filenotify.el | |||
| @@ -258,6 +258,10 @@ EVENT is the cadr of the event in `file-notify-handle-event' | |||
| 258 | ;; File matches. | 258 | ;; File matches. |
| 259 | (string-equal | 259 | (string-equal |
| 260 | (nth 0 entry) (file-name-nondirectory file)) | 260 | (nth 0 entry) (file-name-nondirectory file)) |
| 261 | ;; Directory matches. | ||
| 262 | (string-equal | ||
| 263 | (file-name-nondirectory file) | ||
| 264 | (file-name-nondirectory (car registered))) | ||
| 261 | ;; File1 matches. | 265 | ;; File1 matches. |
| 262 | (and (stringp file1) | 266 | (and (stringp file1) |
| 263 | (string-equal | 267 | (string-equal |
| @@ -364,7 +368,7 @@ FILE is the name of the file whose event is being reported." | |||
| 364 | ((eq file-notify--library 'inotify) | 368 | ((eq file-notify--library 'inotify) |
| 365 | '(create delete delete-self modify move-self move)) | 369 | '(create delete delete-self modify move-self move)) |
| 366 | ((eq file-notify--library 'kqueue) | 370 | ((eq file-notify--library 'kqueue) |
| 367 | '(delete write extend rename)) | 371 | '(create delete write extend rename)) |
| 368 | ((eq file-notify--library 'w32notify) | 372 | ((eq file-notify--library 'w32notify) |
| 369 | '(file-name directory-name size last-write-time))))) | 373 | '(file-name directory-name size last-write-time))))) |
| 370 | (when (memq 'attribute-change flags) | 374 | (when (memq 'attribute-change flags) |
diff --git a/src/kqueue.c b/src/kqueue.c index 5caef67b92a..e2c9dabcb20 100644 --- a/src/kqueue.c +++ b/src/kqueue.c | |||
| @@ -67,21 +67,39 @@ kqueue_directory_listing (Lisp_Object directory_files) | |||
| 67 | /* Generate a file notification event. */ | 67 | /* Generate a file notification event. */ |
| 68 | static void | 68 | static void |
| 69 | kqueue_generate_event | 69 | kqueue_generate_event |
| 70 | (Lisp_Object ident, Lisp_Object actions, Lisp_Object file, Lisp_Object file1, | 70 | (Lisp_Object watch_object, Lisp_Object actions, |
| 71 | Lisp_Object callback) | 71 | Lisp_Object file, Lisp_Object file1) |
| 72 | { | 72 | { |
| 73 | Lisp_Object flags, action, entry; | ||
| 73 | struct input_event event; | 74 | struct input_event event; |
| 74 | EVENT_INIT (event); | 75 | |
| 75 | event.kind = FILE_NOTIFY_EVENT; | 76 | /* Check, whether all actions shall be monitored. */ |
| 76 | event.frame_or_window = Qnil; | 77 | flags = Fnth (make_number (2), watch_object); |
| 77 | event.arg = list2 (Fcons (ident, Fcons (actions, | 78 | action = actions; |
| 78 | NILP (file1) | 79 | do { |
| 79 | ? Fcons (file, Qnil) | 80 | if (NILP (action)) |
| 80 | : list2 (file, file1))), | 81 | break; |
| 81 | callback); | 82 | entry = XCAR (action); |
| 83 | if (NILP (Fmember (entry, flags))) { | ||
| 84 | action = XCDR (action); | ||
| 85 | actions = Fdelq (entry, actions); | ||
| 86 | } else | ||
| 87 | action = XCDR (action); | ||
| 88 | } while (1); | ||
| 82 | 89 | ||
| 83 | /* Store it into the input event queue. */ | 90 | /* Store it into the input event queue. */ |
| 84 | kbd_buffer_store_event (&event); | 91 | if (! NILP (actions)) { |
| 92 | EVENT_INIT (event); | ||
| 93 | event.kind = FILE_NOTIFY_EVENT; | ||
| 94 | event.frame_or_window = Qnil; | ||
| 95 | event.arg = list2 (Fcons (XCAR (watch_object), | ||
| 96 | Fcons (actions, | ||
| 97 | NILP (file1) | ||
| 98 | ? Fcons (file, Qnil) | ||
| 99 | : list2 (file, file1))), | ||
| 100 | Fnth (make_number (3), watch_object)); | ||
| 101 | kbd_buffer_store_event (&event); | ||
| 102 | } | ||
| 85 | } | 103 | } |
| 86 | 104 | ||
| 87 | /* This compares two directory listings in case of a `write' event for | 105 | /* This compares two directory listings in case of a `write' event for |
| @@ -93,19 +111,16 @@ static void | |||
| 93 | kqueue_compare_dir_list | 111 | kqueue_compare_dir_list |
| 94 | (Lisp_Object watch_object) | 112 | (Lisp_Object watch_object) |
| 95 | { | 113 | { |
| 96 | Lisp_Object dir, callback; | 114 | Lisp_Object dir, old_directory_files, old_dl, new_directory_files, new_dl, dl; |
| 97 | Lisp_Object old_directory_files, old_dl, new_directory_files, new_dl, dl; | ||
| 98 | 115 | ||
| 99 | dir = XCAR (XCDR (watch_object)); | 116 | dir = XCAR (XCDR (watch_object)); |
| 100 | callback = Fnth (make_number (3), watch_object); | ||
| 101 | 117 | ||
| 102 | old_directory_files = Fnth (make_number (4), watch_object); | 118 | old_directory_files = Fnth (make_number (4), watch_object); |
| 103 | old_dl = kqueue_directory_listing (old_directory_files); | 119 | old_dl = kqueue_directory_listing (old_directory_files); |
| 104 | 120 | ||
| 105 | /* When the directory is not accessible anymore, it has been deleted. */ | 121 | /* When the directory is not accessible anymore, it has been deleted. */ |
| 106 | if (NILP (Ffile_directory_p (dir))) { | 122 | if (NILP (Ffile_directory_p (dir))) { |
| 107 | kqueue_generate_event | 123 | kqueue_generate_event (watch_object, Fcons (Qdelete, Qnil), dir, Qnil); |
| 108 | (XCAR (watch_object), Fcons (Qdelete, Qnil), dir, Qnil, callback); | ||
| 109 | return; | 124 | return; |
| 110 | } | 125 | } |
| 111 | new_directory_files = | 126 | new_directory_files = |
| @@ -137,21 +152,20 @@ kqueue_compare_dir_list | |||
| 137 | if (NILP (Fequal (Fnth (make_number (2), old_entry), | 152 | if (NILP (Fequal (Fnth (make_number (2), old_entry), |
| 138 | Fnth (make_number (2), new_entry)))) | 153 | Fnth (make_number (2), new_entry)))) |
| 139 | kqueue_generate_event | 154 | kqueue_generate_event |
| 140 | (XCAR (watch_object), Fcons (Qwrite, Qnil), | 155 | (watch_object, Fcons (Qwrite, Qnil), XCAR (XCDR (old_entry)), Qnil); |
| 141 | XCAR (XCDR (old_entry)), Qnil, callback); | ||
| 142 | /* Status change time has been changed, the file attributes | 156 | /* Status change time has been changed, the file attributes |
| 143 | have changed. */ | 157 | have changed. */ |
| 144 | if (NILP (Fequal (Fnth (make_number (3), old_entry), | 158 | if (NILP (Fequal (Fnth (make_number (3), old_entry), |
| 145 | Fnth (make_number (3), new_entry)))) | 159 | Fnth (make_number (3), new_entry)))) |
| 146 | kqueue_generate_event | 160 | kqueue_generate_event |
| 147 | (XCAR (watch_object), Fcons (Qattrib, Qnil), | 161 | (watch_object, Fcons (Qattrib, Qnil), |
| 148 | XCAR (XCDR (old_entry)), Qnil, callback); | 162 | XCAR (XCDR (old_entry)), Qnil); |
| 149 | 163 | ||
| 150 | } else { | 164 | } else { |
| 151 | /* The file has been renamed. */ | 165 | /* The file has been renamed. */ |
| 152 | kqueue_generate_event | 166 | kqueue_generate_event |
| 153 | (XCAR (watch_object), Fcons (Qrename, Qnil), | 167 | (watch_object, Fcons (Qrename, Qnil), |
| 154 | XCAR (XCDR (old_entry)), XCAR (XCDR (new_entry)), callback); | 168 | XCAR (XCDR (old_entry)), XCAR (XCDR (new_entry))); |
| 155 | } | 169 | } |
| 156 | new_dl = Fdelq (new_entry, new_dl); | 170 | new_dl = Fdelq (new_entry, new_dl); |
| 157 | goto the_end; | 171 | goto the_end; |
| @@ -164,8 +178,7 @@ kqueue_compare_dir_list | |||
| 164 | if (strcmp (SSDATA (XCAR (XCDR (old_entry))), | 178 | if (strcmp (SSDATA (XCAR (XCDR (old_entry))), |
| 165 | SSDATA (XCAR (XCDR (new_entry)))) == 0) { | 179 | SSDATA (XCAR (XCDR (new_entry)))) == 0) { |
| 166 | kqueue_generate_event | 180 | kqueue_generate_event |
| 167 | (XCAR (watch_object), Fcons (Qwrite, Qnil), | 181 | (watch_object, Fcons (Qwrite, Qnil), XCAR (XCDR (old_entry)), Qnil); |
| 168 | XCAR (XCDR (old_entry)), Qnil, callback); | ||
| 169 | new_dl = Fdelq (new_entry, new_dl); | 182 | new_dl = Fdelq (new_entry, new_dl); |
| 170 | goto the_end; | 183 | goto the_end; |
| 171 | } | 184 | } |
| @@ -173,8 +186,7 @@ kqueue_compare_dir_list | |||
| 173 | 186 | ||
| 174 | /* The file has been deleted. */ | 187 | /* The file has been deleted. */ |
| 175 | kqueue_generate_event | 188 | kqueue_generate_event |
| 176 | (XCAR (watch_object), Fcons (Qdelete, Qnil), | 189 | (watch_object, Fcons (Qdelete, Qnil), XCAR (XCDR (old_entry)), Qnil); |
| 177 | XCAR (XCDR (old_entry)), Qnil, callback); | ||
| 178 | 190 | ||
| 179 | the_end: | 191 | the_end: |
| 180 | dl = XCDR (dl); | 192 | dl = XCDR (dl); |
| @@ -191,15 +203,13 @@ kqueue_compare_dir_list | |||
| 191 | /* A new file has appeared. */ | 203 | /* A new file has appeared. */ |
| 192 | new_entry = XCAR (dl); | 204 | new_entry = XCAR (dl); |
| 193 | kqueue_generate_event | 205 | kqueue_generate_event |
| 194 | (XCAR (watch_object), Fcons (Qcreate, Qnil), | 206 | (watch_object, Fcons (Qcreate, Qnil), XCAR (XCDR (new_entry)), Qnil); |
| 195 | XCAR (XCDR (new_entry)), Qnil, callback); | ||
| 196 | 207 | ||
| 197 | /* Check size of that file. */ | 208 | /* Check size of that file. */ |
| 198 | Lisp_Object size = Fnth (make_number (4), new_entry); | 209 | Lisp_Object size = Fnth (make_number (4), new_entry); |
| 199 | if (FLOATP (size) || (XINT (size) > 0)) | 210 | if (FLOATP (size) || (XINT (size) > 0)) |
| 200 | kqueue_generate_event | 211 | kqueue_generate_event |
| 201 | (XCAR (watch_object), Fcons (Qwrite, Qnil), | 212 | (watch_object, Fcons (Qwrite, Qnil), XCAR (XCDR (new_entry)), Qnil); |
| 202 | XCAR (XCDR (new_entry)), Qnil, callback); | ||
| 203 | 213 | ||
| 204 | dl = XCDR (dl); | 214 | dl = XCDR (dl); |
| 205 | new_dl = Fdelq (new_entry, new_dl); | 215 | new_dl = Fdelq (new_entry, new_dl); |
| @@ -226,7 +236,7 @@ kqueue_callback (int fd, void *data) | |||
| 226 | for (;;) { | 236 | for (;;) { |
| 227 | struct kevent kev; | 237 | struct kevent kev; |
| 228 | static const struct timespec nullts = { 0, 0 }; | 238 | static const struct timespec nullts = { 0, 0 }; |
| 229 | Lisp_Object descriptor, watch_object, file, callback, actions; | 239 | Lisp_Object descriptor, watch_object, file, actions; |
| 230 | 240 | ||
| 231 | /* Read one event. */ | 241 | /* Read one event. */ |
| 232 | int ret = kevent (kqueuefd, NULL, 0, &kev, 1, &nullts); | 242 | int ret = kevent (kqueuefd, NULL, 0, &kev, 1, &nullts); |
| @@ -235,14 +245,11 @@ kqueue_callback (int fd, void *data) | |||
| 235 | return; | 245 | return; |
| 236 | } | 246 | } |
| 237 | 247 | ||
| 238 | /* Determine descriptor, file name and callback function. */ | 248 | /* Determine descriptor and file name. */ |
| 239 | descriptor = make_number (kev.ident); | 249 | descriptor = make_number (kev.ident); |
| 240 | watch_object = assq_no_quit (descriptor, watch_list); | 250 | watch_object = assq_no_quit (descriptor, watch_list); |
| 241 | 251 | if (CONSP (watch_object)) | |
| 242 | if (CONSP (watch_object)) { | ||
| 243 | file = XCAR (XCDR (watch_object)); | 252 | file = XCAR (XCDR (watch_object)); |
| 244 | callback = Fnth (make_number (3), watch_object); | ||
| 245 | } | ||
| 246 | else | 253 | else |
| 247 | continue; | 254 | continue; |
| 248 | 255 | ||
| @@ -271,7 +278,7 @@ kqueue_callback (int fd, void *data) | |||
| 271 | 278 | ||
| 272 | /* Create the event. */ | 279 | /* Create the event. */ |
| 273 | if (! NILP (actions)) | 280 | if (! NILP (actions)) |
| 274 | kqueue_generate_event (descriptor, actions, file, Qnil, callback); | 281 | kqueue_generate_event (watch_object, actions, file, Qnil); |
| 275 | 282 | ||
| 276 | /* Cancel monitor if file or directory is deleted or renamed. */ | 283 | /* Cancel monitor if file or directory is deleted or renamed. */ |
| 277 | if (kev.fflags & (NOTE_DELETE | NOTE_RENAME)) | 284 | if (kev.fflags & (NOTE_DELETE | NOTE_RENAME)) |
diff --git a/test/automated/file-notify-tests.el b/test/automated/file-notify-tests.el index 67e929a6477..6946541b909 100644 --- a/test/automated/file-notify-tests.el +++ b/test/automated/file-notify-tests.el | |||
| @@ -133,6 +133,18 @@ being the result.") | |||
| 133 | ;; Return result. | 133 | ;; Return result. |
| 134 | (cdr file-notify--test-remote-enabled-checked)) | 134 | (cdr file-notify--test-remote-enabled-checked)) |
| 135 | 135 | ||
| 136 | (defun file-notify--test-library () | ||
| 137 | "The used libray for the test, as string. | ||
| 138 | In the remote case, it is the process name which runs on the | ||
| 139 | remote host, or nil." | ||
| 140 | (if (null (file-remote-p temporary-file-directory)) | ||
| 141 | (symbol-name file-notify--library) | ||
| 142 | (and (consp file-notify--test-remote-enabled-checked) | ||
| 143 | (processp (cdr file-notify--test-remote-enabled-checked)) | ||
| 144 | (replace-regexp-in-string | ||
| 145 | "<[[:digit:]]+>\\'" "" | ||
| 146 | (process-name (cdr file-notify--test-remote-enabled-checked)))))) | ||
| 147 | |||
| 136 | (defmacro file-notify--deftest-remote (test docstring) | 148 | (defmacro file-notify--deftest-remote (test docstring) |
| 137 | "Define ert `TEST-remote' for remote files." | 149 | "Define ert `TEST-remote' for remote files." |
| 138 | (declare (indent 1)) | 150 | (declare (indent 1)) |
| @@ -150,12 +162,7 @@ being the result.") | |||
| 150 | "Test availability of `file-notify'." | 162 | "Test availability of `file-notify'." |
| 151 | (skip-unless (file-notify--test-local-enabled)) | 163 | (skip-unless (file-notify--test-local-enabled)) |
| 152 | ;; Report the native library which has been used. | 164 | ;; Report the native library which has been used. |
| 153 | (if (null (file-remote-p temporary-file-directory)) | 165 | (message "Library: `%s'" (file-notify--test-library)) |
| 154 | (message "Local library: `%s'" file-notify--library) | ||
| 155 | (message "Remote command: `%s'" | ||
| 156 | (replace-regexp-in-string | ||
| 157 | "<[[:digit:]]+>\\'" "" | ||
| 158 | (process-name (cdr file-notify--test-remote-enabled-checked))))) | ||
| 159 | (should | 166 | (should |
| 160 | (setq file-notify--test-desc | 167 | (setq file-notify--test-desc |
| 161 | (file-notify-add-watch temporary-file-directory '(change) 'ignore))) | 168 | (file-notify-add-watch temporary-file-directory '(change) 'ignore))) |
| @@ -311,6 +318,7 @@ Don't wait longer than timeout seconds for the events to be delivered." | |||
| 311 | (file-notify--test-with-events '(created changed deleted) | 318 | (file-notify--test-with-events '(created changed deleted) |
| 312 | (write-region | 319 | (write-region |
| 313 | "any text" nil file-notify--test-tmpfile nil 'no-message) | 320 | "any text" nil file-notify--test-tmpfile nil 'no-message) |
| 321 | (read-event nil nil 0.1) | ||
| 314 | (delete-file file-notify--test-tmpfile)) | 322 | (delete-file file-notify--test-tmpfile)) |
| 315 | ;; `file-notify-rm-watch' fires the `stopped' event. Suppress it. | 323 | ;; `file-notify-rm-watch' fires the `stopped' event. Suppress it. |
| 316 | (let (file-notify--test-events) | 324 | (let (file-notify--test-events) |
| @@ -319,7 +327,7 @@ Don't wait longer than timeout seconds for the events to be delivered." | |||
| 319 | ;; Check creation, change and deletion. There must be a | 327 | ;; Check creation, change and deletion. There must be a |
| 320 | ;; `stopped' event when deleting the directory. It doesn't | 328 | ;; `stopped' event when deleting the directory. It doesn't |
| 321 | ;; work for w32notify. | 329 | ;; work for w32notify. |
| 322 | (unless (eq file-notify--library 'w32notify) | 330 | (unless (string-equal (file-notify--test-library) "w32notify") |
| 323 | (make-directory file-notify--test-tmpfile) | 331 | (make-directory file-notify--test-tmpfile) |
| 324 | (setq file-notify--test-desc | 332 | (setq file-notify--test-desc |
| 325 | (file-notify-add-watch | 333 | (file-notify-add-watch |
| @@ -327,11 +335,14 @@ Don't wait longer than timeout seconds for the events to be delivered." | |||
| 327 | '(change) 'file-notify--test-event-handler)) | 335 | '(change) 'file-notify--test-event-handler)) |
| 328 | (file-notify--test-with-events | 336 | (file-notify--test-with-events |
| 329 | ;; There are two `deleted' events, for the file and for | 337 | ;; There are two `deleted' events, for the file and for |
| 330 | ;; the directory. | 338 | ;; the directory. Except for kqueue. |
| 331 | '(created changed deleted deleted stopped) | 339 | (if (string-equal (file-notify--test-library) "kqueue") |
| 340 | '(created changed deleted stopped) | ||
| 341 | '(created changed deleted deleted stopped)) | ||
| 332 | (write-region | 342 | (write-region |
| 333 | "any text" nil (expand-file-name "foo" file-notify--test-tmpfile) | 343 | "any text" nil (expand-file-name "foo" file-notify--test-tmpfile) |
| 334 | nil 'no-message) | 344 | nil 'no-message) |
| 345 | (read-event nil nil 0.1) | ||
| 335 | (delete-directory file-notify--test-tmpfile 'recursive)) | 346 | (delete-directory file-notify--test-tmpfile 'recursive)) |
| 336 | ;; `file-notify-rm-watch' fires the `stopped' event. Suppress it. | 347 | ;; `file-notify-rm-watch' fires the `stopped' event. Suppress it. |
| 337 | (let (file-notify--test-events) | 348 | (let (file-notify--test-events) |
| @@ -346,17 +357,21 @@ Don't wait longer than timeout seconds for the events to be delivered." | |||
| 346 | (file-notify--test-with-events | 357 | (file-notify--test-with-events |
| 347 | ;; w32notify does not distinguish between `changed' and | 358 | ;; w32notify does not distinguish between `changed' and |
| 348 | ;; `attribute-changed'. | 359 | ;; `attribute-changed'. |
| 349 | (if (eq file-notify--library 'w32notify) | 360 | (if (string-equal (file-notify--test-library) "w32notify") |
| 350 | '(created changed changed deleted) | 361 | '(created changed changed deleted) |
| 351 | '(created changed deleted)) | 362 | '(created changed deleted)) |
| 352 | (write-region | 363 | (write-region |
| 353 | "any text" nil file-notify--test-tmpfile nil 'no-message) | 364 | "any text" nil file-notify--test-tmpfile nil 'no-message) |
| 365 | (read-event nil nil 0.1) | ||
| 354 | (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1) | 366 | (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1) |
| 355 | ;; The next two events shall not be visible. | 367 | ;; The next two events shall not be visible. |
| 368 | (read-event nil nil 0.1) | ||
| 356 | (set-file-modes file-notify--test-tmpfile 000) | 369 | (set-file-modes file-notify--test-tmpfile 000) |
| 357 | (read-event nil nil 0.1) ; In order to distinguish the events. | 370 | (read-event nil nil 0.1) |
| 358 | (set-file-times file-notify--test-tmpfile '(0 0)) | 371 | (set-file-times file-notify--test-tmpfile '(0 0)) |
| 372 | (read-event nil nil 0.1) | ||
| 359 | (delete-file file-notify--test-tmpfile) | 373 | (delete-file file-notify--test-tmpfile) |
| 374 | (read-event nil nil 0.1) | ||
| 360 | (delete-file file-notify--test-tmpfile1)) | 375 | (delete-file file-notify--test-tmpfile1)) |
| 361 | ;; `file-notify-rm-watch' fires the `stopped' event. Suppress it. | 376 | ;; `file-notify-rm-watch' fires the `stopped' event. Suppress it. |
| 362 | (let (file-notify--test-events) | 377 | (let (file-notify--test-events) |
| @@ -371,15 +386,18 @@ Don't wait longer than timeout seconds for the events to be delivered." | |||
| 371 | (file-notify--test-with-events '(created changed renamed) | 386 | (file-notify--test-with-events '(created changed renamed) |
| 372 | (write-region | 387 | (write-region |
| 373 | "any text" nil file-notify--test-tmpfile nil 'no-message) | 388 | "any text" nil file-notify--test-tmpfile nil 'no-message) |
| 389 | (read-event nil nil 0.1) | ||
| 374 | (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1) | 390 | (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1) |
| 375 | ;; After the rename, we won't get events anymore. | 391 | ;; After the rename, we won't get events anymore. |
| 392 | (read-event nil nil 0.1) | ||
| 376 | (delete-file file-notify--test-tmpfile1)) | 393 | (delete-file file-notify--test-tmpfile1)) |
| 377 | ;; `file-notify-rm-watch' fires the `stopped' event. Suppress it. | 394 | ;; `file-notify-rm-watch' fires the `stopped' event. Suppress it. |
| 378 | (let (file-notify--test-events) | 395 | (let (file-notify--test-events) |
| 379 | (file-notify-rm-watch file-notify--test-desc)) | 396 | (file-notify-rm-watch file-notify--test-desc)) |
| 380 | 397 | ||
| 381 | ;; Check attribute change. It doesn't work for w32notify. | 398 | ;; Check attribute change. It doesn't work for kqueue and w32notify. |
| 382 | (unless (eq file-notify--library 'w32notify) | 399 | (unless (or (string-equal (file-notify--test-library) "kqueue") |
| 400 | (string-equal (file-notify--test-library) "w32notify")) | ||
| 383 | (setq file-notify--test-desc | 401 | (setq file-notify--test-desc |
| 384 | (file-notify-add-watch | 402 | (file-notify-add-watch |
| 385 | file-notify--test-tmpfile | 403 | file-notify--test-tmpfile |
| @@ -523,6 +541,7 @@ Don't wait longer than timeout seconds for the events to be delivered." | |||
| 523 | (should (file-notify-valid-p file-notify--test-desc)) | 541 | (should (file-notify-valid-p file-notify--test-desc)) |
| 524 | (write-region | 542 | (write-region |
| 525 | "any text" nil file-notify--test-tmpfile nil 'no-message) | 543 | "any text" nil file-notify--test-tmpfile nil 'no-message) |
| 544 | (read-event nil nil 0.1) | ||
| 526 | (delete-file file-notify--test-tmpfile)) | 545 | (delete-file file-notify--test-tmpfile)) |
| 527 | ;; After deleting the file, the descriptor is still valid. | 546 | ;; After deleting the file, the descriptor is still valid. |
| 528 | (should (file-notify-valid-p file-notify--test-desc)) | 547 | (should (file-notify-valid-p file-notify--test-desc)) |
| @@ -537,8 +556,7 @@ Don't wait longer than timeout seconds for the events to be delivered." | |||
| 537 | (unwind-protect | 556 | (unwind-protect |
| 538 | ;; The batch-mode operation of w32notify is fragile (there's no | 557 | ;; The batch-mode operation of w32notify is fragile (there's no |
| 539 | ;; input threads to send the message to). | 558 | ;; input threads to send the message to). |
| 540 | ;(unless (and noninteractive (eq file-notify--library 'w32notify)) | 559 | (unless (string-equal (file-notify--test-library) "w32notify") |
| 541 | (unless (eq file-notify--library 'w32notify) | ||
| 542 | (let ((temporary-file-directory | 560 | (let ((temporary-file-directory |
| 543 | (make-temp-file "file-notify-test-parent" t))) | 561 | (make-temp-file "file-notify-test-parent" t))) |
| 544 | (setq file-notify--test-tmpfile (file-notify--test-make-temp-name) | 562 | (setq file-notify--test-tmpfile (file-notify--test-make-temp-name) |
| @@ -546,10 +564,16 @@ Don't wait longer than timeout seconds for the events to be delivered." | |||
| 546 | (file-notify-add-watch | 564 | (file-notify-add-watch |
| 547 | file-notify--test-tmpfile | 565 | file-notify--test-tmpfile |
| 548 | '(change) #'file-notify--test-event-handler)) | 566 | '(change) #'file-notify--test-event-handler)) |
| 549 | (file-notify--test-with-events '(created changed deleted stopped) | 567 | (file-notify--test-with-events |
| 568 | ;; There are two `deleted' events, for the file and for | ||
| 569 | ;; the directory. Except for kqueue. | ||
| 570 | (if (string-equal (file-notify--test-library) "kqueue") | ||
| 571 | '(created changed deleted stopped) | ||
| 572 | '(created changed deleted deleted stopped)) | ||
| 550 | (should (file-notify-valid-p file-notify--test-desc)) | 573 | (should (file-notify-valid-p file-notify--test-desc)) |
| 551 | (write-region | 574 | (write-region |
| 552 | "any text" nil file-notify--test-tmpfile nil 'no-message) | 575 | "any text" nil file-notify--test-tmpfile nil 'no-message) |
| 576 | (read-event nil nil 0.1) | ||
| 553 | (delete-directory temporary-file-directory t)) | 577 | (delete-directory temporary-file-directory t)) |
| 554 | ;; After deleting the parent directory, the descriptor must | 578 | ;; After deleting the parent directory, the descriptor must |
| 555 | ;; not be valid anymore. | 579 | ;; not be valid anymore. |
| @@ -589,7 +613,8 @@ Don't wait longer than timeout seconds for the events to be delivered." | |||
| 589 | (unwind-protect | 613 | (unwind-protect |
| 590 | ;; The batch-mode operation of w32notify is fragile (there's no | 614 | ;; The batch-mode operation of w32notify is fragile (there's no |
| 591 | ;; input threads to send the message to). | 615 | ;; input threads to send the message to). |
| 592 | (unless (and noninteractive (eq file-notify--library 'w32notify)) | 616 | (unless (and noninteractive |
| 617 | (string-equal (file-notify--test-library) "w32notify")) | ||
| 593 | (setq file-notify--test-tmpfile | 618 | (setq file-notify--test-tmpfile |
| 594 | (file-name-as-directory (file-notify--test-make-temp-name))) | 619 | (file-name-as-directory (file-notify--test-make-temp-name))) |
| 595 | (make-directory file-notify--test-tmpfile) | 620 | (make-directory file-notify--test-tmpfile) |