From: Michael Albinus Date: Wed, 24 Jul 2013 13:56:19 +0000 (+0200) Subject: * automated/file-notify-tests.el X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~1706 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e81dd54dc2ac22d2ea2e2c6e8c79497d074e2458;p=emacs.git * 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. --- diff --git a/test/ChangeLog b/test/ChangeLog index 0626d92b207..bffe85e6a7a 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,14 @@ +2013-07-24 Michael Albinus + + * 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 * 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 @@ 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))) + +(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'." @@ -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-"))))