diff options
| author | Michael Albinus | 2015-10-27 16:02:26 +0100 |
|---|---|---|
| committer | Michael Albinus | 2015-10-27 16:02:26 +0100 |
| commit | 838023d469054cc19d0a2b7cf48e39082d8220f0 (patch) | |
| tree | c6e4bd985901ab909948332d6b67e3c47b471ee5 /test | |
| parent | 99ded6be7afe843d7abc0e255fe36b684435cfd7 (diff) | |
| download | emacs-838023d469054cc19d0a2b7cf48e39082d8220f0.tar.gz emacs-838023d469054cc19d0a2b7cf48e39082d8220f0.zip | |
Fall back to polling in autorevert when needed
* lisp/autorevert.el (auto-revert-notify-handler): When a
`stopped' event arrives from file notification, fall back to polling.
* test/automated/file-notify-tests.el
(file-notify-test03-autorevert): Extend test for polling when file
notification ceases to work.
Diffstat (limited to 'test')
| -rw-r--r-- | test/automated/file-notify-tests.el | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/test/automated/file-notify-tests.el b/test/automated/file-notify-tests.el index 472c6927b87..f411c6b76b0 100644 --- a/test/automated/file-notify-tests.el +++ b/test/automated/file-notify-tests.el | |||
| @@ -461,6 +461,8 @@ Don't wait longer than TIMEOUT seconds for the events to be delivered." | |||
| 461 | 461 | ||
| 462 | ;; Modify file. We wait for a second, in order to | 462 | ;; Modify file. We wait for a second, in order to |
| 463 | ;; have another timestamp. | 463 | ;; have another timestamp. |
| 464 | (with-current-buffer (get-buffer-create "*Messages*") | ||
| 465 | (narrow-to-region (point-max) (point-max))) | ||
| 464 | (sleep-for 1) | 466 | (sleep-for 1) |
| 465 | (write-region | 467 | (write-region |
| 466 | "another text" nil file-notify--test-tmpfile nil 'no-message) | 468 | "another text" nil file-notify--test-tmpfile nil 'no-message) |
| @@ -472,9 +474,34 @@ Don't wait longer than TIMEOUT seconds for the events to be delivered." | |||
| 472 | (string-match | 474 | (string-match |
| 473 | (format-message "Reverting buffer `%s'." (buffer-name buf)) | 475 | (format-message "Reverting buffer `%s'." (buffer-name buf)) |
| 474 | (buffer-string)))) | 476 | (buffer-string)))) |
| 475 | (should (string-match "another text" (buffer-string))))) | 477 | (should (string-match "another text" (buffer-string))) |
| 478 | |||
| 479 | ;; Stop file notification. Autorevert shall still work via polling. | ||
| 480 | (file-notify-rm-watch auto-revert-notify-watch-descriptor) | ||
| 481 | (file-notify--wait-for-events | ||
| 482 | timeout (null auto-revert-use-notify)) | ||
| 483 | (should-not auto-revert-use-notify) | ||
| 484 | (should-not auto-revert-notify-watch-descriptor) | ||
| 485 | |||
| 486 | ;; Modify file. We wait for a second, in order to | ||
| 487 | ;; have another timestamp. | ||
| 488 | (with-current-buffer (get-buffer-create "*Messages*") | ||
| 489 | (narrow-to-region (point-max) (point-max))) | ||
| 490 | (sleep-for 2) | ||
| 491 | (write-region | ||
| 492 | "foo bla" nil file-notify--test-tmpfile nil 'no-message) | ||
| 493 | |||
| 494 | ;; Check, that the buffer has been reverted. | ||
| 495 | (with-current-buffer (get-buffer-create "*Messages*") | ||
| 496 | (file-notify--wait-for-events | ||
| 497 | timeout | ||
| 498 | (string-match | ||
| 499 | (format-message "Reverting buffer `%s'." (buffer-name buf)) | ||
| 500 | (buffer-string)))) | ||
| 501 | (should (string-match "foo bla" (buffer-string))))) | ||
| 476 | 502 | ||
| 477 | ;; Cleanup. | 503 | ;; Cleanup. |
| 504 | (with-current-buffer "*Messages*" (widen)) | ||
| 478 | (ignore-errors (kill-buffer buf)) | 505 | (ignore-errors (kill-buffer buf)) |
| 479 | (file-notify--test-cleanup)))) | 506 | (file-notify--test-cleanup)))) |
| 480 | 507 | ||