diff options
Diffstat (limited to 'test/lisp/filenotify-tests.el')
| -rw-r--r-- | test/lisp/filenotify-tests.el | 70 |
1 files changed, 40 insertions, 30 deletions
diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el index d237d0cc06e..27434bcef20 100644 --- a/test/lisp/filenotify-tests.el +++ b/test/lisp/filenotify-tests.el | |||
| @@ -36,6 +36,7 @@ | |||
| 36 | ;;; Code: | 36 | ;;; Code: |
| 37 | 37 | ||
| 38 | (require 'ert) | 38 | (require 'ert) |
| 39 | (require 'ert-x) | ||
| 39 | (require 'filenotify) | 40 | (require 'filenotify) |
| 40 | (require 'tramp) | 41 | (require 'tramp) |
| 41 | 42 | ||
| @@ -703,21 +704,19 @@ delivered." | |||
| 703 | (should auto-revert-notify-watch-descriptor) | 704 | (should auto-revert-notify-watch-descriptor) |
| 704 | 705 | ||
| 705 | ;; Modify file. We wait for a second, in order to have | 706 | ;; Modify file. We wait for a second, in order to have |
| 706 | ;; another timestamp. | 707 | ;; another timestamp. |
| 707 | (with-current-buffer (get-buffer-create "*Messages*") | 708 | (ert-with-message-capture captured-messages |
| 708 | (narrow-to-region (point-max) (point-max))) | 709 | (sleep-for 1) |
| 709 | (sleep-for 1) | 710 | (write-region |
| 710 | (write-region | 711 | "another text" nil file-notify--test-tmpfile nil 'no-message) |
| 711 | "another text" nil file-notify--test-tmpfile nil 'no-message) | 712 | |
| 712 | 713 | ;; Check, that the buffer has been reverted. | |
| 713 | ;; Check, that the buffer has been reverted. | 714 | (file-notify--wait-for-events |
| 714 | (with-current-buffer (get-buffer-create "*Messages*") | 715 | timeout |
| 715 | (file-notify--wait-for-events | 716 | (string-match |
| 716 | timeout | ||
| 717 | (string-match | ||
| 718 | (format-message "Reverting buffer `%s'." (buffer-name buf)) | 717 | (format-message "Reverting buffer `%s'." (buffer-name buf)) |
| 719 | (buffer-string)))) | 718 | captured-messages)) |
| 720 | (should (string-match "another text" (buffer-string))) | 719 | (should (string-match "another text" (buffer-string)))) |
| 721 | 720 | ||
| 722 | ;; Stop file notification. Autorevert shall still work via polling. | 721 | ;; Stop file notification. Autorevert shall still work via polling. |
| 723 | (file-notify-rm-watch auto-revert-notify-watch-descriptor) | 722 | (file-notify-rm-watch auto-revert-notify-watch-descriptor) |
| @@ -728,27 +727,24 @@ delivered." | |||
| 728 | 727 | ||
| 729 | ;; Modify file. We wait for two seconds, in order to | 728 | ;; Modify file. We wait for two seconds, in order to |
| 730 | ;; have another timestamp. One second seems to be too | 729 | ;; have another timestamp. One second seems to be too |
| 731 | ;; short. | 730 | ;; short. |
| 732 | (with-current-buffer (get-buffer-create "*Messages*") | 731 | (ert-with-message-capture captured-messages |
| 733 | (narrow-to-region (point-max) (point-max))) | 732 | (sleep-for 2) |
| 734 | (sleep-for 2) | 733 | (write-region |
| 735 | (write-region | 734 | "foo bla" nil file-notify--test-tmpfile nil 'no-message) |
| 736 | "foo bla" nil file-notify--test-tmpfile nil 'no-message) | 735 | |
| 737 | 736 | ;; Check, that the buffer has been reverted. | |
| 738 | ;; Check, that the buffer has been reverted. | 737 | (file-notify--wait-for-events |
| 739 | (with-current-buffer (get-buffer-create "*Messages*") | 738 | timeout |
| 740 | (file-notify--wait-for-events | 739 | (string-match |
| 741 | timeout | 740 | (format-message "Reverting buffer `%s'." (buffer-name buf)) |
| 742 | (string-match | 741 | captured-messages)) |
| 743 | (format-message "Reverting buffer `%s'." (buffer-name buf)) | 742 | (should (string-match "foo bla" (buffer-string))))) |
| 744 | (buffer-string)))) | ||
| 745 | (should (string-match "foo bla" (buffer-string)))) | ||
| 746 | 743 | ||
| 747 | ;; The environment shall be cleaned up. | 744 | ;; The environment shall be cleaned up. |
| 748 | (file-notify--test-cleanup-p)) | 745 | (file-notify--test-cleanup-p)) |
| 749 | 746 | ||
| 750 | ;; Cleanup. | 747 | ;; Cleanup. |
| 751 | (with-current-buffer "*Messages*" (widen)) | ||
| 752 | (ignore-errors (kill-buffer buf)) | 748 | (ignore-errors (kill-buffer buf)) |
| 753 | (file-notify--test-cleanup)))) | 749 | (file-notify--test-cleanup)))) |
| 754 | 750 | ||
| @@ -850,6 +846,13 @@ delivered." | |||
| 850 | ;; After deleting the parent directory, the descriptor must | 846 | ;; After deleting the parent directory, the descriptor must |
| 851 | ;; not be valid anymore. | 847 | ;; not be valid anymore. |
| 852 | (should-not (file-notify-valid-p file-notify--test-desc)) | 848 | (should-not (file-notify-valid-p file-notify--test-desc)) |
| 849 | ;; w32notify doesn't generate 'stopped' events when the parent | ||
| 850 | ;; directory is deleted, which doesn't provide a chance for | ||
| 851 | ;; filenotify.el to remove the descriptor from the internal | ||
| 852 | ;; hash table it maintains. So we must remove the descriptor | ||
| 853 | ;; manually. | ||
| 854 | (if (string-equal (file-notify--test-library) "w32notify") | ||
| 855 | (file-notify--rm-descriptor file-notify--test-desc)) | ||
| 853 | 856 | ||
| 854 | ;; The environment shall be cleaned up. | 857 | ;; The environment shall be cleaned up. |
| 855 | (file-notify--test-cleanup-p)) | 858 | (file-notify--test-cleanup-p)) |
| @@ -906,6 +909,8 @@ delivered." | |||
| 906 | (file-notify--test-timeout) | 909 | (file-notify--test-timeout) |
| 907 | (not (file-notify-valid-p file-notify--test-desc))) | 910 | (not (file-notify-valid-p file-notify--test-desc))) |
| 908 | (should-not (file-notify-valid-p file-notify--test-desc)) | 911 | (should-not (file-notify-valid-p file-notify--test-desc)) |
| 912 | (if (string-equal (file-notify--test-library) "w32notify") | ||
| 913 | (file-notify--rm-descriptor file-notify--test-desc)) | ||
| 909 | 914 | ||
| 910 | ;; The environment shall be cleaned up. | 915 | ;; The environment shall be cleaned up. |
| 911 | (file-notify--test-cleanup-p)) | 916 | (file-notify--test-cleanup-p)) |
| @@ -975,6 +980,8 @@ delivered." | |||
| 975 | (file-notify--test-read-event) | 980 | (file-notify--test-read-event) |
| 976 | (delete-file file))) | 981 | (delete-file file))) |
| 977 | (delete-directory file-notify--test-tmpfile) | 982 | (delete-directory file-notify--test-tmpfile) |
| 983 | (if (string-equal (file-notify--test-library) "w32notify") | ||
| 984 | (file-notify--rm-descriptor file-notify--test-desc)) | ||
| 978 | 985 | ||
| 979 | ;; The environment shall be cleaned up. | 986 | ;; The environment shall be cleaned up. |
| 980 | (file-notify--test-cleanup-p)) | 987 | (file-notify--test-cleanup-p)) |
| @@ -1184,6 +1191,9 @@ the file watch." | |||
| 1184 | (delete-directory file-notify--test-tmpfile 'recursive)) | 1191 | (delete-directory file-notify--test-tmpfile 'recursive)) |
| 1185 | (should-not (file-notify-valid-p file-notify--test-desc1)) | 1192 | (should-not (file-notify-valid-p file-notify--test-desc1)) |
| 1186 | (should-not (file-notify-valid-p file-notify--test-desc2)) | 1193 | (should-not (file-notify-valid-p file-notify--test-desc2)) |
| 1194 | (when (string-equal (file-notify--test-library) "w32notify") | ||
| 1195 | (file-notify--rm-descriptor file-notify--test-desc1) | ||
| 1196 | (file-notify--rm-descriptor file-notify--test-desc2)) | ||
| 1187 | 1197 | ||
| 1188 | ;; The environment shall be cleaned up. | 1198 | ;; The environment shall be cleaned up. |
| 1189 | (file-notify--test-cleanup-p)) | 1199 | (file-notify--test-cleanup-p)) |