(defvar file-notify--test-tmpfile1 nil)
(defvar file-notify--test-desc nil)
(defvar file-notify--test-desc1 nil)
+(defvar file-notify--test-desc2 nil)
(defvar file-notify--test-results nil)
(defvar file-notify--test-event nil)
(defvar file-notify--test-events nil)
"Cleanup after a test."
(file-notify-rm-watch file-notify--test-desc)
(file-notify-rm-watch file-notify--test-desc1)
+ (file-notify-rm-watch file-notify--test-desc2)
(ignore-errors
(delete-file (file-newest-backup file-notify--test-tmpfile)))
file-notify--test-tmpfile1 nil
file-notify--test-desc nil
file-notify--test-desc1 nil
+ file-notify--test-desc2 nil
file-notify--test-results nil
file-notify--test-events nil)
(when file-notify--test-event
(unless (string-match
(regexp-quote ".#")
(file-notify--event-file-name file-notify--test-event))
- ;;(message "file-notify--test-event-handler %S" file-notify--test-event)
+ (message "file-notify--test-event-handler %S" file-notify--test-event)
(setq file-notify--test-events
(append file-notify--test-events `(,file-notify--test-event))
file-notify--test-results
(let (file-notify--test-events)
(file-notify-rm-watch file-notify--test-desc)))
- ;; Check the global sequence again just to make sure that
- ;; `file-notify--test-events' has been set correctly.
+ ;; Check the global sequence just to make sure that all
+ ;; results are as expected.
(should file-notify--test-results)
(dolist (result file-notify--test-results)
(when (ert-test-failed-p result)
test caters for the situation in bug#22736 where the callback for
the directory received events for the file with the descriptor of
the file watch."
+ :tags '(:expensive-test)
(skip-unless (file-notify--test-local-enabled))
(unwind-protect
(setq file-notify--test-tmpfile1
(let ((temporary-file-directory file-notify--test-tmpfile))
(make-temp-file "file")))
- (cl-flet ((dir-callback
- (ev)
- (should (equal file-notify--test-desc (car ev))))
- (file-callback
- (ev)
- (should (equal file-notify--test-desc1 (car ev)))))
+ (cl-flet ((dir-callback (event)
+ (message "dir-callback %s" event)
+ (let ((file-notify--test-desc file-notify--test-desc1))
+ (file-notify--test-event-handler event)))
+ (file-callback (event)
+ (message "file-callback %s" event)
+ (let ((file-notify--test-desc file-notify--test-desc2))
+ (file-notify--test-event-handler event))))
(should
- (setq file-notify--test-desc
+ (setq file-notify--test-desc1
(file-notify-add-watch
file-notify--test-tmpfile
'(change attribute-change) #'dir-callback)))
(should
- (setq file-notify--test-desc1
+ (setq file-notify--test-desc2
(file-notify-add-watch
file-notify--test-tmpfile1
'(change attribute-change) #'file-callback)))
- (should (file-notify-valid-p file-notify--test-desc))
(should (file-notify-valid-p file-notify--test-desc1))
+ (should (file-notify-valid-p file-notify--test-desc2))
(dotimes (i 100)
+ (read-event nil nil file-notify--test-read-event-timeout)
(if (< 0 (random))
(write-region
"any text" nil file-notify--test-tmpfile1 t 'no-message)
(let ((temporary-file-directory file-notify--test-tmpfile))
- (make-temp-file "fileX")))))
- ;; After saving the buffer, the descriptor is still valid.
- (should (file-notify-valid-p file-notify--test-desc))
- (should (file-notify-valid-p file-notify--test-desc1))
- (delete-file file-notify--test-tmpfile1)
- (delete-directory file-notify--test-tmpfile))
+ (make-temp-file "fileX"))))
+ ;; After saving the buffer, the descriptor is still valid.
+ (should (file-notify-valid-p file-notify--test-desc1))
+ (should (file-notify-valid-p file-notify--test-desc2))
+ (delete-file file-notify--test-tmpfile1)
+ (delete-directory file-notify--test-tmpfile 'recursive))
+
+ ;; Check the global sequence just to make sure that all
+ ;; results are as expected.
+ (should file-notify--test-results)
+ (dolist (result file-notify--test-results)
+ (when (ert-test-failed-p result)
+ (ert-fail
+ (cadr (ert-test-result-with-condition-condition result))))))
;; Cleanup.
(file-notify--test-cleanup)))
(file-notify--deftest-remote file-notify-test08-watched-file-in-watched-dir
- "Checks what `file-notify-test08-watched-file-in-watched-dir'
-checks, just for a remote directory and file.")
+ "Check `file-notify-test08-watched-file-in-watched-dir' for remote files.")
(defun file-notify-test-all (&optional interactive)
"Run all tests for \\[file-notify]."