tramp-message-show-message nil)
(when noninteractive (defalias 'tramp-read-passwd 'ignore))
+;; We do not want to try and fail `file-notify-add-watch'.
+(defconst file-notify--test-local-enabled file-notify--library
+ "Whether local file notification is enabled.")
+
+;; We need also a check on the remote side, w/o adding a file monitor.
+(defun file-notify--test-remote-enabled ()
+ "Whether remote file notification is enabled."
+ (ignore-errors
+ (and (file-remote-p file-notify-test-remote-temporary-file-directory)
+ (file-directory-p file-notify-test-remote-temporary-file-directory)
+ (file-writable-p file-notify-test-remote-temporary-file-directory))))
+
(defmacro file-notify--deftest-remote (test docstring)
"Define ert `TEST-remote' for remote files."
- `(when (ignore-errors
- (and
- (file-remote-p file-notify-test-remote-temporary-file-directory)
- (file-directory-p file-notify-test-remote-temporary-file-directory)
- (file-writable-p file-notify-test-remote-temporary-file-directory)))
+ `(when (and (file-notify--test-remote-enabled) (ert-get-test ',test))
;; Define the test.
(ert-deftest ,(intern (concat (symbol-name test) "-remote")) ()
,docstring
(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))))
+ (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)))
+
+(file-notify--deftest-remote file-notify-test00-availability
+ "Test availability of `file-notify' for remote files.")
-(when file-notify-support
+(when file-notify--test-local-enabled
(ert-deftest file-notify-test01-add-watch ()
"Check `file-notify-add-watch'."
(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-error (file-notify-add-watch 1 2 3 4)
+ :type 'wrong-number-of-arguments)
(should
(equal (should-error (file-notify-add-watch 1 2 3))
'(wrong-type-argument 1)))
(file-notify--deftest-remote file-notify-test01-add-watch
"Check `file-notify-add-watch' for remote files.")
- ) ;; file-notify-support
+ ) ;; file-notify--test-local-enabled
(defun file-notify--test-event-test ()
"Ert test function to be called by `file-notify--test-event-handler'.
(expand-file-name
(make-temp-name "file-notify-test") temporary-file-directory))
-(when file-notify-support
+(when file-notify--test-local-enabled
(ert-deftest file-notify-test02-events ()
"Check file creation/removal notifications."
(file-notify--deftest-remote file-notify-test02-events
"Check file creation/removal notifications for remote files.")
- ) ;; file-notify-support
+ ) ;; file-notify--test-local-enabled
;; autorevert runs only in interactive mode.
(defvar auto-revert-remote-files)
(setq auto-revert-remote-files t)
(require 'autorevert)
-(when (and file-notify-support (null noninteractive))
+(when (and file-notify--test-local-enabled (null noninteractive))
(ert-deftest file-notify-test03-autorevert ()
"Check autorevert via file notification.
(file-notify--deftest-remote file-notify-test03-autorevert
"Check autorevert via file notification for remote files.
This test is skipped in batch mode.")
- ) ;; (and file-notify-support (null noninteractive))
+ ) ;; (and file-notify--test-local-enabled (null noninteractive))
(defun file-notify-test-all (&optional interactive)
"Run all tests for \\[file-notify]."
(interactive "p")
- (when file-notify-support
+ (when file-notify--test-local-enabled
(if interactive
(ert-run-tests-interactively "^file-notify-")
(ert-run-tests-batch "^file-notify-"))))