summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2015-09-21 15:07:06 +0200
committerMichael Albinus <michael.albinus@gmx.de>2015-09-21 15:07:06 +0200
commit01b547529ba81f4f5a64f5017a2c3d6601d0bb95 (patch)
treec52e7ad2b66dca3d7a8f612516d0e738696713bf /test
parent127bafdc6dcbcf4b11bff7ec52960bd941613a1c (diff)
downloademacs-01b547529ba81f4f5a64f5017a2c3d6601d0bb95.tar.gz
Adapt tests and manual for w32notify
* doc/lispref/os.texi (File Notifications): w32notify does not send `attribute-changed' events. * test/automated/file-notify-tests.el (file-notify--test-with-events): Simplify parameters. Adapt all callees. (file-notify-test02-events): w32notify does not send `attribute-changed' events. (file-notify-test04-file-validity, file-notify-test05-dir-validity): Do not skip in case of w32notify. Simply ignore this part of the test.
Diffstat (limited to 'test')
-rw-r--r--test/automated/file-notify-tests.el161
1 files changed, 76 insertions, 85 deletions
diff --git a/test/automated/file-notify-tests.el b/test/automated/file-notify-tests.el
index 9d66f03ae0c..75e0c24a7e9 100644
--- a/test/automated/file-notify-tests.el
+++ b/test/automated/file-notify-tests.el
@@ -245,17 +245,17 @@ TIMEOUT is the maximum time to wait for, in seconds."
(while (null ,until)
(read-event nil nil 0.1))))
-(defmacro file-notify--test-with-events (n timeout assert-fn &rest body)
- "Run BODY collecting N events and then run ASSERT-FN.
+(defmacro file-notify--test-with-events (timeout events &rest body)
+ "Run BODY collecting events and then compare with EVENTS.
Don't wait longer than TIMEOUT seconds for the events to be delivered."
- (declare (indent 3))
+ (declare (indent 2))
(let ((outer (make-symbol "outer")))
`(let ((,outer file-notify--test-events))
(let (file-notify--test-events)
,@body
(file-notify--wait-for-events
- ,timeout (= ,n (length file-notify--test-events)))
- (funcall ,assert-fn file-notify--test-events)
+ ,timeout (= (length ,events) (length file-notify--test-events)))
+ (should (equal ,events (mapcar #'cadr file-notify--test-events)))
(setq ,outer (append ,outer file-notify--test-events)))
(setq file-notify--test-events ,outer))))
@@ -274,67 +274,65 @@ Don't wait longer than TIMEOUT seconds for the events to be delivered."
;; Check creation, change, and deletion.
(file-notify--test-with-events
- 3 (file-notify--test-timeout)
- (lambda (events)
- (should (equal '(created changed deleted)
- (mapcar #'cadr events))))
+ (file-notify--test-timeout) '(created changed deleted)
(write-region
"any text" nil file-notify--test-tmpfile nil 'no-message)
(delete-file file-notify--test-tmpfile))
;; Check copy.
(file-notify--test-with-events
- 3 (file-notify--test-timeout)
- (lambda (events)
- (should (equal '(created changed deleted)
- (mapcar #'cadr events))))
+ (file-notify--test-timeout)
+ ;; w32notify does not distinguish between `changed' and
+ ;; `attribute-changed'.
+ (if (eq file-notify--library 'w32notify)
+ '(created changed changed changed deleted)
+ '(created changed deleted))
(write-region
"any text" nil file-notify--test-tmpfile nil 'no-message)
(copy-file file-notify--test-tmpfile file-notify--test-tmpfile1)
;; The next two events shall not be visible.
(set-file-modes file-notify--test-tmpfile 000)
+ (read-event nil nil 0.1) ; In order to distinguish the events.
(set-file-times file-notify--test-tmpfile '(0 0))
(delete-file file-notify--test-tmpfile)
(delete-file file-notify--test-tmpfile1))
;; Check rename.
(file-notify--test-with-events
- 3 (file-notify--test-timeout)
- (lambda (events)
- (should (equal '(created changed renamed)
- (mapcar #'cadr events))))
+ (file-notify--test-timeout) '(created changed renamed)
(write-region
"any text" nil file-notify--test-tmpfile nil 'no-message)
(rename-file file-notify--test-tmpfile file-notify--test-tmpfile1)
;; After the rename, we won't get events anymore.
(delete-file file-notify--test-tmpfile1))
- ;; Check attribute change.
- (file-notify-rm-watch file-notify--test-desc)
- (setq file-notify--test-desc
- (file-notify-add-watch
- file-notify--test-tmpfile
- '(attribute-change) 'file-notify--test-event-handler))
- (file-notify--test-with-events
- 2 (file-notify--test-timeout)
- (lambda (events)
- (should (equal '(attribute-changed attribute-changed)
- (mapcar #'cadr events))))
- (write-region
- "any text" nil file-notify--test-tmpfile nil 'no-message)
- (set-file-modes file-notify--test-tmpfile 000)
- (read-event nil nil 0.1) ; In order to distinguish the events.
- (set-file-times file-notify--test-tmpfile '(0 0))
- (delete-file file-notify--test-tmpfile))
+ ;; Check attribute change. It doesn't work for w32notify.
+ (unless (eq file-notify--library 'w32notify)
+ (file-notify-rm-watch file-notify--test-desc)
+ (setq file-notify--test-desc
+ (file-notify-add-watch
+ file-notify--test-tmpfile
+ '(attribute-change) 'file-notify--test-event-handler))
+ (file-notify--test-with-events
+ (file-notify--test-timeout) '(attribute-changed attribute-changed)
+ (write-region
+ "any text" nil file-notify--test-tmpfile nil 'no-message)
+ (set-file-modes file-notify--test-tmpfile 000)
+ (read-event nil nil 0.1) ; In order to distinguish the events.
+ (set-file-times file-notify--test-tmpfile '(0 0))
+ (delete-file file-notify--test-tmpfile)))
;; Check the global sequence again just to make sure that
;; `file-notify--test-events' has been set correctly.
(should (equal (mapcar #'cadr file-notify--test-events)
- '(created changed deleted
- created changed deleted
- created changed renamed
- attribute-changed attribute-changed)))
-
+ (if (eq file-notify--library 'w32notify)
+ '(created changed deleted
+ created changed changed changed deleted
+ created changed renamed)
+ '(created changed deleted
+ created changed deleted
+ created changed renamed
+ attribute-changed attribute-changed))))
(should file-notify--test-results)
(dolist (result file-notify--test-results)
;;(message "%s" (ert-test-result-messages result))
@@ -414,15 +412,12 @@ Don't wait longer than TIMEOUT seconds for the events to be delivered."
(unwind-protect
(progn
(setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
- (setq file-notify--test-desc (file-notify-add-watch
- file-notify--test-tmpfile
- '(change)
- #'file-notify--test-event-handler))
+ (setq file-notify--test-desc
+ (file-notify-add-watch
+ file-notify--test-tmpfile
+ '(change) #'file-notify--test-event-handler))
(file-notify--test-with-events
- 2 (file-notify--test-timeout)
- (lambda (events)
- (should (equal '(created changed)
- (mapcar #'cadr events))))
+ (file-notify--test-timeout) '(created changed)
(should (file-notify-valid-p file-notify--test-desc))
(write-region
"any text" nil file-notify--test-tmpfile nil 'no-message)
@@ -435,33 +430,30 @@ Don't wait longer than TIMEOUT seconds for the events to be delivered."
;; Cleanup.
(file-notify--test-cleanup))
- ;; The batch-mode operation of w32notify is fragile (there's no
- ;; input threads to send the message to).
- (skip-unless (not (and noninteractive (eq file-notify--library 'w32notify))))
(unwind-protect
- (let ((temporary-file-directory (make-temp-file
- "file-notify-test-parent" t)))
- (setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
- (setq file-notify--test-desc (file-notify-add-watch
- file-notify--test-tmpfile
- '(change)
- #'file-notify--test-event-handler))
- (file-notify--test-with-events
- 2 (file-notify--test-timeout)
- (lambda (events)
- (should (equal '(created changed)
- (mapcar #'cadr events))))
- (should (file-notify-valid-p file-notify--test-desc))
- (write-region
- "any text" nil file-notify--test-tmpfile nil 'no-message)
- (should (file-notify-valid-p file-notify--test-desc)))
- ;; After deleting the parent, the descriptor must not be valid
- ;; anymore.
- (delete-directory temporary-file-directory t)
- (file-notify--wait-for-events
- (file-notify--test-timeout)
- (not (file-notify-valid-p file-notify--test-desc)))
- (should-not (file-notify-valid-p file-notify--test-desc)))
+ ;; The batch-mode operation of w32notify is fragile (there's no
+ ;; input threads to send the message to).
+ (unless (and noninteractive (eq file-notify--library 'w32notify))
+ (let ((temporary-file-directory (make-temp-file
+ "file-notify-test-parent" t)))
+ (setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
+ (setq file-notify--test-desc
+ (file-notify-add-watch
+ file-notify--test-tmpfile
+ '(change) #'file-notify--test-event-handler))
+ (file-notify--test-with-events
+ (file-notify--test-timeout) '(created changed)
+ (should (file-notify-valid-p file-notify--test-desc))
+ (write-region
+ "any text" nil file-notify--test-tmpfile nil 'no-message)
+ (should (file-notify-valid-p file-notify--test-desc)))
+ ;; After deleting the parent, the descriptor must not be valid
+ ;; anymore.
+ (delete-directory temporary-file-directory t)
+ (file-notify--wait-for-events
+ (file-notify--test-timeout)
+ (not (file-notify-valid-p file-notify--test-desc)))
+ (should-not (file-notify-valid-p file-notify--test-desc))))
;; Cleanup.
(file-notify--test-cleanup)))
@@ -478,10 +470,10 @@ Don't wait longer than TIMEOUT seconds for the events to be delivered."
(setq file-notify--test-tmpfile (file-name-as-directory
(file-notify--test-make-temp-name)))
(make-directory file-notify--test-tmpfile)
- (setq file-notify--test-desc (file-notify-add-watch
- file-notify--test-tmpfile
- '(change)
- #'file-notify--test-event-handler))
+ (setq file-notify--test-desc
+ (file-notify-add-watch
+ file-notify--test-tmpfile
+ '(change) #'file-notify--test-event-handler))
(should (file-notify-valid-p file-notify--test-desc))
;; After removing the watch, the descriptor must not be valid
;; anymore.
@@ -491,18 +483,17 @@ Don't wait longer than TIMEOUT seconds for the events to be delivered."
;; Cleanup.
(file-notify--test-cleanup))
- ;; The batch-mode operation of w32notify is fragile (there's no
- ;; input threads to send the message to).
- (skip-unless (not (and noninteractive (eq file-notify--library 'w32notify))))
(unwind-protect
- (progn
+ ;; The batch-mode operation of w32notify is fragile (there's no
+ ;; input threads to send the message to).
+ (unless (and noninteractive (eq file-notify--library 'w32notify))
(setq file-notify--test-tmpfile (file-name-as-directory
(file-notify--test-make-temp-name)))
(make-directory file-notify--test-tmpfile)
- (setq file-notify--test-desc (file-notify-add-watch
- file-notify--test-tmpfile
- '(change)
- #'file-notify--test-event-handler))
+ (setq file-notify--test-desc
+ (file-notify-add-watch
+ file-notify--test-tmpfile
+ '(change) #'file-notify--test-event-handler))
(should (file-notify-valid-p file-notify--test-desc))
;; After deleting the directory, the descriptor must not be
;; valid anymore.