* automated/file-notify-tests.el

(file-notify--test-local-enabled): New defconst.  Replaces all
`file-notify-support' occurences.
(file-notify--test-remote-enabled): New defun.
(file-notify--deftest-remote): Use it.
(file-notify-test00-availability): Rewrite.
(file-notify-test00-availability-remote): New defun.
(file-notify-test01-add-watch): Rewrite first erroneous check.
This commit is contained in:
Michael Albinus 2013-07-24 15:56:19 +02:00
parent d5d3c58aac
commit e81dd54dc2
2 changed files with 41 additions and 17 deletions

View file

@ -1,3 +1,14 @@
2013-07-24 Michael Albinus <michael.albinus@gmx.de>
* automated/file-notify-tests.el
(file-notify--test-local-enabled): New defconst. Replaces all
`file-notify-support' occurences.
(file-notify--test-remote-enabled): New defun.
(file-notify--deftest-remote): Use it.
(file-notify-test00-availability): Rewrite.
(file-notify-test00-availability-remote): New defun.
(file-notify-test01-add-watch): Rewrite first erroneous check.
2013-07-23 Glenn Morris <rgm@gnu.org>
* automated/inotify-test.el (inotify-file-watch-simple):

View file

@ -47,13 +47,21 @@
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
@ -77,10 +85,16 @@
(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)))
(when file-notify-support
(file-notify--deftest-remote file-notify-test00-availability
"Test availability of `file-notify' for remote files.")
(when file-notify--test-local-enabled
(ert-deftest file-notify-test01-add-watch ()
"Check `file-notify-add-watch'."
@ -99,9 +113,8 @@
(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)))
@ -116,7 +129,7 @@
(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'.
@ -147,7 +160,7 @@ Save the result in `file-notify--test-results', for later analysis."
(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."
@ -189,13 +202,13 @@ Save the result in `file-notify--test-results', for later analysis."
(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.
@ -249,12 +262,12 @@ 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.")
) ;; (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-"))))