diff options
| author | Michael Albinus | 2015-11-07 11:05:03 +0100 |
|---|---|---|
| committer | Michael Albinus | 2015-11-07 11:05:03 +0100 |
| commit | b29be628889c4bdec24f14a3352848d559446a70 (patch) | |
| tree | d37f44b454d9b73b6723a875e02ce75e4f5d26a7 | |
| parent | 07178f43e16dc343c67bf9525fbccf049b1aedba (diff) | |
| download | emacs-b29be628889c4bdec24f14a3352848d559446a70.tar.gz emacs-b29be628889c4bdec24f14a3352848d559446a70.zip | |
Add test to auto-revert-tests.el for Bug#21841
* test/automated/auto-revert-tests.el
(auto-revert-test01-auto-revert-several-files): New test.
(auto-revert-test02-auto-revert-tail-mode)
(auto-revert-test03-auto-revert-mode-dired): Rename them.
| -rw-r--r-- | test/automated/auto-revert-tests.el | 68 |
1 files changed, 66 insertions, 2 deletions
diff --git a/test/automated/auto-revert-tests.el b/test/automated/auto-revert-tests.el index 7cabc5c3e66..2745f106087 100644 --- a/test/automated/auto-revert-tests.el +++ b/test/automated/auto-revert-tests.el | |||
| @@ -89,7 +89,71 @@ | |||
| 89 | (kill-buffer buf)) | 89 | (kill-buffer buf)) |
| 90 | (ignore-errors (delete-file tmpfile))))) | 90 | (ignore-errors (delete-file tmpfile))))) |
| 91 | 91 | ||
| 92 | (ert-deftest auto-revert-test01-auto-revert-tail-mode () | 92 | ;; This is inspired by Bug#21841. |
| 93 | (ert-deftest auto-revert-test01-auto-revert-several-files () | ||
| 94 | "Check autorevert for several files at once." | ||
| 95 | (skip-unless (executable-find "cp")) | ||
| 96 | |||
| 97 | (let* ((cp (executable-find "cp")) | ||
| 98 | (tmpdir1 (make-temp-file "auto-revert-test" 'dir)) | ||
| 99 | (tmpdir2 (make-temp-file "auto-revert-test" 'dir)) | ||
| 100 | (tmpfile1 | ||
| 101 | (make-temp-file (expand-file-name "auto-revert-test" tmpdir1))) | ||
| 102 | (tmpfile2 | ||
| 103 | (make-temp-file (expand-file-name "auto-revert-test" tmpdir1))) | ||
| 104 | buf1 buf2) | ||
| 105 | (unwind-protect | ||
| 106 | (progn | ||
| 107 | (with-current-buffer (get-buffer-create "*Messages*") | ||
| 108 | (narrow-to-region (point-max) (point-max))) | ||
| 109 | (write-region "any text" nil tmpfile1 nil 'no-message) | ||
| 110 | (setq buf1 (find-file-noselect tmpfile1)) | ||
| 111 | (write-region "any text" nil tmpfile2 nil 'no-message) | ||
| 112 | (setq buf2 (find-file-noselect tmpfile2)) | ||
| 113 | |||
| 114 | (dolist (buf (list buf1 buf2)) | ||
| 115 | (with-current-buffer buf | ||
| 116 | (should (string-equal (buffer-string) "any text")) | ||
| 117 | ;; `buffer-stale--default-function' checks for | ||
| 118 | ;; `verify-visited-file-modtime'. We must ensure that | ||
| 119 | ;; it returns nil. | ||
| 120 | (sleep-for 1) | ||
| 121 | (auto-revert-mode 1) | ||
| 122 | (should auto-revert-mode))) | ||
| 123 | |||
| 124 | ;; Modify files. We wait for a second, in order to have | ||
| 125 | ;; another timestamp. | ||
| 126 | (sleep-for 1) | ||
| 127 | (write-region | ||
| 128 | "another text" nil | ||
| 129 | (expand-file-name (file-name-nondirectory tmpfile1) tmpdir2) | ||
| 130 | nil 'no-message) | ||
| 131 | (write-region | ||
| 132 | "another text" nil | ||
| 133 | (expand-file-name (file-name-nondirectory tmpfile2) tmpdir2) | ||
| 134 | nil 'no-message) | ||
| 135 | ;;(copy-directory tmpdir2 tmpdir1 nil 'copy-contents) | ||
| 136 | ;; Strange, that `copy-directory' does not work as expected. | ||
| 137 | ;; The following shell command is not portable on all | ||
| 138 | ;; platforms, unfortunately. | ||
| 139 | (shell-command (format "%s -f %s/* %s" cp tmpdir2 tmpdir1)) | ||
| 140 | |||
| 141 | ;; Check, that the buffers have been reverted. | ||
| 142 | (dolist (buf (list buf1 buf2)) | ||
| 143 | (with-current-buffer buf | ||
| 144 | (auto-revert--wait-for-revert buf) | ||
| 145 | (should (string-match "another text" (buffer-string)))))) | ||
| 146 | |||
| 147 | ;; Exit. | ||
| 148 | (with-current-buffer "*Messages*" (widen)) | ||
| 149 | (ignore-errors | ||
| 150 | (dolist (buf (list buf1 buf2)) | ||
| 151 | (with-current-buffer buf (set-buffer-modified-p nil)) | ||
| 152 | (kill-buffer buf))) | ||
| 153 | (ignore-errors (delete-directory tmpdir1 'recursive)) | ||
| 154 | (ignore-errors (delete-directory tmpdir2 'recursive))))) | ||
| 155 | |||
| 156 | (ert-deftest auto-revert-test02-auto-revert-tail-mode () | ||
| 93 | "Check autorevert tail mode." | 157 | "Check autorevert tail mode." |
| 94 | ;; `auto-revert-buffers' runs every 5". And we must wait, until the | 158 | ;; `auto-revert-buffers' runs every 5". And we must wait, until the |
| 95 | ;; file has been reverted. | 159 | ;; file has been reverted. |
| @@ -127,7 +191,7 @@ | |||
| 127 | (ignore-errors (kill-buffer buf)) | 191 | (ignore-errors (kill-buffer buf)) |
| 128 | (ignore-errors (delete-file tmpfile))))) | 192 | (ignore-errors (delete-file tmpfile))))) |
| 129 | 193 | ||
| 130 | (ert-deftest auto-revert-test02-auto-revert-mode-dired () | 194 | (ert-deftest auto-revert-test03-auto-revert-mode-dired () |
| 131 | "Check autorevert for dired." | 195 | "Check autorevert for dired." |
| 132 | ;; `auto-revert-buffers' runs every 5". And we must wait, until the | 196 | ;; `auto-revert-buffers' runs every 5". And we must wait, until the |
| 133 | ;; file has been reverted. | 197 | ;; file has been reverted. |