diff options
| author | Michael Albinus | 2013-07-09 09:52:25 +0200 |
|---|---|---|
| committer | Michael Albinus | 2013-07-09 09:52:25 +0200 |
| commit | 59eb37e5f5ed23dc322af9a80d78a4923ee39db9 (patch) | |
| tree | d958706ee690beb24e75636084919a29fdaa4ad2 | |
| parent | 0b57d6fc8e9e5c5b4ea27fd8507965a6124fc785 (diff) | |
| download | emacs-59eb37e5f5ed23dc322af9a80d78a4923ee39db9.tar.gz emacs-59eb37e5f5ed23dc322af9a80d78a4923ee39db9.zip | |
* automated/file-notify-tests.el (file-notify-test00-availability):
Set :expected-result.
(file-notify-test01-add-watch, file-notify-test01-add-watch-remote)
(file-notify-test02-events, file-notify-test02-events-remote)
(file-notify-test03-autorevert, file-notify-test03-autorevert-remote):
Skip when `file-notify-support' is nil. (Bug#14823)
| -rw-r--r-- | test/ChangeLog | 9 | ||||
| -rw-r--r-- | test/automated/file-notify-tests.el | 151 |
2 files changed, 89 insertions, 71 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 304afeac6e4..0a9bedcb5d8 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2013-07-09 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * automated/file-notify-tests.el (file-notify-test00-availability): | ||
| 4 | Set :expected-result. | ||
| 5 | (file-notify-test01-add-watch, file-notify-test01-add-watch-remote) | ||
| 6 | (file-notify-test02-events, file-notify-test02-events-remote) | ||
| 7 | (file-notify-test03-autorevert, file-notify-test03-autorevert-remote): | ||
| 8 | Skip when `file-notify-support' is nil. (Bug#14823) | ||
| 9 | |||
| 1 | 2013-07-09 Glenn Morris <rgm@gnu.org> | 10 | 2013-07-09 Glenn Morris <rgm@gnu.org> |
| 2 | 11 | ||
| 3 | * automated/inotify-test.el (inotify-add-watch, inotify-rm-watch): | 12 | * automated/inotify-test.el (inotify-add-watch, inotify-rm-watch): |
diff --git a/test/automated/file-notify-tests.el b/test/automated/file-notify-tests.el index 8fcfbe548fc..0e9be33f157 100644 --- a/test/automated/file-notify-tests.el +++ b/test/automated/file-notify-tests.el | |||
| @@ -77,40 +77,46 @@ | |||
| 77 | 77 | ||
| 78 | (ert-deftest file-notify-test00-availability () | 78 | (ert-deftest file-notify-test00-availability () |
| 79 | "Test availability of `file-notify'." | 79 | "Test availability of `file-notify'." |
| 80 | :expected-result (if file-notify-support :passed :failed) | ||
| 80 | (should (memq file-notify-support '(gfilenotify inotify w32notify)))) | 81 | (should (memq file-notify-support '(gfilenotify inotify w32notify)))) |
| 81 | 82 | ||
| 82 | (ert-deftest file-notify-test01-add-watch () | 83 | (when file-notify-support |
| 83 | "Check `file-notify-add-watch'." | ||
| 84 | (let (desc) | ||
| 85 | ;; Check, that different valid parameters are accepted. | ||
| 86 | (should (setq desc (file-notify-add-watch | ||
| 87 | temporary-file-directory '(change) 'ignore))) | ||
| 88 | (file-notify-rm-watch desc) | ||
| 89 | (should (setq desc (file-notify-add-watch | ||
| 90 | temporary-file-directory '(attribute-change) 'ignore))) | ||
| 91 | (file-notify-rm-watch desc) | ||
| 92 | (should (setq desc (file-notify-add-watch | ||
| 93 | temporary-file-directory | ||
| 94 | '(change attribute-change) 'ignore))) | ||
| 95 | (file-notify-rm-watch desc) | ||
| 96 | |||
| 97 | ;; Check error handling. | ||
| 98 | (should | ||
| 99 | (equal (car (should-error (file-notify-add-watch 1 2 3 4))) | ||
| 100 | 'wrong-number-of-arguments)) | ||
| 101 | (should | ||
| 102 | (equal (should-error (file-notify-add-watch 1 2 3)) | ||
| 103 | '(wrong-type-argument 1))) | ||
| 104 | (should | ||
| 105 | (equal (should-error (file-notify-add-watch temporary-file-directory 2 3)) | ||
| 106 | '(wrong-type-argument 2))) | ||
| 107 | (should | ||
| 108 | (equal (should-error (file-notify-add-watch | ||
| 109 | temporary-file-directory '(change) 3)) | ||
| 110 | '(wrong-type-argument 3))))) | ||
| 111 | 84 | ||
| 112 | (file-notify--deftest-remote file-notify-test01-add-watch | 85 | (ert-deftest file-notify-test01-add-watch () |
| 113 | "Check `file-notify-add-watch' for remote files.") | 86 | "Check `file-notify-add-watch'." |
| 87 | (let (desc) | ||
| 88 | ;; Check, that different valid parameters are accepted. | ||
| 89 | (should (setq desc (file-notify-add-watch | ||
| 90 | temporary-file-directory '(change) 'ignore))) | ||
| 91 | (file-notify-rm-watch desc) | ||
| 92 | (should (setq desc (file-notify-add-watch | ||
| 93 | temporary-file-directory | ||
| 94 | '(attribute-change) 'ignore))) | ||
| 95 | (file-notify-rm-watch desc) | ||
| 96 | (should (setq desc (file-notify-add-watch | ||
| 97 | temporary-file-directory | ||
| 98 | '(change attribute-change) 'ignore))) | ||
| 99 | (file-notify-rm-watch desc) | ||
| 100 | |||
| 101 | ;; Check error handling. | ||
| 102 | (should | ||
| 103 | (equal (car (should-error (file-notify-add-watch 1 2 3 4))) | ||
| 104 | 'wrong-number-of-arguments)) | ||
| 105 | (should | ||
| 106 | (equal (should-error (file-notify-add-watch 1 2 3)) | ||
| 107 | '(wrong-type-argument 1))) | ||
| 108 | (should | ||
| 109 | (equal (should-error (file-notify-add-watch | ||
| 110 | temporary-file-directory 2 3)) | ||
| 111 | '(wrong-type-argument 2))) | ||
| 112 | (should | ||
| 113 | (equal (should-error (file-notify-add-watch | ||
| 114 | temporary-file-directory '(change) 3)) | ||
| 115 | '(wrong-type-argument 3))))) | ||
| 116 | |||
| 117 | (file-notify--deftest-remote file-notify-test01-add-watch | ||
| 118 | "Check `file-notify-add-watch' for remote files.") | ||
| 119 | ) ;; file-notify-support | ||
| 114 | 120 | ||
| 115 | (defun file-notify--test-event-test () | 121 | (defun file-notify--test-event-test () |
| 116 | "Ert test function to be called by `file-notify--test-event-handler'. | 122 | "Ert test function to be called by `file-notify--test-event-handler'. |
| @@ -141,52 +147,55 @@ Save the result in `file-notify--test-results', for later analysis." | |||
| 141 | (expand-file-name | 147 | (expand-file-name |
| 142 | (make-temp-name "file-notify-test") temporary-file-directory)) | 148 | (make-temp-name "file-notify-test") temporary-file-directory)) |
| 143 | 149 | ||
| 144 | (ert-deftest file-notify-test02-events () | 150 | (when file-notify-support |
| 145 | "Check file creation/removal notifications." | 151 | |
| 146 | (let (desc) | 152 | (ert-deftest file-notify-test02-events () |
| 147 | (unwind-protect | 153 | "Check file creation/removal notifications." |
| 148 | (progn | 154 | (let (desc) |
| 149 | (setq file-notify--test-results nil | 155 | (unwind-protect |
| 150 | file-notify--test-tmpfile (file-notify--test-make-temp-name) | 156 | (progn |
| 151 | file-notify--test-tmpfile1 (file-notify--test-make-temp-name) | 157 | (setq file-notify--test-results nil |
| 152 | desc | 158 | file-notify--test-tmpfile (file-notify--test-make-temp-name) |
| 153 | (file-notify-add-watch | 159 | file-notify--test-tmpfile1 (file-notify--test-make-temp-name) |
| 154 | file-notify--test-tmpfile | 160 | desc |
| 155 | '(change) 'file-notify--test-event-handler)) | 161 | (file-notify-add-watch |
| 156 | 162 | file-notify--test-tmpfile | |
| 157 | ;; Check creation and removal. | 163 | '(change) 'file-notify--test-event-handler)) |
| 158 | (write-region "any text" nil file-notify--test-tmpfile) | 164 | |
| 159 | (delete-file file-notify--test-tmpfile) | 165 | ;; Check creation and removal. |
| 160 | 166 | (write-region "any text" nil file-notify--test-tmpfile) | |
| 161 | ;; Check copy and rename. | 167 | (delete-file file-notify--test-tmpfile) |
| 162 | (write-region "any text" nil file-notify--test-tmpfile) | 168 | |
| 163 | (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1) | 169 | ;; Check copy and rename. |
| 164 | (delete-file file-notify--test-tmpfile) | 170 | (write-region "any text" nil file-notify--test-tmpfile) |
| 165 | (delete-file file-notify--test-tmpfile1) | 171 | (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1) |
| 166 | 172 | (delete-file file-notify--test-tmpfile) | |
| 167 | (write-region "any text" nil file-notify--test-tmpfile) | 173 | (delete-file file-notify--test-tmpfile1) |
| 168 | (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1) | 174 | |
| 169 | (delete-file file-notify--test-tmpfile1)) | 175 | (write-region "any text" nil file-notify--test-tmpfile) |
| 170 | 176 | (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1) | |
| 171 | ;; Wait for events, and exit. | 177 | (delete-file file-notify--test-tmpfile1)) |
| 172 | (sit-for 5 'nodisplay) | 178 | |
| 173 | (file-notify-rm-watch desc) | 179 | ;; Wait for events, and exit. |
| 174 | (ignore-errors (delete-file file-notify--test-tmpfile)) | 180 | (sit-for 5 'nodisplay) |
| 175 | (ignore-errors (delete-file file-notify--test-tmpfile1)))) | 181 | (file-notify-rm-watch desc) |
| 182 | (ignore-errors (delete-file file-notify--test-tmpfile)) | ||
| 183 | (ignore-errors (delete-file file-notify--test-tmpfile1)))) | ||
| 176 | 184 | ||
| 177 | (dolist (result file-notify--test-results) | 185 | (dolist (result file-notify--test-results) |
| 178 | ;(message "%s" (ert-test-result-messages result)) | 186 | ;(message "%s" (ert-test-result-messages result)) |
| 179 | (when (ert-test-failed-p result) | 187 | (when (ert-test-failed-p result) |
| 180 | (ert-fail (cadr (ert-test-result-with-condition-condition result)))))) | 188 | (ert-fail (cadr (ert-test-result-with-condition-condition result)))))) |
| 181 | 189 | ||
| 182 | (file-notify--deftest-remote file-notify-test02-events | 190 | (file-notify--deftest-remote file-notify-test02-events |
| 183 | "Check file creation/removal notifications for remote files.") | 191 | "Check file creation/removal notifications for remote files.") |
| 192 | ) ;; file-notify-support | ||
| 184 | 193 | ||
| 185 | ;; autorevert runs only in interactive mode. | 194 | ;; autorevert runs only in interactive mode. |
| 186 | (defvar auto-revert-remote-files) | 195 | (defvar auto-revert-remote-files) |
| 187 | (setq auto-revert-remote-files t) | 196 | (setq auto-revert-remote-files t) |
| 188 | (require 'autorevert) | 197 | (require 'autorevert) |
| 189 | (when (null noninteractive) | 198 | (when (and file-notify-support (null noninteractive)) |
| 190 | 199 | ||
| 191 | (ert-deftest file-notify-test03-autorevert () | 200 | (ert-deftest file-notify-test03-autorevert () |
| 192 | "Check autorevert via file notification. | 201 | "Check autorevert via file notification. |
| @@ -240,7 +249,7 @@ This test is skipped in batch mode." | |||
| 240 | (file-notify--deftest-remote file-notify-test03-autorevert | 249 | (file-notify--deftest-remote file-notify-test03-autorevert |
| 241 | "Check autorevert via file notification for remote files. | 250 | "Check autorevert via file notification for remote files. |
| 242 | This test is skipped in batch mode.") | 251 | This test is skipped in batch mode.") |
| 243 | ) ;; (null noninteractive) | 252 | ) ;; (and file-notify-support (null noninteractive)) |
| 244 | 253 | ||
| 245 | (defun file-notify-test-all (&optional interactive) | 254 | (defun file-notify-test-all (&optional interactive) |
| 246 | "Run all tests for \\[file-notify]." | 255 | "Run all tests for \\[file-notify]." |