summaryrefslogtreecommitdiff
path: root/test/automated/file-notify-tests.el
diff options
context:
space:
mode:
Diffstat (limited to 'test/automated/file-notify-tests.el')
-rw-r--r--test/automated/file-notify-tests.el151
1 files changed, 80 insertions, 71 deletions
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 @@
(ert-deftest file-notify-test00-availability ()
"Test availability of `file-notify'."
+ :expected-result (if file-notify-support :passed :failed)
(should (memq file-notify-support '(gfilenotify inotify w32notify))))
-(ert-deftest file-notify-test01-add-watch ()
- "Check `file-notify-add-watch'."
- (let (desc)
- ;; Check, that different valid parameters are accepted.
- (should (setq desc (file-notify-add-watch
- temporary-file-directory '(change) 'ignore)))
- (file-notify-rm-watch desc)
- (should (setq desc (file-notify-add-watch
- temporary-file-directory '(attribute-change) 'ignore)))
- (file-notify-rm-watch desc)
- (should (setq desc (file-notify-add-watch
- temporary-file-directory
- '(change attribute-change) 'ignore)))
- (file-notify-rm-watch desc)
-
- ;; Check error handling.
- (should
- (equal (car (should-error (file-notify-add-watch 1 2 3 4)))
- 'wrong-number-of-arguments))
- (should
- (equal (should-error (file-notify-add-watch 1 2 3))
- '(wrong-type-argument 1)))
- (should
- (equal (should-error (file-notify-add-watch temporary-file-directory 2 3))
- '(wrong-type-argument 2)))
- (should
- (equal (should-error (file-notify-add-watch
- temporary-file-directory '(change) 3))
- '(wrong-type-argument 3)))))
+(when file-notify-support
-(file-notify--deftest-remote file-notify-test01-add-watch
- "Check `file-notify-add-watch' for remote files.")
+ (ert-deftest file-notify-test01-add-watch ()
+ "Check `file-notify-add-watch'."
+ (let (desc)
+ ;; Check, that different valid parameters are accepted.
+ (should (setq desc (file-notify-add-watch
+ temporary-file-directory '(change) 'ignore)))
+ (file-notify-rm-watch desc)
+ (should (setq desc (file-notify-add-watch
+ temporary-file-directory
+ '(attribute-change) 'ignore)))
+ (file-notify-rm-watch desc)
+ (should (setq desc (file-notify-add-watch
+ temporary-file-directory
+ '(change attribute-change) 'ignore)))
+ (file-notify-rm-watch desc)
+
+ ;; Check error handling.
+ (should
+ (equal (car (should-error (file-notify-add-watch 1 2 3 4)))
+ 'wrong-number-of-arguments))
+ (should
+ (equal (should-error (file-notify-add-watch 1 2 3))
+ '(wrong-type-argument 1)))
+ (should
+ (equal (should-error (file-notify-add-watch
+ temporary-file-directory 2 3))
+ '(wrong-type-argument 2)))
+ (should
+ (equal (should-error (file-notify-add-watch
+ temporary-file-directory '(change) 3))
+ '(wrong-type-argument 3)))))
+
+ (file-notify--deftest-remote file-notify-test01-add-watch
+ "Check `file-notify-add-watch' for remote files.")
+ ) ;; file-notify-support
(defun file-notify--test-event-test ()
"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."
(expand-file-name
(make-temp-name "file-notify-test") temporary-file-directory))
-(ert-deftest file-notify-test02-events ()
- "Check file creation/removal notifications."
- (let (desc)
- (unwind-protect
- (progn
- (setq file-notify--test-results nil
- file-notify--test-tmpfile (file-notify--test-make-temp-name)
- file-notify--test-tmpfile1 (file-notify--test-make-temp-name)
- desc
- (file-notify-add-watch
- file-notify--test-tmpfile
- '(change) 'file-notify--test-event-handler))
-
- ;; Check creation and removal.
- (write-region "any text" nil file-notify--test-tmpfile)
- (delete-file file-notify--test-tmpfile)
-
- ;; Check copy and rename.
- (write-region "any text" nil file-notify--test-tmpfile)
- (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1)
- (delete-file file-notify--test-tmpfile)
- (delete-file file-notify--test-tmpfile1)
-
- (write-region "any text" nil file-notify--test-tmpfile)
- (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1)
- (delete-file file-notify--test-tmpfile1))
-
- ;; Wait for events, and exit.
- (sit-for 5 'nodisplay)
- (file-notify-rm-watch desc)
- (ignore-errors (delete-file file-notify--test-tmpfile))
- (ignore-errors (delete-file file-notify--test-tmpfile1))))
+(when file-notify-support
+
+ (ert-deftest file-notify-test02-events ()
+ "Check file creation/removal notifications."
+ (let (desc)
+ (unwind-protect
+ (progn
+ (setq file-notify--test-results nil
+ file-notify--test-tmpfile (file-notify--test-make-temp-name)
+ file-notify--test-tmpfile1 (file-notify--test-make-temp-name)
+ desc
+ (file-notify-add-watch
+ file-notify--test-tmpfile
+ '(change) 'file-notify--test-event-handler))
+
+ ;; Check creation and removal.
+ (write-region "any text" nil file-notify--test-tmpfile)
+ (delete-file file-notify--test-tmpfile)
+
+ ;; Check copy and rename.
+ (write-region "any text" nil file-notify--test-tmpfile)
+ (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1)
+ (delete-file file-notify--test-tmpfile)
+ (delete-file file-notify--test-tmpfile1)
+
+ (write-region "any text" nil file-notify--test-tmpfile)
+ (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1)
+ (delete-file file-notify--test-tmpfile1))
+
+ ;; Wait for events, and exit.
+ (sit-for 5 'nodisplay)
+ (file-notify-rm-watch desc)
+ (ignore-errors (delete-file file-notify--test-tmpfile))
+ (ignore-errors (delete-file file-notify--test-tmpfile1))))
- (dolist (result file-notify--test-results)
- ;(message "%s" (ert-test-result-messages result))
- (when (ert-test-failed-p result)
- (ert-fail (cadr (ert-test-result-with-condition-condition result))))))
+ (dolist (result file-notify--test-results)
+ ;(message "%s" (ert-test-result-messages result))
+ (when (ert-test-failed-p result)
+ (ert-fail (cadr (ert-test-result-with-condition-condition result))))))
-(file-notify--deftest-remote file-notify-test02-events
- "Check file creation/removal notifications for remote files.")
+ (file-notify--deftest-remote file-notify-test02-events
+ "Check file creation/removal notifications for remote files.")
+ ) ;; file-notify-support
;; autorevert runs only in interactive mode.
(defvar auto-revert-remote-files)
(setq auto-revert-remote-files t)
(require 'autorevert)
-(when (null noninteractive)
+(when (and file-notify-support (null noninteractive))
(ert-deftest file-notify-test03-autorevert ()
"Check autorevert via file notification.
@@ -240,7 +249,7 @@ This test is skipped in batch mode."
(file-notify--deftest-remote file-notify-test03-autorevert
"Check autorevert via file notification for remote files.
This test is skipped in batch mode.")
- ) ;; (null noninteractive)
+ ) ;; (and file-notify-support (null noninteractive))
(defun file-notify-test-all (&optional interactive)
"Run all tests for \\[file-notify]."