diff options
| author | Michael Albinus | 2015-11-25 15:24:27 +0100 |
|---|---|---|
| committer | Michael Albinus | 2015-11-25 15:24:27 +0100 |
| commit | 91cad2b327f19094764ca1dc2c432368742f1d2f (patch) | |
| tree | c08880452d912fb7992d631eb092b1943d65b1b0 /test | |
| parent | c378d6c33f751d1a0b97958f3cacfe0b07c72f58 (diff) | |
| parent | bec57a486a2a40d7c770dab72a34cf6a4d17a5d0 (diff) | |
| download | emacs-91cad2b327f19094764ca1dc2c432368742f1d2f.tar.gz emacs-91cad2b327f19094764ca1dc2c432368742f1d2f.zip | |
Merge from scratch/kqueue
bec57a4 Some final fixes in file notification before merging with master
0247489 Rework file notifications, kqueue has problems with directory monitors
5154781 Continie with pending events
6b490c0 Improve loops in file-notify-test06-many-events
c8e266f Handle more complex rename operation in kqueue
5044bdf New test with a larger number of events.
65ba5a9 Further fixes for kqueue.
13f3508 Code cleanup of kqueue.c
99aa855 Doc changes for kqueue
8deebe1 Finish implementation in kqueue.c
90d6c69 * lisp/filenotify.el (file-notify-add-watch): Fix thinko.
e95b309 More work on kqueue
41d9bd0 Implement directory events
c571fc1 Build fixes for kqueue support.
e0a68f2 Continue kqueue implementation
7543d1c Work on kqueue
e3354e2 Add kqueue support
c6457ce Minor fix to comment indentation and typo in last commit
b92307f linum-mode plays more nicely with other margin-setting extensions
58e6235 * lisp/image-mode.el: Support encrypted file
9375652 * lisp/progmodes/verilog-mode.el (verilog-save-buffer-state): Add backquote
47f83b6 ; ChangeLog.2 fixes
7cc233e * lisp/emacs-lisp/package.el: Fix a decoding issue
5f9153f * lisp/emacs-lisp/package.el: Refactor -with-work-buffer-async
353f5e7 * lisp/progmodes/verilog-mode.el: Use with-silent-modifications
70f1fda ; Auto-commit of ChangeLog files.
ae0653b * CONTRIBUTE: Remove information about feature freeze.
9459456 Merge branch 'release-process-lowercase'
9a4aa0f Document the release process
f8cc14b * admin/release-process: Rename from admin/FOR-RELEASE.
dcd5877 gitmerge: Fix git log command
2ac79ae gitmerge: Try to detect cherry-picks
5f7a2a9 Increment Emacs version on master branch
ed2e7e2 Mention CONTRIBUTE in README
9e00a02 Update verilog-mode.el to 2015-11-09-b121d60-vpo.
138ad3d ; Fix warnings
7126e9a ; Update xref-etags-mode for the latest change
246d660 Use generic dispatch for xref backends
31f6e93 Support rectangular regions for more commands
f103a27 Handle multiple matches on the same line; add highlighting
fe973fc Replace xref-match-bounds with xref-match-length
92a5010 Merge from gnulib
04ac097 Spruce up ftfont.c memory allocation
4c4b520 Port recent XCB changes to 64-bit ‘long int’
4f0ce9c * src/undo.c (run_undoable_change): Now static.
695a6f9 Remove support for ':timeout' from w32 tray notifications
a731c2f * test/automated/simple-test.el: Add test for bug#20698 (bug#21885)
2b4c0c0 * lisp/progmodes/elisp-mode.el: Declare function `project-roots'
66b9f7b * src/undo.c: Small fixes for previous change
2fac30e Add a few more variables to redisplay--variables
04f69f1 * lisp/loadup.el: Enlarge the size of the hash table to 80000.
e221d32 Fix point positioning after transposing with negative arg
35f5afb Fix last change in shr.el
508e77b Fix last change
d60ed3f Another fix for MinGW64 and Cygwin builds due to notifications
805a39b Remove intern calls and XXX comments from Fx_export_frames
9463abf shr: don't invoke unbound function (Bug#21895)
6e5186e * test/automated/keymaps-test.el: Fix test to make it repeatable
0c92826 * test/automated/cl-lib-tests.el (cl-lib-struct-constructors): Small fix
39dbd1c : Tests for undo-auto functionality.
20aa42e ; Merge branch 'fix/no-undo-boundary-on-secondary-buffer-change'
44dfa86 The heuristic that Emacs uses to add an `undo-boundary' has been reworked, as it interacts poorly with functions on `post-command-hook' or `after-change-functions'.
d2f73db Bind [?\S-\ ] to previous line command in Dired-like modes.
c1bc6e5 Fix the MinGW64 and Cygwin-w32 builds
1e363a8 Enable sorting of JSON object keys when encoding
9dd7da9 * test/automated/keymap-tests.el: New test file
aa17de9 Speed up x_real_pos_and_offsets using XCB
a838c83 Enable use of XCB for checking window manager state
c7f2b6a Detect XCB and save a connection handle
e1c27db Reduce some data dependencies between X calls
25e32bd Use color cache for creating bitmap
851be0f Add "^" to the interactive specs of `dired-next/previous-line'
055ca3a Sync with soap-client repository, version 3.0.2
e0f64e7 CC Mode: Respect users' settings of open-paren-in-column-0-is-defun-start.
952395d * lisp/obarray.el: Fix shadowed variables
436d330 Avoid error in submitting a form with EWW
e887f6e ; * doc/lispref/os.texi: Fix indentation of sample code.
51d840a Rename seq-p and map-p to seqp and mapp
23036ba Rename obarray-p to obarrayp
20aea42 Rename obarray-foreach to obarray-map
a3b2101 New file with obarray functions.
9d43941 Implement tray notifications for MS-Windows
Diffstat (limited to 'test')
| -rw-r--r-- | test/automated/auto-revert-tests.el | 2 | ||||
| -rw-r--r-- | test/automated/file-notify-tests.el | 557 |
2 files changed, 388 insertions, 171 deletions
diff --git a/test/automated/auto-revert-tests.el b/test/automated/auto-revert-tests.el index 2745f106087..6f186973ee7 100644 --- a/test/automated/auto-revert-tests.el +++ b/test/automated/auto-revert-tests.el | |||
| @@ -136,7 +136,7 @@ | |||
| 136 | ;; Strange, that `copy-directory' does not work as expected. | 136 | ;; Strange, that `copy-directory' does not work as expected. |
| 137 | ;; The following shell command is not portable on all | 137 | ;; The following shell command is not portable on all |
| 138 | ;; platforms, unfortunately. | 138 | ;; platforms, unfortunately. |
| 139 | (shell-command (format "%s -f %s/* %s" cp tmpdir2 tmpdir1)) | 139 | (shell-command (format "%s %s/* %s" cp tmpdir2 tmpdir1)) |
| 140 | 140 | ||
| 141 | ;; Check, that the buffers have been reverted. | 141 | ;; Check, that the buffers have been reverted. |
| 142 | (dolist (buf (list buf1 buf2)) | 142 | (dolist (buf (list buf1 buf2)) |
diff --git a/test/automated/file-notify-tests.el b/test/automated/file-notify-tests.el index 67e929a6477..b665dddb631 100644 --- a/test/automated/file-notify-tests.el +++ b/test/automated/file-notify-tests.el | |||
| @@ -65,7 +65,11 @@ | |||
| 65 | 65 | ||
| 66 | (defun file-notify--test-timeout () | 66 | (defun file-notify--test-timeout () |
| 67 | "Timeout to wait for arriving events, in seconds." | 67 | "Timeout to wait for arriving events, in seconds." |
| 68 | (if (file-remote-p temporary-file-directory) 6 3)) | 68 | (cond |
| 69 | ((file-remote-p temporary-file-directory) 6) | ||
| 70 | ((string-equal (file-notify--test-library) "w32notify") 20) | ||
| 71 | ((eq system-type 'cygwin) 10) | ||
| 72 | (t 3))) | ||
| 69 | 73 | ||
| 70 | (defun file-notify--test-cleanup () | 74 | (defun file-notify--test-cleanup () |
| 71 | "Cleanup after a test." | 75 | "Cleanup after a test." |
| @@ -133,6 +137,18 @@ being the result.") | |||
| 133 | ;; Return result. | 137 | ;; Return result. |
| 134 | (cdr file-notify--test-remote-enabled-checked)) | 138 | (cdr file-notify--test-remote-enabled-checked)) |
| 135 | 139 | ||
| 140 | (defun file-notify--test-library () | ||
| 141 | "The used libray for the test, as string. | ||
| 142 | In the remote case, it is the process name which runs on the | ||
| 143 | remote host, or nil." | ||
| 144 | (if (null (file-remote-p temporary-file-directory)) | ||
| 145 | (symbol-name file-notify--library) | ||
| 146 | (and (consp file-notify--test-remote-enabled-checked) | ||
| 147 | (processp (cdr file-notify--test-remote-enabled-checked)) | ||
| 148 | (replace-regexp-in-string | ||
| 149 | "<[[:digit:]]+>\\'" "" | ||
| 150 | (process-name (cdr file-notify--test-remote-enabled-checked)))))) | ||
| 151 | |||
| 136 | (defmacro file-notify--deftest-remote (test docstring) | 152 | (defmacro file-notify--deftest-remote (test docstring) |
| 137 | "Define ert `TEST-remote' for remote files." | 153 | "Define ert `TEST-remote' for remote files." |
| 138 | (declare (indent 1)) | 154 | (declare (indent 1)) |
| @@ -150,12 +166,7 @@ being the result.") | |||
| 150 | "Test availability of `file-notify'." | 166 | "Test availability of `file-notify'." |
| 151 | (skip-unless (file-notify--test-local-enabled)) | 167 | (skip-unless (file-notify--test-local-enabled)) |
| 152 | ;; Report the native library which has been used. | 168 | ;; Report the native library which has been used. |
| 153 | (if (null (file-remote-p temporary-file-directory)) | 169 | (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 | 170 | (should |
| 160 | (setq file-notify--test-desc | 171 | (setq file-notify--test-desc |
| 161 | (file-notify-add-watch temporary-file-directory '(change) 'ignore))) | 172 | (file-notify-add-watch temporary-file-directory '(change) 'ignore))) |
| @@ -189,12 +200,13 @@ being the result.") | |||
| 189 | (file-notify-add-watch | 200 | (file-notify-add-watch |
| 190 | temporary-file-directory '(change attribute-change) 'ignore))) | 201 | temporary-file-directory '(change attribute-change) 'ignore))) |
| 191 | (file-notify-rm-watch file-notify--test-desc) | 202 | (file-notify-rm-watch file-notify--test-desc) |
| 192 | ;; The file does not need to exist, just the upper directory. | 203 | (write-region "any text" nil file-notify--test-tmpfile nil 'no-message) |
| 193 | (should | 204 | (should |
| 194 | (setq file-notify--test-desc | 205 | (setq file-notify--test-desc |
| 195 | (file-notify-add-watch | 206 | (file-notify-add-watch |
| 196 | file-notify--test-tmpfile '(change attribute-change) 'ignore))) | 207 | file-notify--test-tmpfile '(change attribute-change) 'ignore))) |
| 197 | (file-notify-rm-watch file-notify--test-desc) | 208 | (file-notify-rm-watch file-notify--test-desc) |
| 209 | (delete-file file-notify--test-tmpfile) | ||
| 198 | 210 | ||
| 199 | ;; Check error handling. | 211 | ;; Check error handling. |
| 200 | (should-error (file-notify-add-watch 1 2 3 4) | 212 | (should-error (file-notify-add-watch 1 2 3 4) |
| @@ -235,16 +247,17 @@ is bound somewhere." | |||
| 235 | (should | 247 | (should |
| 236 | (or (string-equal (file-notify--event-file-name file-notify--test-event) | 248 | (or (string-equal (file-notify--event-file-name file-notify--test-event) |
| 237 | file-notify--test-tmpfile) | 249 | file-notify--test-tmpfile) |
| 238 | (string-equal (directory-file-name | 250 | (string-equal (file-notify--event-file-name file-notify--test-event) |
| 239 | (file-name-directory | 251 | file-notify--test-tmpfile1) |
| 240 | (file-notify--event-file-name file-notify--test-event))) | 252 | (string-equal (file-notify--event-file-name file-notify--test-event) |
| 241 | file-notify--test-tmpfile))) | 253 | temporary-file-directory))) |
| 242 | ;; Check the second file name if exists. | 254 | ;; Check the second file name if exists. |
| 243 | (when (eq (nth 1 file-notify--test-event) 'renamed) | 255 | (when (eq (nth 1 file-notify--test-event) 'renamed) |
| 244 | (should | 256 | (should |
| 245 | (string-equal | 257 | (or (string-equal (file-notify--event-file1-name file-notify--test-event) |
| 246 | (file-notify--event-file1-name file-notify--test-event) | 258 | file-notify--test-tmpfile1) |
| 247 | file-notify--test-tmpfile1)))) | 259 | (string-equal (file-notify--event-file1-name file-notify--test-event) |
| 260 | temporary-file-directory))))) | ||
| 248 | 261 | ||
| 249 | (defun file-notify--test-event-handler (event) | 262 | (defun file-notify--test-event-handler (event) |
| 250 | "Run a test over FILE-NOTIFY--TEST-EVENT. | 263 | "Run a test over FILE-NOTIFY--TEST-EVENT. |
| @@ -253,7 +266,7 @@ and the event to `file-notify--test-events'." | |||
| 253 | (let* ((file-notify--test-event event) | 266 | (let* ((file-notify--test-event event) |
| 254 | (result | 267 | (result |
| 255 | (ert-run-test (make-ert-test :body 'file-notify--test-event-test)))) | 268 | (ert-run-test (make-ert-test :body 'file-notify--test-event-test)))) |
| 256 | ;; Do not add temporary files, this would confuse the checks. | 269 | ;; Do not add lock files, this would confuse the checks. |
| 257 | (unless (string-match | 270 | (unless (string-match |
| 258 | (regexp-quote ".#") | 271 | (regexp-quote ".#") |
| 259 | (file-notify--event-file-name file-notify--test-event)) | 272 | (file-notify--event-file-name file-notify--test-event)) |
| @@ -280,13 +293,19 @@ TIMEOUT is the maximum time to wait for, in seconds." | |||
| 280 | Don't wait longer than timeout seconds for the events to be delivered." | 293 | Don't wait longer than timeout seconds for the events to be delivered." |
| 281 | (declare (indent 1)) | 294 | (declare (indent 1)) |
| 282 | (let ((outer (make-symbol "outer"))) | 295 | (let ((outer (make-symbol "outer"))) |
| 283 | `(let ((,outer file-notify--test-events)) | 296 | `(let ((,outer file-notify--test-events) |
| 297 | create-lockfiles) | ||
| 284 | (setq file-notify--test-expected-events | 298 | (setq file-notify--test-expected-events |
| 285 | (append file-notify--test-expected-events ,events)) | 299 | (append file-notify--test-expected-events ,events)) |
| 300 | ;; Flush pending events. | ||
| 301 | (file-notify--wait-for-events | ||
| 302 | (file-notify--test-timeout) | ||
| 303 | (input-pending-p)) | ||
| 286 | (let (file-notify--test-events) | 304 | (let (file-notify--test-events) |
| 287 | ,@body | 305 | ,@body |
| 288 | (file-notify--wait-for-events | 306 | (file-notify--wait-for-events |
| 289 | (file-notify--test-timeout) | 307 | ;; More events need more time. Use some fudge factor. |
| 308 | (* (ceiling (length ,events) 100) (file-notify--test-timeout)) | ||
| 290 | (= (length ,events) (length file-notify--test-events))) | 309 | (= (length ,events) (length file-notify--test-events))) |
| 291 | (should (equal ,events (mapcar #'cadr file-notify--test-events))) | 310 | (should (equal ,events (mapcar #'cadr file-notify--test-events))) |
| 292 | (setq ,outer (append ,outer file-notify--test-events))) | 311 | (setq ,outer (append ,outer file-notify--test-events))) |
| @@ -295,111 +314,207 @@ Don't wait longer than timeout seconds for the events to be delivered." | |||
| 295 | (ert-deftest file-notify-test02-events () | 314 | (ert-deftest file-notify-test02-events () |
| 296 | "Check file creation/change/removal notifications." | 315 | "Check file creation/change/removal notifications." |
| 297 | (skip-unless (file-notify--test-local-enabled)) | 316 | (skip-unless (file-notify--test-local-enabled)) |
| 298 | ;; Under cygwin there are so bad timings that it doesn't make sense to test. | ||
| 299 | (skip-unless (not (eq system-type 'cygwin))) | ||
| 300 | |||
| 301 | (setq file-notify--test-tmpfile (file-notify--test-make-temp-name) | ||
| 302 | file-notify--test-tmpfile1 (file-notify--test-make-temp-name)) | ||
| 303 | 317 | ||
| 304 | (unwind-protect | 318 | (unwind-protect |
| 305 | (progn | 319 | (progn |
| 306 | ;; Check creation, change and deletion. | 320 | ;; Check file creation, change and deletion. It doesn't work |
| 307 | (setq file-notify--test-desc | 321 | ;; for cygwin and kqueue, because we don't use an implicit |
| 308 | (file-notify-add-watch | 322 | ;; directory monitor (kqueue), or the timings are too bad (cygwin). |
| 309 | file-notify--test-tmpfile | 323 | (unless (or (eq system-type 'cygwin) |
| 310 | '(change) 'file-notify--test-event-handler)) | 324 | (string-equal (file-notify--test-library) "kqueue")) |
| 311 | (file-notify--test-with-events '(created changed deleted) | 325 | (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)) |
| 326 | (should | ||
| 327 | (setq file-notify--test-desc | ||
| 328 | (file-notify-add-watch | ||
| 329 | file-notify--test-tmpfile | ||
| 330 | '(change) 'file-notify--test-event-handler))) | ||
| 331 | (file-notify--test-with-events | ||
| 332 | (cond | ||
| 333 | ;; cygwin recognizes only `deleted' and `stopped' events. | ||
| 334 | ((eq system-type 'cygwin) | ||
| 335 | '(deleted stopped)) | ||
| 336 | (t '(created changed deleted stopped))) | ||
| 337 | (write-region | ||
| 338 | "another text" nil file-notify--test-tmpfile nil 'no-message) | ||
| 339 | (read-event nil nil 0.1) | ||
| 340 | (delete-file file-notify--test-tmpfile)) | ||
| 341 | ;; `file-notify-rm-watch' fires the `stopped' event. Suppress it. | ||
| 342 | (let (file-notify--test-events) | ||
| 343 | (file-notify-rm-watch file-notify--test-desc))) | ||
| 344 | |||
| 345 | ;; Check file change and deletion. | ||
| 346 | (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)) | ||
| 347 | (write-region "any text" nil file-notify--test-tmpfile nil 'no-message) | ||
| 348 | (should | ||
| 349 | (setq file-notify--test-desc | ||
| 350 | (file-notify-add-watch | ||
| 351 | file-notify--test-tmpfile | ||
| 352 | '(change) 'file-notify--test-event-handler))) | ||
| 353 | (file-notify--test-with-events | ||
| 354 | (cond | ||
| 355 | ;; cygwin recognizes only `deleted' and `stopped' events. | ||
| 356 | ((eq system-type 'cygwin) | ||
| 357 | '(deleted stopped)) | ||
| 358 | ;; inotify, kqueueg and gfilenotify raise just one | ||
| 359 | ;; `changed' event, the other backends show us two of | ||
| 360 | ;; them. | ||
| 361 | ((or (string-equal "inotify" (file-notify--test-library)) | ||
| 362 | (string-equal "kqueue" (file-notify--test-library)) | ||
| 363 | (string-equal "gfilenotify" (file-notify--test-library))) | ||
| 364 | '(changed deleted stopped)) | ||
| 365 | (t '(changed changed deleted stopped))) | ||
| 366 | (read-event nil nil 0.1) | ||
| 312 | (write-region | 367 | (write-region |
| 313 | "any text" nil file-notify--test-tmpfile nil 'no-message) | 368 | "another text" nil file-notify--test-tmpfile nil 'no-message) |
| 369 | (read-event nil nil 0.1) | ||
| 314 | (delete-file file-notify--test-tmpfile)) | 370 | (delete-file file-notify--test-tmpfile)) |
| 315 | ;; `file-notify-rm-watch' fires the `stopped' event. Suppress it. | 371 | ;; `file-notify-rm-watch' fires the `stopped' event. Suppress it. |
| 316 | (let (file-notify--test-events) | 372 | (let (file-notify--test-events) |
| 317 | (file-notify-rm-watch file-notify--test-desc)) | 373 | (file-notify-rm-watch file-notify--test-desc)) |
| 318 | 374 | ||
| 319 | ;; Check creation, change and deletion. There must be a | 375 | ;; Check file creation, change and deletion when watching a |
| 320 | ;; `stopped' event when deleting the directory. It doesn't | 376 | ;; directory. There must be a `stopped' event when deleting |
| 321 | ;; work for w32notify. | 377 | ;; the directory. |
| 322 | (unless (eq file-notify--library 'w32notify) | 378 | (let ((temporary-file-directory |
| 323 | (make-directory file-notify--test-tmpfile) | 379 | (make-temp-file "file-notify-test-parent" t))) |
| 324 | (setq file-notify--test-desc | 380 | (should |
| 325 | (file-notify-add-watch | 381 | (setq file-notify--test-tmpfile (file-notify--test-make-temp-name) |
| 326 | file-notify--test-tmpfile | 382 | file-notify--test-desc |
| 327 | '(change) 'file-notify--test-event-handler)) | 383 | (file-notify-add-watch |
| 384 | temporary-file-directory | ||
| 385 | '(change) 'file-notify--test-event-handler))) | ||
| 328 | (file-notify--test-with-events | 386 | (file-notify--test-with-events |
| 329 | ;; There are two `deleted' events, for the file and for | 387 | (cond |
| 330 | ;; the directory. | 388 | ;; w32notify does raise a `stopped' event when a |
| 331 | '(created changed deleted deleted stopped) | 389 | ;; watched directory is deleted. |
| 390 | ((string-equal (file-notify--test-library) "w32notify") | ||
| 391 | '(created changed deleted)) | ||
| 392 | ;; cygwin recognizes only `deleted' and `stopped' events. | ||
| 393 | ((eq system-type 'cygwin) | ||
| 394 | '(deleted stopped)) | ||
| 395 | ;; There are two `deleted' events, for the file and for | ||
| 396 | ;; the directory. Except for kqueue. | ||
| 397 | ((string-equal (file-notify--test-library) "kqueue") | ||
| 398 | '(created changed deleted stopped)) | ||
| 399 | (t '(created changed deleted deleted stopped))) | ||
| 400 | (read-event nil nil 0.1) | ||
| 332 | (write-region | 401 | (write-region |
| 333 | "any text" nil (expand-file-name "foo" file-notify--test-tmpfile) | 402 | "any text" nil file-notify--test-tmpfile nil 'no-message) |
| 334 | nil 'no-message) | 403 | (read-event nil nil 0.1) |
| 335 | (delete-directory file-notify--test-tmpfile 'recursive)) | 404 | (delete-directory temporary-file-directory 'recursive)) |
| 336 | ;; `file-notify-rm-watch' fires the `stopped' event. Suppress it. | 405 | ;; `file-notify-rm-watch' fires the `stopped' event. Suppress it. |
| 337 | (let (file-notify--test-events) | 406 | (let (file-notify--test-events) |
| 338 | (file-notify-rm-watch file-notify--test-desc))) | 407 | (file-notify-rm-watch file-notify--test-desc))) |
| 339 | 408 | ||
| 340 | ;; Check copy. | 409 | ;; Check copy of files inside a directory. |
| 341 | (setq file-notify--test-desc | 410 | (let ((temporary-file-directory |
| 342 | (file-notify-add-watch | 411 | (make-temp-file "file-notify-test-parent" t))) |
| 343 | file-notify--test-tmpfile | 412 | (should |
| 344 | '(change) 'file-notify--test-event-handler)) | 413 | (setq file-notify--test-tmpfile (file-notify--test-make-temp-name) |
| 345 | (should file-notify--test-desc) | 414 | file-notify--test-tmpfile1 (file-notify--test-make-temp-name) |
| 346 | (file-notify--test-with-events | 415 | file-notify--test-desc |
| 347 | ;; w32notify does not distinguish between `changed' and | 416 | (file-notify-add-watch |
| 348 | ;; `attribute-changed'. | 417 | temporary-file-directory |
| 349 | (if (eq file-notify--library 'w32notify) | 418 | '(change) 'file-notify--test-event-handler))) |
| 350 | '(created changed changed deleted) | 419 | (file-notify--test-with-events |
| 351 | '(created changed deleted)) | 420 | (cond |
| 352 | (write-region | 421 | ;; w32notify does not distinguish between `changed' and |
| 353 | "any text" nil file-notify--test-tmpfile nil 'no-message) | 422 | ;; `attribute-changed'. |
| 354 | (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1) | 423 | ((string-equal (file-notify--test-library) "w32notify") |
| 355 | ;; The next two events shall not be visible. | 424 | '(created changed created changed changed changed changed |
| 356 | (set-file-modes file-notify--test-tmpfile 000) | 425 | deleted deleted)) |
| 357 | (read-event nil nil 0.1) ; In order to distinguish the events. | 426 | ;; cygwin recognizes only `deleted' and `stopped' events. |
| 358 | (set-file-times file-notify--test-tmpfile '(0 0)) | 427 | ((eq system-type 'cygwin) |
| 359 | (delete-file file-notify--test-tmpfile) | 428 | '(deleted stopped)) |
| 360 | (delete-file file-notify--test-tmpfile1)) | 429 | ;; There are three `deleted' events, for two files and |
| 361 | ;; `file-notify-rm-watch' fires the `stopped' event. Suppress it. | 430 | ;; for the directory. Except for kqueue. |
| 362 | (let (file-notify--test-events) | 431 | ((string-equal (file-notify--test-library) "kqueue") |
| 363 | (file-notify-rm-watch file-notify--test-desc)) | 432 | '(created changed created changed deleted stopped)) |
| 433 | (t '(created changed created changed | ||
| 434 | deleted deleted deleted stopped))) | ||
| 435 | (read-event nil nil 0.1) | ||
| 436 | (write-region | ||
| 437 | "any text" nil file-notify--test-tmpfile nil 'no-message) | ||
| 438 | (read-event nil nil 0.1) | ||
| 439 | (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1) | ||
| 440 | ;; The next two events shall not be visible. | ||
| 441 | (read-event nil nil 0.1) | ||
| 442 | (set-file-modes file-notify--test-tmpfile 000) | ||
| 443 | (read-event nil nil 0.1) | ||
| 444 | (set-file-times file-notify--test-tmpfile '(0 0)) | ||
| 445 | (read-event nil nil 0.1) | ||
| 446 | (delete-directory temporary-file-directory 'recursive)) | ||
| 447 | ;; `file-notify-rm-watch' fires the `stopped' event. Suppress it. | ||
| 448 | (let (file-notify--test-events) | ||
| 449 | (file-notify-rm-watch file-notify--test-desc))) | ||
| 364 | 450 | ||
| 365 | ;; Check rename. | 451 | ;; Check rename of files inside a directory. |
| 366 | (setq file-notify--test-desc | 452 | (let ((temporary-file-directory |
| 367 | (file-notify-add-watch | 453 | (make-temp-file "file-notify-test-parent" t))) |
| 368 | file-notify--test-tmpfile | 454 | (should |
| 369 | '(change) 'file-notify--test-event-handler)) | 455 | (setq file-notify--test-tmpfile (file-notify--test-make-temp-name) |
| 370 | (should file-notify--test-desc) | 456 | file-notify--test-tmpfile1 (file-notify--test-make-temp-name) |
| 371 | (file-notify--test-with-events '(created changed renamed) | 457 | file-notify--test-desc |
| 372 | (write-region | 458 | (file-notify-add-watch |
| 373 | "any text" nil file-notify--test-tmpfile nil 'no-message) | 459 | temporary-file-directory |
| 374 | (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1) | 460 | '(change) 'file-notify--test-event-handler))) |
| 375 | ;; After the rename, we won't get events anymore. | 461 | (file-notify--test-with-events |
| 376 | (delete-file file-notify--test-tmpfile1)) | 462 | (cond |
| 377 | ;; `file-notify-rm-watch' fires the `stopped' event. Suppress it. | 463 | ;; w32notify does not distinguish between `changed' and |
| 378 | (let (file-notify--test-events) | 464 | ;; `attribute-changed'. |
| 379 | (file-notify-rm-watch file-notify--test-desc)) | 465 | ((string-equal (file-notify--test-library) "w32notify") |
| 466 | '(created changed renamed deleted)) | ||
| 467 | ;; cygwin recognizes only `deleted' and `stopped' events. | ||
| 468 | ((eq system-type 'cygwin) | ||
| 469 | '(deleted stopped)) | ||
| 470 | ;; There are two `deleted' events, for the file and for | ||
| 471 | ;; the directory. Except for kqueue. | ||
| 472 | ((string-equal (file-notify--test-library) "kqueue") | ||
| 473 | '(created changed renamed deleted stopped)) | ||
| 474 | (t '(created changed renamed deleted deleted stopped))) | ||
| 475 | (read-event nil nil 0.1) | ||
| 476 | (write-region | ||
| 477 | "any text" nil file-notify--test-tmpfile nil 'no-message) | ||
| 478 | (read-event nil nil 0.1) | ||
| 479 | (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1) | ||
| 480 | ;; After the rename, we won't get events anymore. | ||
| 481 | (read-event nil nil 0.1) | ||
| 482 | (delete-directory temporary-file-directory 'recursive)) | ||
| 483 | ;; `file-notify-rm-watch' fires the `stopped' event. Suppress it. | ||
| 484 | (let (file-notify--test-events) | ||
| 485 | (file-notify-rm-watch file-notify--test-desc))) | ||
| 380 | 486 | ||
| 381 | ;; Check attribute change. It doesn't work for w32notify. | 487 | ;; Check attribute change. Does not work for cygwin. |
| 382 | (unless (eq file-notify--library 'w32notify) | 488 | (unless (eq system-type 'cygwin) |
| 383 | (setq file-notify--test-desc | 489 | (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)) |
| 384 | (file-notify-add-watch | 490 | (write-region |
| 385 | file-notify--test-tmpfile | 491 | "any text" nil file-notify--test-tmpfile nil 'no-message) |
| 386 | '(attribute-change) 'file-notify--test-event-handler)) | 492 | (should |
| 387 | (file-notify--test-with-events | 493 | (setq file-notify--test-desc |
| 388 | (if (file-remote-p temporary-file-directory) | 494 | (file-notify-add-watch |
| 389 | ;; In the remote case, `write-region' raises also an | 495 | file-notify--test-tmpfile |
| 390 | ;; `attribute-changed' event. | 496 | '(attribute-change) 'file-notify--test-event-handler))) |
| 391 | '(attribute-changed attribute-changed attribute-changed) | 497 | (file-notify--test-with-events |
| 392 | '(attribute-changed attribute-changed)) | 498 | (cond |
| 393 | ;; We must use short delays between the operations. | 499 | ;; w32notify does not distinguish between `changed' and |
| 394 | ;; Otherwise, not all events arrive us in the remote case. | 500 | ;; `attribute-changed'. |
| 395 | (write-region | 501 | ((string-equal (file-notify--test-library) "w32notify") |
| 396 | "any text" nil file-notify--test-tmpfile nil 'no-message) | 502 | '(changed changed changed changed)) |
| 397 | (read-event nil nil 0.1) | 503 | ;; For kqueue and in the remote case, `write-region' |
| 398 | (set-file-modes file-notify--test-tmpfile 000) | 504 | ;; raises also an `attribute-changed' event. |
| 399 | (read-event nil nil 0.1) | 505 | ((or (string-equal (file-notify--test-library) "kqueue") |
| 400 | (set-file-times file-notify--test-tmpfile '(0 0)) | 506 | (file-remote-p temporary-file-directory)) |
| 401 | (read-event nil nil 0.1) | 507 | '(attribute-changed attribute-changed attribute-changed)) |
| 402 | (delete-file file-notify--test-tmpfile)) | 508 | (t '(attribute-changed attribute-changed))) |
| 509 | (read-event nil nil 0.1) | ||
| 510 | (write-region | ||
| 511 | "any text" nil file-notify--test-tmpfile nil 'no-message) | ||
| 512 | (read-event nil nil 0.1) | ||
| 513 | (set-file-modes file-notify--test-tmpfile 000) | ||
| 514 | (read-event nil nil 0.1) | ||
| 515 | (set-file-times file-notify--test-tmpfile '(0 0)) | ||
| 516 | (read-event nil nil 0.1) | ||
| 517 | (delete-file file-notify--test-tmpfile)) | ||
| 403 | ;; `file-notify-rm-watch' fires the `stopped' event. Suppress it. | 518 | ;; `file-notify-rm-watch' fires the `stopped' event. Suppress it. |
| 404 | (let (file-notify--test-events) | 519 | (let (file-notify--test-events) |
| 405 | (file-notify-rm-watch file-notify--test-desc))) | 520 | (file-notify-rm-watch file-notify--test-desc))) |
| @@ -475,28 +590,31 @@ Don't wait longer than timeout seconds for the events to be delivered." | |||
| 475 | (should (string-match "another text" (buffer-string))) | 590 | (should (string-match "another text" (buffer-string))) |
| 476 | 591 | ||
| 477 | ;; Stop file notification. Autorevert shall still work via polling. | 592 | ;; Stop file notification. Autorevert shall still work via polling. |
| 478 | (file-notify-rm-watch auto-revert-notify-watch-descriptor) | 593 | ;; It doesn't work for `w32notify'. |
| 479 | (file-notify--wait-for-events | 594 | (unless (string-equal (file-notify--test-library) "w32notify") |
| 480 | timeout (null auto-revert-use-notify)) | 595 | (file-notify-rm-watch auto-revert-notify-watch-descriptor) |
| 481 | (should-not auto-revert-use-notify) | ||
| 482 | (should-not auto-revert-notify-watch-descriptor) | ||
| 483 | |||
| 484 | ;; Modify file. We wait for two seconds, in order to have | ||
| 485 | ;; another timestamp. One second seems to be too short. | ||
| 486 | (with-current-buffer (get-buffer-create "*Messages*") | ||
| 487 | (narrow-to-region (point-max) (point-max))) | ||
| 488 | (sleep-for 2) | ||
| 489 | (write-region | ||
| 490 | "foo bla" nil file-notify--test-tmpfile nil 'no-message) | ||
| 491 | |||
| 492 | ;; Check, that the buffer has been reverted. | ||
| 493 | (with-current-buffer (get-buffer-create "*Messages*") | ||
| 494 | (file-notify--wait-for-events | 596 | (file-notify--wait-for-events |
| 495 | timeout | 597 | timeout (null auto-revert-use-notify)) |
| 496 | (string-match | 598 | (should-not auto-revert-use-notify) |
| 497 | (format-message "Reverting buffer `%s'." (buffer-name buf)) | 599 | (should-not auto-revert-notify-watch-descriptor) |
| 498 | (buffer-string)))) | 600 | |
| 499 | (should (string-match "foo bla" (buffer-string))))) | 601 | ;; Modify file. We wait for two seconds, in order to |
| 602 | ;; have another timestamp. One second seems to be too | ||
| 603 | ;; short. | ||
| 604 | (with-current-buffer (get-buffer-create "*Messages*") | ||
| 605 | (narrow-to-region (point-max) (point-max))) | ||
| 606 | (sleep-for 2) | ||
| 607 | (write-region | ||
| 608 | "foo bla" nil file-notify--test-tmpfile nil 'no-message) | ||
| 609 | |||
| 610 | ;; Check, that the buffer has been reverted. | ||
| 611 | (with-current-buffer (get-buffer-create "*Messages*") | ||
| 612 | (file-notify--wait-for-events | ||
| 613 | timeout | ||
| 614 | (string-match | ||
| 615 | (format-message "Reverting buffer `%s'." (buffer-name buf)) | ||
| 616 | (buffer-string)))) | ||
| 617 | (should (string-match "foo bla" (buffer-string)))))) | ||
| 500 | 618 | ||
| 501 | ;; Cleanup. | 619 | ;; Cleanup. |
| 502 | (with-current-buffer "*Messages*" (widen)) | 620 | (with-current-buffer "*Messages*" (widen)) |
| @@ -509,51 +627,92 @@ Don't wait longer than timeout seconds for the events to be delivered." | |||
| 509 | (ert-deftest file-notify-test04-file-validity () | 627 | (ert-deftest file-notify-test04-file-validity () |
| 510 | "Check `file-notify-valid-p' for files." | 628 | "Check `file-notify-valid-p' for files." |
| 511 | (skip-unless (file-notify--test-local-enabled)) | 629 | (skip-unless (file-notify--test-local-enabled)) |
| 512 | ;; Under cygwin there are so bad timings that it doesn't make sense to test. | ||
| 513 | (skip-unless (not (eq system-type 'cygwin))) | ||
| 514 | 630 | ||
| 515 | (unwind-protect | 631 | (unwind-protect |
| 516 | (progn | 632 | (progn |
| 517 | (setq file-notify--test-tmpfile (file-notify--test-make-temp-name) | 633 | (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)) |
| 518 | file-notify--test-desc | 634 | (write-region "any text" nil file-notify--test-tmpfile nil 'no-message) |
| 519 | (file-notify-add-watch | 635 | (should |
| 520 | file-notify--test-tmpfile | 636 | (setq file-notify--test-desc |
| 521 | '(change) #'file-notify--test-event-handler)) | 637 | (file-notify-add-watch |
| 522 | (file-notify--test-with-events '(created changed deleted) | 638 | file-notify--test-tmpfile |
| 639 | '(change) #'file-notify--test-event-handler))) | ||
| 640 | (should (file-notify-valid-p file-notify--test-desc)) | ||
| 641 | ;; After calling `file-notify-rm-watch', the descriptor is not | ||
| 642 | ;; valid anymore. | ||
| 643 | (file-notify-rm-watch file-notify--test-desc) | ||
| 644 | (should-not (file-notify-valid-p file-notify--test-desc)) | ||
| 645 | (delete-file file-notify--test-tmpfile)) | ||
| 646 | |||
| 647 | ;; Cleanup. | ||
| 648 | (file-notify--test-cleanup)) | ||
| 649 | |||
| 650 | (unwind-protect | ||
| 651 | (progn | ||
| 652 | (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)) | ||
| 653 | (write-region "any text" nil file-notify--test-tmpfile nil 'no-message) | ||
| 654 | (should | ||
| 655 | (setq file-notify--test-desc | ||
| 656 | (file-notify-add-watch | ||
| 657 | file-notify--test-tmpfile | ||
| 658 | '(change) #'file-notify--test-event-handler))) | ||
| 659 | (file-notify--test-with-events | ||
| 660 | (cond | ||
| 661 | ;; cygwin recognizes only `deleted' and `stopped' events. | ||
| 662 | ((eq system-type 'cygwin) | ||
| 663 | '(deleted stopped)) | ||
| 664 | ;; inotify, kqueueg and gfilenotify raise just one | ||
| 665 | ;; `changed' event, the other backends show us two of | ||
| 666 | ;; them. | ||
| 667 | ((or (string-equal "inotify" (file-notify--test-library)) | ||
| 668 | (string-equal "kqueue" (file-notify--test-library)) | ||
| 669 | (string-equal "gfilenotify" (file-notify--test-library))) | ||
| 670 | '(changed deleted stopped)) | ||
| 671 | (t '(changed changed deleted stopped))) | ||
| 672 | (read-event nil nil 0.1) | ||
| 523 | (should (file-notify-valid-p file-notify--test-desc)) | 673 | (should (file-notify-valid-p file-notify--test-desc)) |
| 524 | (write-region | 674 | (write-region |
| 525 | "any text" nil file-notify--test-tmpfile nil 'no-message) | 675 | "another text" nil file-notify--test-tmpfile nil 'no-message) |
| 676 | (read-event nil nil 0.1) | ||
| 526 | (delete-file file-notify--test-tmpfile)) | 677 | (delete-file file-notify--test-tmpfile)) |
| 527 | ;; After deleting the file, the descriptor is still valid. | 678 | ;; After deleting the file, the descriptor is not valid anymore. |
| 528 | (should (file-notify-valid-p file-notify--test-desc)) | 679 | (should-not (file-notify-valid-p file-notify--test-desc)) |
| 529 | ;; After removing the watch, the descriptor must not be valid | 680 | (file-notify-rm-watch file-notify--test-desc)) |
| 530 | ;; anymore. | ||
| 531 | (file-notify-rm-watch file-notify--test-desc) | ||
| 532 | (should-not (file-notify-valid-p file-notify--test-desc))) | ||
| 533 | 681 | ||
| 534 | ;; Cleanup. | 682 | ;; Cleanup. |
| 535 | (file-notify--test-cleanup)) | 683 | (file-notify--test-cleanup)) |
| 536 | 684 | ||
| 537 | (unwind-protect | 685 | (unwind-protect |
| 538 | ;; The batch-mode operation of w32notify is fragile (there's no | 686 | ;; w32notify does not send a `stopped' event when deleting a |
| 539 | ;; input threads to send the message to). | 687 | ;; directory. The test does not work, therefore. |
| 540 | ;(unless (and noninteractive (eq file-notify--library 'w32notify)) | 688 | (unless (string-equal (file-notify--test-library) "w32notify") |
| 541 | (unless (eq file-notify--library 'w32notify) | 689 | (let ((temporary-file-directory |
| 542 | (let ((temporary-file-directory | ||
| 543 | (make-temp-file "file-notify-test-parent" t))) | 690 | (make-temp-file "file-notify-test-parent" t))) |
| 544 | (setq file-notify--test-tmpfile (file-notify--test-make-temp-name) | 691 | (should |
| 545 | file-notify--test-desc | 692 | (setq file-notify--test-tmpfile (file-notify--test-make-temp-name) |
| 546 | (file-notify-add-watch | 693 | file-notify--test-desc |
| 547 | file-notify--test-tmpfile | 694 | (file-notify-add-watch |
| 548 | '(change) #'file-notify--test-event-handler)) | 695 | temporary-file-directory |
| 549 | (file-notify--test-with-events '(created changed deleted stopped) | 696 | '(change) #'file-notify--test-event-handler))) |
| 550 | (should (file-notify-valid-p file-notify--test-desc)) | 697 | (file-notify--test-with-events |
| 551 | (write-region | 698 | (cond |
| 552 | "any text" nil file-notify--test-tmpfile nil 'no-message) | 699 | ;; cygwin recognizes only `deleted' and `stopped' events. |
| 700 | ((eq system-type 'cygwin) | ||
| 701 | '(deleted stopped)) | ||
| 702 | ;; There are two `deleted' events, for the file and for | ||
| 703 | ;; the directory. Except for kqueue. | ||
| 704 | ((string-equal (file-notify--test-library) "kqueue") | ||
| 705 | '(created changed deleted stopped)) | ||
| 706 | (t '(created changed deleted deleted stopped))) | ||
| 707 | (should (file-notify-valid-p file-notify--test-desc)) | ||
| 708 | (read-event nil nil 0.1) | ||
| 709 | (write-region | ||
| 710 | "any text" nil file-notify--test-tmpfile nil 'no-message) | ||
| 711 | (read-event nil nil 0.1) | ||
| 553 | (delete-directory temporary-file-directory t)) | 712 | (delete-directory temporary-file-directory t)) |
| 554 | ;; After deleting the parent directory, the descriptor must | 713 | ;; After deleting the parent directory, the descriptor must |
| 555 | ;; not be valid anymore. | 714 | ;; not be valid anymore. |
| 556 | (should-not (file-notify-valid-p file-notify--test-desc)))) | 715 | (should-not (file-notify-valid-p file-notify--test-desc)))) |
| 557 | 716 | ||
| 558 | ;; Cleanup. | 717 | ;; Cleanup. |
| 559 | (file-notify--test-cleanup))) | 718 | (file-notify--test-cleanup))) |
| @@ -570,10 +729,11 @@ Don't wait longer than timeout seconds for the events to be delivered." | |||
| 570 | (setq file-notify--test-tmpfile | 729 | (setq file-notify--test-tmpfile |
| 571 | (file-name-as-directory (file-notify--test-make-temp-name))) | 730 | (file-name-as-directory (file-notify--test-make-temp-name))) |
| 572 | (make-directory file-notify--test-tmpfile) | 731 | (make-directory file-notify--test-tmpfile) |
| 573 | (setq file-notify--test-desc | 732 | (should |
| 574 | (file-notify-add-watch | 733 | (setq file-notify--test-desc |
| 575 | file-notify--test-tmpfile | 734 | (file-notify-add-watch |
| 576 | '(change) #'file-notify--test-event-handler)) | 735 | file-notify--test-tmpfile |
| 736 | '(change) #'file-notify--test-event-handler))) | ||
| 577 | (should (file-notify-valid-p file-notify--test-desc)) | 737 | (should (file-notify-valid-p file-notify--test-desc)) |
| 578 | ;; After removing the watch, the descriptor must not be valid | 738 | ;; After removing the watch, the descriptor must not be valid |
| 579 | ;; anymore. | 739 | ;; anymore. |
| @@ -589,20 +749,22 @@ Don't wait longer than timeout seconds for the events to be delivered." | |||
| 589 | (unwind-protect | 749 | (unwind-protect |
| 590 | ;; The batch-mode operation of w32notify is fragile (there's no | 750 | ;; The batch-mode operation of w32notify is fragile (there's no |
| 591 | ;; input threads to send the message to). | 751 | ;; input threads to send the message to). |
| 592 | (unless (and noninteractive (eq file-notify--library 'w32notify)) | 752 | (unless (and noninteractive |
| 753 | (string-equal (file-notify--test-library) "w32notify")) | ||
| 593 | (setq file-notify--test-tmpfile | 754 | (setq file-notify--test-tmpfile |
| 594 | (file-name-as-directory (file-notify--test-make-temp-name))) | 755 | (file-name-as-directory (file-notify--test-make-temp-name))) |
| 595 | (make-directory file-notify--test-tmpfile) | 756 | (make-directory file-notify--test-tmpfile) |
| 596 | (setq file-notify--test-desc | 757 | (should |
| 597 | (file-notify-add-watch | 758 | (setq file-notify--test-desc |
| 598 | file-notify--test-tmpfile | 759 | (file-notify-add-watch |
| 599 | '(change) #'file-notify--test-event-handler)) | 760 | file-notify--test-tmpfile |
| 761 | '(change) #'file-notify--test-event-handler))) | ||
| 600 | (should (file-notify-valid-p file-notify--test-desc)) | 762 | (should (file-notify-valid-p file-notify--test-desc)) |
| 601 | ;; After deleting the directory, the descriptor must not be | 763 | ;; After deleting the directory, the descriptor must not be |
| 602 | ;; valid anymore. | 764 | ;; valid anymore. |
| 603 | (delete-directory file-notify--test-tmpfile t) | 765 | (delete-directory file-notify--test-tmpfile t) |
| 604 | (file-notify--wait-for-events | 766 | (file-notify--wait-for-events |
| 605 | (file-notify--test-timeout) | 767 | (file-notify--test-timeout) |
| 606 | (not (file-notify-valid-p file-notify--test-desc))) | 768 | (not (file-notify-valid-p file-notify--test-desc))) |
| 607 | (should-not (file-notify-valid-p file-notify--test-desc))) | 769 | (should-not (file-notify-valid-p file-notify--test-desc))) |
| 608 | 770 | ||
| @@ -612,6 +774,61 @@ Don't wait longer than timeout seconds for the events to be delivered." | |||
| 612 | (file-notify--deftest-remote file-notify-test05-dir-validity | 774 | (file-notify--deftest-remote file-notify-test05-dir-validity |
| 613 | "Check `file-notify-valid-p' via file notification for remote directories.") | 775 | "Check `file-notify-valid-p' via file notification for remote directories.") |
| 614 | 776 | ||
| 777 | (ert-deftest file-notify-test06-many-events () | ||
| 778 | "Check that events are not dropped." | ||
| 779 | (skip-unless (file-notify--test-local-enabled)) | ||
| 780 | ;; Under cygwin events arrive in random order. Impossible to define a test. | ||
| 781 | (skip-unless (not (eq system-type 'cygwin))) | ||
| 782 | |||
| 783 | (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)) | ||
| 784 | (make-directory file-notify--test-tmpfile) | ||
| 785 | (should | ||
| 786 | (setq file-notify--test-desc | ||
| 787 | (file-notify-add-watch | ||
| 788 | file-notify--test-tmpfile | ||
| 789 | '(change) 'file-notify--test-event-handler))) | ||
| 790 | (unwind-protect | ||
| 791 | (let ((n 1000) | ||
| 792 | source-file-list target-file-list | ||
| 793 | (default-directory file-notify--test-tmpfile)) | ||
| 794 | (dotimes (i n) | ||
| 795 | ;; It matters which direction we rename, at least for | ||
| 796 | ;; kqueue. This backend parses directories in alphabetic | ||
| 797 | ;; order (x%d before y%d). So we rename both directions. | ||
| 798 | (if (zerop (mod i 2)) | ||
| 799 | (progn | ||
| 800 | (push (expand-file-name (format "x%d" i)) source-file-list) | ||
| 801 | (push (expand-file-name (format "y%d" i)) target-file-list)) | ||
| 802 | (push (expand-file-name (format "y%d" i)) source-file-list) | ||
| 803 | (push (expand-file-name (format "x%d" i)) target-file-list))) | ||
| 804 | (file-notify--test-with-events (make-list (+ n n) 'created) | ||
| 805 | (let ((source-file-list source-file-list) | ||
| 806 | (target-file-list target-file-list)) | ||
| 807 | (while (and source-file-list target-file-list) | ||
| 808 | (read-event nil nil 0.1) | ||
| 809 | (write-region "" nil (pop source-file-list) nil 'no-message) | ||
| 810 | (read-event nil nil 0.1) | ||
| 811 | (write-region "" nil (pop target-file-list) nil 'no-message)))) | ||
| 812 | (file-notify--test-with-events | ||
| 813 | (cond | ||
| 814 | ;; w32notify fires both `deleted' and `renamed' events. | ||
| 815 | ((string-equal (file-notify--test-library) "w32notify") | ||
| 816 | (let (r) | ||
| 817 | (dotimes (i n r) | ||
| 818 | (setq r (append '(deleted renamed) r))))) | ||
| 819 | (t (make-list n 'renamed))) | ||
| 820 | (let ((source-file-list source-file-list) | ||
| 821 | (target-file-list target-file-list)) | ||
| 822 | (while (and source-file-list target-file-list) | ||
| 823 | (rename-file (pop source-file-list) (pop target-file-list) t)))) | ||
| 824 | (file-notify--test-with-events (make-list n 'deleted) | ||
| 825 | (dolist (file target-file-list) | ||
| 826 | (delete-file file)))) | ||
| 827 | (file-notify--test-cleanup))) | ||
| 828 | |||
| 829 | (file-notify--deftest-remote file-notify-test06-many-events | ||
| 830 | "Check that events are not dropped for remote directories.") | ||
| 831 | |||
| 615 | (defun file-notify-test-all (&optional interactive) | 832 | (defun file-notify-test-all (&optional interactive) |
| 616 | "Run all tests for \\[file-notify]." | 833 | "Run all tests for \\[file-notify]." |
| 617 | (interactive "p") | 834 | (interactive "p") |
| @@ -622,7 +839,7 @@ Don't wait longer than timeout seconds for the events to be delivered." | |||
| 622 | ;; TODO: | 839 | ;; TODO: |
| 623 | 840 | ||
| 624 | ;; * For w32notify, no stopped events arrive when a directory is removed. | 841 | ;; * For w32notify, no stopped events arrive when a directory is removed. |
| 625 | ;; * Try to handle arriving events under cygwin reliably. | 842 | ;; * Check, why cygwin recognizes only `deleted' and `stopped' events. |
| 626 | 843 | ||
| 627 | (provide 'file-notify-tests) | 844 | (provide 'file-notify-tests) |
| 628 | ;;; file-notify-tests.el ends here | 845 | ;;; file-notify-tests.el ends here |