diff options
| -rw-r--r-- | test/ChangeLog | 11 | ||||
| -rw-r--r-- | test/automated/file-notify-tests.el | 47 |
2 files changed, 41 insertions, 17 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 0626d92b207..bffe85e6a7a 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2013-07-24 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * automated/file-notify-tests.el | ||
| 4 | (file-notify--test-local-enabled): New defconst. Replaces all | ||
| 5 | `file-notify-support' occurences. | ||
| 6 | (file-notify--test-remote-enabled): New defun. | ||
| 7 | (file-notify--deftest-remote): Use it. | ||
| 8 | (file-notify-test00-availability): Rewrite. | ||
| 9 | (file-notify-test00-availability-remote): New defun. | ||
| 10 | (file-notify-test01-add-watch): Rewrite first erroneous check. | ||
| 11 | |||
| 1 | 2013-07-23 Glenn Morris <rgm@gnu.org> | 12 | 2013-07-23 Glenn Morris <rgm@gnu.org> |
| 2 | 13 | ||
| 3 | * automated/inotify-test.el (inotify-file-watch-simple): | 14 | * automated/inotify-test.el (inotify-file-watch-simple): |
diff --git a/test/automated/file-notify-tests.el b/test/automated/file-notify-tests.el index 0e9be33f157..8bd4f258b1c 100644 --- a/test/automated/file-notify-tests.el +++ b/test/automated/file-notify-tests.el | |||
| @@ -47,13 +47,21 @@ | |||
| 47 | tramp-message-show-message nil) | 47 | tramp-message-show-message nil) |
| 48 | (when noninteractive (defalias 'tramp-read-passwd 'ignore)) | 48 | (when noninteractive (defalias 'tramp-read-passwd 'ignore)) |
| 49 | 49 | ||
| 50 | ;; We do not want to try and fail `file-notify-add-watch'. | ||
| 51 | (defconst file-notify--test-local-enabled file-notify--library | ||
| 52 | "Whether local file notification is enabled.") | ||
| 53 | |||
| 54 | ;; We need also a check on the remote side, w/o adding a file monitor. | ||
| 55 | (defun file-notify--test-remote-enabled () | ||
| 56 | "Whether remote file notification is enabled." | ||
| 57 | (ignore-errors | ||
| 58 | (and (file-remote-p file-notify-test-remote-temporary-file-directory) | ||
| 59 | (file-directory-p file-notify-test-remote-temporary-file-directory) | ||
| 60 | (file-writable-p file-notify-test-remote-temporary-file-directory)))) | ||
| 61 | |||
| 50 | (defmacro file-notify--deftest-remote (test docstring) | 62 | (defmacro file-notify--deftest-remote (test docstring) |
| 51 | "Define ert `TEST-remote' for remote files." | 63 | "Define ert `TEST-remote' for remote files." |
| 52 | `(when (ignore-errors | 64 | `(when (and (file-notify--test-remote-enabled) (ert-get-test ',test)) |
| 53 | (and | ||
| 54 | (file-remote-p file-notify-test-remote-temporary-file-directory) | ||
| 55 | (file-directory-p file-notify-test-remote-temporary-file-directory) | ||
| 56 | (file-writable-p file-notify-test-remote-temporary-file-directory))) | ||
| 57 | ;; Define the test. | 65 | ;; Define the test. |
| 58 | (ert-deftest ,(intern (concat (symbol-name test) "-remote")) () | 66 | (ert-deftest ,(intern (concat (symbol-name test) "-remote")) () |
| 59 | ,docstring | 67 | ,docstring |
| @@ -77,10 +85,16 @@ | |||
| 77 | 85 | ||
| 78 | (ert-deftest file-notify-test00-availability () | 86 | (ert-deftest file-notify-test00-availability () |
| 79 | "Test availability of `file-notify'." | 87 | "Test availability of `file-notify'." |
| 80 | :expected-result (if file-notify-support :passed :failed) | 88 | (let (desc) |
| 81 | (should (memq file-notify-support '(gfilenotify inotify w32notify)))) | 89 | ;; Check, that different valid parameters are accepted. |
| 90 | (should (setq desc (file-notify-add-watch | ||
| 91 | temporary-file-directory '(change) 'ignore))) | ||
| 92 | (file-notify-rm-watch desc))) | ||
| 93 | |||
| 94 | (file-notify--deftest-remote file-notify-test00-availability | ||
| 95 | "Test availability of `file-notify' for remote files.") | ||
| 82 | 96 | ||
| 83 | (when file-notify-support | 97 | (when file-notify--test-local-enabled |
| 84 | 98 | ||
| 85 | (ert-deftest file-notify-test01-add-watch () | 99 | (ert-deftest file-notify-test01-add-watch () |
| 86 | "Check `file-notify-add-watch'." | 100 | "Check `file-notify-add-watch'." |
| @@ -99,9 +113,8 @@ | |||
| 99 | (file-notify-rm-watch desc) | 113 | (file-notify-rm-watch desc) |
| 100 | 114 | ||
| 101 | ;; Check error handling. | 115 | ;; Check error handling. |
| 102 | (should | 116 | (should-error (file-notify-add-watch 1 2 3 4) |
| 103 | (equal (car (should-error (file-notify-add-watch 1 2 3 4))) | 117 | :type 'wrong-number-of-arguments) |
| 104 | 'wrong-number-of-arguments)) | ||
| 105 | (should | 118 | (should |
| 106 | (equal (should-error (file-notify-add-watch 1 2 3)) | 119 | (equal (should-error (file-notify-add-watch 1 2 3)) |
| 107 | '(wrong-type-argument 1))) | 120 | '(wrong-type-argument 1))) |
| @@ -116,7 +129,7 @@ | |||
| 116 | 129 | ||
| 117 | (file-notify--deftest-remote file-notify-test01-add-watch | 130 | (file-notify--deftest-remote file-notify-test01-add-watch |
| 118 | "Check `file-notify-add-watch' for remote files.") | 131 | "Check `file-notify-add-watch' for remote files.") |
| 119 | ) ;; file-notify-support | 132 | ) ;; file-notify--test-local-enabled |
| 120 | 133 | ||
| 121 | (defun file-notify--test-event-test () | 134 | (defun file-notify--test-event-test () |
| 122 | "Ert test function to be called by `file-notify--test-event-handler'. | 135 | "Ert test function to be called by `file-notify--test-event-handler'. |
| @@ -147,7 +160,7 @@ Save the result in `file-notify--test-results', for later analysis." | |||
| 147 | (expand-file-name | 160 | (expand-file-name |
| 148 | (make-temp-name "file-notify-test") temporary-file-directory)) | 161 | (make-temp-name "file-notify-test") temporary-file-directory)) |
| 149 | 162 | ||
| 150 | (when file-notify-support | 163 | (when file-notify--test-local-enabled |
| 151 | 164 | ||
| 152 | (ert-deftest file-notify-test02-events () | 165 | (ert-deftest file-notify-test02-events () |
| 153 | "Check file creation/removal notifications." | 166 | "Check file creation/removal notifications." |
| @@ -189,13 +202,13 @@ Save the result in `file-notify--test-results', for later analysis." | |||
| 189 | 202 | ||
| 190 | (file-notify--deftest-remote file-notify-test02-events | 203 | (file-notify--deftest-remote file-notify-test02-events |
| 191 | "Check file creation/removal notifications for remote files.") | 204 | "Check file creation/removal notifications for remote files.") |
| 192 | ) ;; file-notify-support | 205 | ) ;; file-notify--test-local-enabled |
| 193 | 206 | ||
| 194 | ;; autorevert runs only in interactive mode. | 207 | ;; autorevert runs only in interactive mode. |
| 195 | (defvar auto-revert-remote-files) | 208 | (defvar auto-revert-remote-files) |
| 196 | (setq auto-revert-remote-files t) | 209 | (setq auto-revert-remote-files t) |
| 197 | (require 'autorevert) | 210 | (require 'autorevert) |
| 198 | (when (and file-notify-support (null noninteractive)) | 211 | (when (and file-notify--test-local-enabled (null noninteractive)) |
| 199 | 212 | ||
| 200 | (ert-deftest file-notify-test03-autorevert () | 213 | (ert-deftest file-notify-test03-autorevert () |
| 201 | "Check autorevert via file notification. | 214 | "Check autorevert via file notification. |
| @@ -249,12 +262,12 @@ This test is skipped in batch mode." | |||
| 249 | (file-notify--deftest-remote file-notify-test03-autorevert | 262 | (file-notify--deftest-remote file-notify-test03-autorevert |
| 250 | "Check autorevert via file notification for remote files. | 263 | "Check autorevert via file notification for remote files. |
| 251 | This test is skipped in batch mode.") | 264 | This test is skipped in batch mode.") |
| 252 | ) ;; (and file-notify-support (null noninteractive)) | 265 | ) ;; (and file-notify--test-local-enabled (null noninteractive)) |
| 253 | 266 | ||
| 254 | (defun file-notify-test-all (&optional interactive) | 267 | (defun file-notify-test-all (&optional interactive) |
| 255 | "Run all tests for \\[file-notify]." | 268 | "Run all tests for \\[file-notify]." |
| 256 | (interactive "p") | 269 | (interactive "p") |
| 257 | (when file-notify-support | 270 | (when file-notify--test-local-enabled |
| 258 | (if interactive | 271 | (if interactive |
| 259 | (ert-run-tests-interactively "^file-notify-") | 272 | (ert-run-tests-interactively "^file-notify-") |
| 260 | (ert-run-tests-batch "^file-notify-")))) | 273 | (ert-run-tests-batch "^file-notify-")))) |