(format "/mock::%s" temporary-file-directory)))
"Temporary directory for Tramp tests.")
+(defvar file-notify--test-tmpdir nil)
(defvar file-notify--test-tmpfile nil)
(defvar file-notify--test-tmpfile1 nil)
(defvar file-notify--test-desc nil)
(if (file-directory-p file-notify--test-tmpfile1)
(delete-directory file-notify--test-tmpfile1 'recursive)
(delete-file file-notify--test-tmpfile1)))
+ (ignore-errors
+ (delete-directory file-notify--test-tmpdir 'recursive))
(ignore-errors
(when (file-remote-p temporary-file-directory)
(tramp-cleanup-connection
(when (hash-table-p file-notify-descriptors)
(clrhash file-notify-descriptors))
- (setq file-notify--test-tmpfile nil
+ (setq file-notify--test-tmpdir nil
+ file-notify--test-tmpfile nil
file-notify--test-tmpfile1 nil
file-notify--test-desc nil
file-notify--test-desc1 nil
(file-notify--deftest-remote file-notify-test00-availability
"Test availability of `file-notify' for remote files.")
+(defun file-notify--test-make-temp-name ()
+ "Create a temporary file name for test."
+ (unless (stringp file-notify--test-tmpdir)
+ (setq file-notify--test-tmpdir
+ (expand-file-name
+ (make-temp-name "file-notify-test") temporary-file-directory)))
+ (unless (file-directory-p file-notify--test-tmpdir)
+ (make-directory file-notify--test-tmpdir))
+ (expand-file-name
+ (make-temp-name "file-notify-test") file-notify--test-tmpdir))
+
(ert-deftest file-notify-test01-add-watch ()
"Check `file-notify-add-watch'."
(skip-unless (file-notify--test-local-enabled))
(should
(setq file-notify--test-desc
(file-notify-add-watch
- temporary-file-directory '(change) #'ignore)))
+ file-notify--test-tmpdir '(change) #'ignore)))
(file-notify-rm-watch file-notify--test-desc)
(should
(setq file-notify--test-desc
(file-notify-add-watch
- temporary-file-directory '(attribute-change) #'ignore)))
+ file-notify--test-tmpdir '(attribute-change) #'ignore)))
(file-notify-rm-watch file-notify--test-desc)
(should
(setq file-notify--test-desc
(file-notify-add-watch
- temporary-file-directory '(change attribute-change) #'ignore)))
+ file-notify--test-tmpdir '(change attribute-change) #'ignore)))
(file-notify-rm-watch file-notify--test-desc)
;; File monitors like kqueue insist, that the watched file
'(wrong-type-argument 1)))
(should
(equal (should-error
- (file-notify-add-watch temporary-file-directory 2 3))
+ (file-notify-add-watch file-notify--test-tmpdir 2 3))
'(wrong-type-argument 2)))
(should
(equal (should-error
- (file-notify-add-watch temporary-file-directory '(change) 3))
+ (file-notify-add-watch file-notify--test-tmpdir '(change) 3))
'(wrong-type-argument 3)))
;; The upper directory of a file must exist.
(should
(file-notify--deftest-remote file-notify-test01-add-watch
"Check `file-notify-add-watch' for remote files.")
-(defun file-notify--test-make-temp-name ()
- "Create a temporary file name for test."
- (expand-file-name
- (make-temp-name "file-notify-test") temporary-file-directory))
-
;; This test is inspired by Bug#26126 and Bug#26127.
(ert-deftest file-notify-test02-rm-watch ()
"Check `file-notify-rm-watch'."
;; Check file creation, change and deletion when watching a
;; directory. There must be a `stopped' event when deleting
;; the directory.
- (let ((temporary-file-directory
+ (let ((file-notify--test-tmpdir
(make-temp-file "file-notify-test-parent" t)))
(should
(setq file-notify--test-tmpfile (file-notify--test-make-temp-name)
file-notify--test-desc
(file-notify-add-watch
- temporary-file-directory
+ file-notify--test-tmpdir
'(change) #'file-notify--test-event-handler)))
(file-notify--test-with-events
(cond
(write-region
"any text" nil file-notify--test-tmpfile nil 'no-message)
(file-notify--test-read-event)
- (delete-directory temporary-file-directory 'recursive))
+ (delete-directory file-notify--test-tmpdir 'recursive))
(file-notify-rm-watch file-notify--test-desc))
;; Check copy of files inside a directory.
- (let ((temporary-file-directory
+ (let ((file-notify--test-tmpdir
(make-temp-file "file-notify-test-parent" t)))
(should
(setq file-notify--test-tmpfile (file-notify--test-make-temp-name)
file-notify--test-tmpfile1 (file-notify--test-make-temp-name)
file-notify--test-desc
(file-notify-add-watch
- temporary-file-directory
+ file-notify--test-tmpdir
'(change) #'file-notify--test-event-handler)))
(file-notify--test-with-events
(cond
(file-notify--test-read-event)
(set-file-times file-notify--test-tmpfile '(0 0))
(file-notify--test-read-event)
- (delete-directory temporary-file-directory 'recursive))
+ (delete-directory file-notify--test-tmpdir 'recursive))
(file-notify-rm-watch file-notify--test-desc))
;; Check rename of files inside a directory.
- (let ((temporary-file-directory
+ (let ((file-notify--test-tmpdir
(make-temp-file "file-notify-test-parent" t)))
(should
(setq file-notify--test-tmpfile (file-notify--test-make-temp-name)
file-notify--test-tmpfile1 (file-notify--test-make-temp-name)
file-notify--test-desc
(file-notify-add-watch
- temporary-file-directory
+ file-notify--test-tmpdir
'(change) #'file-notify--test-event-handler)))
(file-notify--test-with-events
(cond
(rename-file file-notify--test-tmpfile file-notify--test-tmpfile1)
;; After the rename, we won't get events anymore.
(file-notify--test-read-event)
- (delete-directory temporary-file-directory 'recursive))
+ (delete-directory file-notify--test-tmpdir 'recursive))
(file-notify-rm-watch file-notify--test-desc))
;; Check attribute change. Does not work for cygwin.
(file-notify--test-cleanup))
(unwind-protect
- (let ((temporary-file-directory
+ (let ((file-notify--test-tmpdir
(make-temp-file "file-notify-test-parent" t)))
(should
(setq file-notify--test-tmpfile (file-notify--test-make-temp-name)
file-notify--test-desc
(file-notify-add-watch
- temporary-file-directory
+ file-notify--test-tmpdir
'(change) #'file-notify--test-event-handler)))
(should (file-notify-valid-p file-notify--test-desc))
(file-notify--test-with-events
(write-region
"any text" nil file-notify--test-tmpfile nil 'no-message)
(file-notify--test-read-event)
- (delete-directory temporary-file-directory t))
+ (delete-directory file-notify--test-tmpdir 'recursive))
;; After deleting the parent directory, the descriptor must
;; not be valid anymore.
(should-not (file-notify-valid-p file-notify--test-desc))
;; A file to be watched.
(should
(setq file-notify--test-tmpfile1
- (let ((temporary-file-directory file-notify--test-tmpfile))
+ (let ((file-notify--test-tmpdir file-notify--test-tmpfile))
(file-notify--test-make-temp-name))))
(write-region "any text" nil file-notify--test-tmpfile1 nil 'no-message)
(unwind-protect
(if (zerop (mod i 2))
(write-region
"any text" nil file-notify--test-tmpfile1 t 'no-message)
- (let ((temporary-file-directory file-notify--test-tmpfile))
+ (let ((file-notify--test-tmpdir file-notify--test-tmpfile))
(write-region
"any text" nil
(file-notify--test-make-temp-name) nil 'no-message))))))
(setq file-notify--test-tmpfile
(make-temp-file "file-notify-test-parent" t)))
(unwind-protect
- (let ((temporary-file-directory file-notify--test-tmpfile)
+ (let ((file-notify--test-tmpdir file-notify--test-tmpfile)
descs)
(should-error
(while t