* automated/file-notify-tests.el (file-notify-test00-availability):

Set :expected-result.
(file-notify-test01-add-watch, file-notify-test01-add-watch-remote)
(file-notify-test02-events, file-notify-test02-events-remote)
(file-notify-test03-autorevert, file-notify-test03-autorevert-remote):
Skip when `file-notify-support' is nil.  (Bug#14823)
This commit is contained in:
Michael Albinus 2013-07-09 09:52:25 +02:00
parent 0b57d6fc8e
commit 59eb37e5f5
2 changed files with 84 additions and 66 deletions

View file

@ -1,3 +1,12 @@
2013-07-09 Michael Albinus <michael.albinus@gmx.de>
* automated/file-notify-tests.el (file-notify-test00-availability):
Set :expected-result.
(file-notify-test01-add-watch, file-notify-test01-add-watch-remote)
(file-notify-test02-events, file-notify-test02-events-remote)
(file-notify-test03-autorevert, file-notify-test03-autorevert-remote):
Skip when `file-notify-support' is nil. (Bug#14823)
2013-07-09 Glenn Morris <rgm@gnu.org>
* automated/inotify-test.el (inotify-add-watch, inotify-rm-watch):

View file

@ -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)
(when file-notify-support
;; 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)))))
(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)
(file-notify--deftest-remote file-notify-test01-add-watch
"Check `file-notify-add-watch' for remote files.")
;; 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))
(when file-notify-support
;; Check creation and removal.
(write-region "any text" nil file-notify--test-tmpfile)
(delete-file file-notify--test-tmpfile)
(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 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)
;; Check creation and removal.
(write-region "any text" nil file-notify--test-tmpfile)
(delete-file file-notify--test-tmpfile)
(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))
;; 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)
;; 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))))
(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))
(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))))))
;; 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))))
(file-notify--deftest-remote file-notify-test02-events
"Check file creation/removal notifications for remote files.")
(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-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]."