aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2019-05-03 17:18:13 +0200
committerMichael Albinus2019-05-03 17:18:13 +0200
commitd0fe28cb1d33daa059990d62556a8de20a385387 (patch)
treeae2dab44a36a6497d034d4a4dc4e08411bcbd9c9
parent24a1d5a0b5c0debd8256d71242bfa6f8448bf5af (diff)
downloademacs-d0fe28cb1d33daa059990d62556a8de20a385387.tar.gz
emacs-d0fe28cb1d33daa059990d62556a8de20a385387.zip
Add tests for remote files in auto-revert-tests
* lisp/autorevert.el (auto-revert-debug): New defvar. (auto-revert-notify-handler): Write traces. * lisp/filenotify.el (file-notify-debug): New defvar. (file-notify-handle-event, file-notify-callback): Write traces. * lisp/net/tramp-sh.el (tramp-sh-handle-vc-registered): Handle nil `vc-handled-backends'. * test/lisp/autorevert-tests.el (auto-revert-test-remote-temporary-file-directory): New defconst. Handle also $REMOTE_FILE_NOTIFY_LIBRARY. (auto-revert--test-enabled-remote-checked): New defvar. (auto-revert--test-enabled-remote): New defun. (auto-revert--wait-for-revert): Rewrite without timeout. (auto-revert--deftest-remote): New defmacro. (auto-revert-test01-auto-revert-several-files): (auto-revert-test02-auto-revert-deleted-file): Adapt for remote files. (auto-revert-test02-auto-revert-deleted-file): Use `auto-revert-debug' for debug messages. (auto-revert-test00-auto-revert-mode-remote) (auto-revert-test01-auto-revert-several-files-mode-remote) (auto-revert-test02-auto-revert-deleted-file-mode-remote) (auto-revert-test03-auto-revert-tail-mode-mode-remote) (auto-revert-test04-auto-revert-mode-dired-mode-remote): New tests. * test/lisp/filenotify-tests.el (file-notify--test-event-handler): Use `file-notify-debug' for debug messages.
-rw-r--r--lisp/autorevert.el7
-rw-r--r--lisp/filenotify.el17
-rw-r--r--lisp/net/tramp-sh.el165
-rw-r--r--test/lisp/autorevert-tests.el145
-rw-r--r--test/lisp/filenotify-tests.el8
5 files changed, 237 insertions, 105 deletions
diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index cdd8223fffd..7cd5e7ee8bf 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -126,8 +126,6 @@ Global Auto-Revert Mode does so in all buffers."
126 126
127;; Variables: 127;; Variables:
128 128
129;;; What's this?: ;; Autoload for the benefit of `make-mode-line-mouse-sensitive'.
130;;; What's this?: ;;;###autoload
131(defvar auto-revert-mode nil 129(defvar auto-revert-mode nil
132 "Non-nil when Auto-Revert Mode is active. 130 "Non-nil when Auto-Revert Mode is active.
133Never set this variable directly, use the command `auto-revert-mode' instead.") 131Never set this variable directly, use the command `auto-revert-mode' instead.")
@@ -365,6 +363,9 @@ buffer.")
365 "Non-nil when file has been modified on the file system. 363 "Non-nil when file has been modified on the file system.
366This has been reported by a file notification event.") 364This has been reported by a file notification event.")
367 365
366(defvar auto-revert-debug nil
367 "Use for debug messages.")
368
368;; Functions: 369;; Functions:
369 370
370(defun auto-revert-remove-current-buffer (&optional buffer) 371(defun auto-revert-remove-current-buffer (&optional buffer)
@@ -634,6 +635,8 @@ system.")
634 ;; Since we watch a directory, a file name must be returned. 635 ;; Since we watch a directory, a file name must be returned.
635 (cl-assert (stringp file)) 636 (cl-assert (stringp file))
636 (when (eq action 'renamed) (cl-assert (stringp file1))) 637 (when (eq action 'renamed) (cl-assert (stringp file1)))
638 (when auto-revert-debug
639 (message "auto-revert-notify-handler %S" event))
637 640
638 (if (eq action 'stopped) 641 (if (eq action 'stopped)
639 ;; File notification has stopped. Continue with polling. 642 ;; File notification has stopped. Continue with polling.
diff --git a/lisp/filenotify.el b/lisp/filenotify.el
index 4d22061138f..a6054c175f1 100644
--- a/lisp/filenotify.el
+++ b/lisp/filenotify.el
@@ -30,6 +30,9 @@
30(require 'cl-lib) 30(require 'cl-lib)
31(eval-when-compile (require 'subr-x)) 31(eval-when-compile (require 'subr-x))
32 32
33(defvar file-notify-debug nil
34 "Use for debug messages.")
35
33(defconst file-notify--library 36(defconst file-notify--library
34 (cond 37 (cond
35 ((featurep 'inotify) 'inotify) 38 ((featurep 'inotify) 'inotify)
@@ -93,7 +96,8 @@ If EVENT is a filewatch event, call its callback. It has the format
93 96
94Otherwise, signal a `file-notify-error'." 97Otherwise, signal a `file-notify-error'."
95 (interactive "e") 98 (interactive "e")
96 ;;(message "file-notify-handle-event %S" event) 99 (when file-notify-debug
100 (message "file-notify-handle-event %S" event))
97 (if (and (consp event) 101 (if (and (consp event)
98 (eq (car event) 'file-notify) 102 (eq (car event) 'file-notify)
99 (>= (length event) 3)) 103 (>= (length event) 3))
@@ -242,11 +246,12 @@ EVENT is the cadr of the event in `file-notify-handle-event'
242 (string-equal 246 (string-equal
243 (file-notify--watch-filename watch) 247 (file-notify--watch-filename watch)
244 (file-name-nondirectory file1))))) 248 (file-name-nondirectory file1)))))
245 ;;(message 249 (when file-notify-debug
246 ;;"file-notify-callback %S %S %S %S %S %S %S" 250 (message
247 ;;desc action file file1 watch 251 "file-notify-callback %S %S %S %S %S %S %S"
248 ;;(file-notify--event-watched-file event) 252 desc action file file1 watch
249 ;;(file-notify--watch-directory watch)) 253 (file-notify--event-watched-file event)
254 (file-notify--watch-directory watch)))
250 (funcall (file-notify--watch-callback watch) 255 (funcall (file-notify--watch-callback watch)
251 (if file1 256 (if file1
252 `(,desc ,action ,file ,file1) 257 `(,desc ,action ,file ,file1)
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index dc64726e211..37ff14a5eb2 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -3444,88 +3444,89 @@ the result will be a local, non-Tramp, file name."
3444;; any other remote command. 3444;; any other remote command.
3445(defun tramp-sh-handle-vc-registered (file) 3445(defun tramp-sh-handle-vc-registered (file)
3446 "Like `vc-registered' for Tramp files." 3446 "Like `vc-registered' for Tramp files."
3447 (with-temp-message "" 3447 (when vc-handled-backends
3448 (with-parsed-tramp-file-name file nil 3448 (with-temp-message ""
3449 (with-tramp-progress-reporter 3449 (with-parsed-tramp-file-name file nil
3450 v 3 (format-message "Checking `vc-registered' for %s" file) 3450 (with-tramp-progress-reporter
3451 3451 v 3 (format-message "Checking `vc-registered' for %s" file)
3452 ;; There could be new files, created by the vc backend. We 3452
3453 ;; cannot reuse the old cache entries, therefore. In 3453 ;; There could be new files, created by the vc backend. We
3454 ;; `tramp-get-file-property', `remote-file-name-inhibit-cache' 3454 ;; cannot reuse the old cache entries, therefore. In
3455 ;; could also be a timestamp as `current-time' returns. This 3455 ;; `tramp-get-file-property', `remote-file-name-inhibit-cache'
3456 ;; means invalidate all cache entries with an older timestamp. 3456 ;; could also be a timestamp as `current-time' returns. This
3457 (let (tramp-vc-registered-file-names 3457 ;; means invalidate all cache entries with an older timestamp.
3458 (remote-file-name-inhibit-cache (current-time)) 3458 (let (tramp-vc-registered-file-names
3459 (file-name-handler-alist 3459 (remote-file-name-inhibit-cache (current-time))
3460 `((,tramp-file-name-regexp . tramp-vc-file-name-handler)))) 3460 (file-name-handler-alist
3461 3461 `((,tramp-file-name-regexp . tramp-vc-file-name-handler))))
3462 ;; Here we collect only file names, which need an operation. 3462
3463 (tramp-with-demoted-errors 3463 ;; Here we collect only file names, which need an operation.
3464 v "Error in 1st pass of `vc-registered': %s" 3464 (tramp-with-demoted-errors
3465 (tramp-run-real-handler #'vc-registered (list file))) 3465 v "Error in 1st pass of `vc-registered': %s"
3466 (tramp-message v 10 "\n%s" tramp-vc-registered-file-names) 3466 (tramp-run-real-handler #'vc-registered (list file)))
3467 3467 (tramp-message v 10 "\n%s" tramp-vc-registered-file-names)
3468 ;; Send just one command, in order to fill the cache. 3468
3469 (when tramp-vc-registered-file-names 3469 ;; Send just one command, in order to fill the cache.
3470 (tramp-maybe-send-script 3470 (when tramp-vc-registered-file-names
3471 v 3471 (tramp-maybe-send-script
3472 (format tramp-vc-registered-read-file-names 3472 v
3473 (tramp-get-file-exists-command v) 3473 (format tramp-vc-registered-read-file-names
3474 (format "%s -r" (tramp-get-test-command v))) 3474 (tramp-get-file-exists-command v)
3475 "tramp_vc_registered_read_file_names") 3475 (format "%s -r" (tramp-get-test-command v)))
3476 3476 "tramp_vc_registered_read_file_names")
3477 (dolist 3477
3478 (elt 3478 (dolist
3479 (ignore-errors 3479 (elt
3480 ;; We cannot use `tramp-send-command-and-read', 3480 (ignore-errors
3481 ;; because this does not cooperate well with 3481 ;; We cannot use `tramp-send-command-and-read',
3482 ;; heredoc documents. 3482 ;; because this does not cooperate well with
3483 (tramp-send-command 3483 ;; heredoc documents.
3484 v 3484 (tramp-send-command
3485 (format 3485 v
3486 "tramp_vc_registered_read_file_names <<'%s'\n%s\n%s\n" 3486 (format
3487 tramp-end-of-heredoc 3487 "tramp_vc_registered_read_file_names <<'%s'\n%s\n%s\n"
3488 (mapconcat #'tramp-shell-quote-argument 3488 tramp-end-of-heredoc
3489 tramp-vc-registered-file-names 3489 (mapconcat #'tramp-shell-quote-argument
3490 "\n") 3490 tramp-vc-registered-file-names
3491 tramp-end-of-heredoc)) 3491 "\n")
3492 (with-current-buffer (tramp-get-connection-buffer v) 3492 tramp-end-of-heredoc))
3493 ;; Read the expression. 3493 (with-current-buffer (tramp-get-connection-buffer v)
3494 (goto-char (point-min)) 3494 ;; Read the expression.
3495 (read (current-buffer))))) 3495 (goto-char (point-min))
3496 3496 (read (current-buffer)))))
3497 (tramp-set-file-property 3497
3498 v (car elt) (cadr elt) (cadr (cdr elt)))))) 3498 (tramp-set-file-property
3499 3499 v (car elt) (cadr elt) (cadr (cdr elt))))))
3500 ;; Second run. Now all `file-exists-p' or `file-readable-p' 3500
3501 ;; calls shall be answered from the file cache. We unset 3501 ;; Second run. Now all `file-exists-p' or `file-readable-p'
3502 ;; `process-file-side-effects' and `remote-file-name-inhibit-cache' 3502 ;; calls shall be answered from the file cache. We unset
3503 ;; in order to keep the cache. 3503 ;; `process-file-side-effects' and `remote-file-name-inhibit-cache'
3504 (let ((vc-handled-backends vc-handled-backends) 3504 ;; in order to keep the cache.
3505 remote-file-name-inhibit-cache process-file-side-effects) 3505 (let ((vc-handled-backends vc-handled-backends)
3506 ;; Reduce `vc-handled-backends' in order to minimize process calls. 3506 remote-file-name-inhibit-cache process-file-side-effects)
3507 (when (and (memq 'Bzr vc-handled-backends) 3507 ;; Reduce `vc-handled-backends' in order to minimize process calls.
3508 (boundp 'vc-bzr-program) 3508 (when (and (memq 'Bzr vc-handled-backends)
3509 (not (with-tramp-connection-property v vc-bzr-program 3509 (boundp 'vc-bzr-program)
3510 (tramp-find-executable 3510 (not (with-tramp-connection-property v vc-bzr-program
3511 v vc-bzr-program (tramp-get-remote-path v))))) 3511 (tramp-find-executable
3512 (setq vc-handled-backends (remq 'Bzr vc-handled-backends))) 3512 v vc-bzr-program (tramp-get-remote-path v)))))
3513 (when (and (memq 'Git vc-handled-backends) 3513 (setq vc-handled-backends (remq 'Bzr vc-handled-backends)))
3514 (boundp 'vc-git-program) 3514 (when (and (memq 'Git vc-handled-backends)
3515 (not (with-tramp-connection-property v vc-git-program 3515 (boundp 'vc-git-program)
3516 (tramp-find-executable 3516 (not (with-tramp-connection-property v vc-git-program
3517 v vc-git-program (tramp-get-remote-path v))))) 3517 (tramp-find-executable
3518 (setq vc-handled-backends (remq 'Git vc-handled-backends))) 3518 v vc-git-program (tramp-get-remote-path v)))))
3519 (when (and (memq 'Hg vc-handled-backends) 3519 (setq vc-handled-backends (remq 'Git vc-handled-backends)))
3520 (boundp 'vc-hg-program) 3520 (when (and (memq 'Hg vc-handled-backends)
3521 (not (with-tramp-connection-property v vc-hg-program 3521 (boundp 'vc-hg-program)
3522 (tramp-find-executable 3522 (not (with-tramp-connection-property v vc-hg-program
3523 v vc-hg-program (tramp-get-remote-path v))))) 3523 (tramp-find-executable
3524 (setq vc-handled-backends (remq 'Hg vc-handled-backends))) 3524 v vc-hg-program (tramp-get-remote-path v)))))
3525 ;; Run. 3525 (setq vc-handled-backends (remq 'Hg vc-handled-backends)))
3526 (tramp-with-demoted-errors 3526 ;; Run.
3527 v "Error in 2nd pass of `vc-registered': %s" 3527 (tramp-with-demoted-errors
3528 (tramp-run-real-handler #'vc-registered (list file)))))))) 3528 v "Error in 2nd pass of `vc-registered': %s"
3529 (tramp-run-real-handler #'vc-registered (list file)))))))))
3529 3530
3530;;;###tramp-autoload 3531;;;###tramp-autoload
3531(defun tramp-sh-file-name-handler (operation &rest args) 3532(defun tramp-sh-file-name-handler (operation &rest args)
diff --git a/test/lisp/autorevert-tests.el b/test/lisp/autorevert-tests.el
index 6e8219d238d..d98c11658fe 100644
--- a/test/lisp/autorevert-tests.el
+++ b/test/lisp/autorevert-tests.el
@@ -19,6 +19,33 @@
19 19
20;;; Commentary: 20;;; Commentary:
21 21
22;; Some of the tests require access to a remote host files. Since
23;; this could be problematic, a mock-up connection method "mock" is
24;; used. Emulating a remote connection, it simply calls "sh -i".
25;; Tramp's file name handlers still run, so this test is sufficient
26;; except for connection establishing.
27
28;; If you want to test a real Tramp connection, set
29;; $REMOTE_TEMPORARY_FILE_DIRECTORY to a suitable value in order to
30;; overwrite the default value. If you want to skip tests accessing a
31;; remote host, set this environment variable to "/dev/null" or
32;; whatever is appropriate on your system.
33
34;; For the remote file-notify library, Tramp checks for the existence
35;; of a respective command. The first command found is used. In
36;; order to use a dedicated one, the environment variable
37;; $REMOTE_FILE_NOTIFY_LIBRARY shall be set, possible values are
38;; "inotifywait", "gio-monitor" and "gvfs-monitor-dir".
39
40;; Local file-notify libraries are auto-detected during Emacs
41;; configuration. This can be changed with a respective configuration
42;; argument, like
43;;
44;; --with-file-notification=inotify
45;; --with-file-notification=kqueue
46;; --with-file-notification=gfile
47;; --with-file-notification=w32
48
22;; A whole test run can be performed calling the command `auto-revert-test-all'. 49;; A whole test run can be performed calling the command `auto-revert-test-all'.
23 50
24;;; Code: 51;;; Code:
@@ -26,8 +53,14 @@
26(require 'ert) 53(require 'ert)
27(require 'ert-x) 54(require 'ert-x)
28(require 'autorevert) 55(require 'autorevert)
29(setq auto-revert-notify-exclude-dir-regexp "nothing-to-be-excluded" 56(require 'tramp)
30 auto-revert-stop-on-user-input nil) 57
58(setq auto-revert-debug nil
59 auto-revert-notify-exclude-dir-regexp "nothing-to-be-excluded"
60 auto-revert-stop-on-user-input nil
61 file-notify-debug nil
62 tramp-verbose 0
63 tramp-message-show-message nil)
31 64
32(defconst auto-revert--timeout 10 65(defconst auto-revert--timeout 10
33 "Time to wait for a message.") 66 "Time to wait for a message.")
@@ -35,19 +68,88 @@
35(defvar auto-revert--messages nil 68(defvar auto-revert--messages nil
36 "Used to collect messages issued during a section of a test.") 69 "Used to collect messages issued during a section of a test.")
37 70
71;; There is no default value on w32 systems, which could work out of the box.
72(defconst auto-revert-test-remote-temporary-file-directory
73 (cond
74 ((getenv "REMOTE_TEMPORARY_FILE_DIRECTORY"))
75 ((eq system-type 'windows-nt) null-device)
76 (t (add-to-list
77 'tramp-methods
78 '("mock"
79 (tramp-login-program "sh")
80 (tramp-login-args (("-i")))
81 (tramp-remote-shell "/bin/sh")
82 (tramp-remote-shell-args ("-c"))
83 (tramp-connection-timeout 10)))
84 (add-to-list
85 'tramp-default-host-alist
86 `("\\`mock\\'" nil ,(system-name)))
87 ;; Emacs' Makefile sets $HOME to a nonexistent value. Needed in
88 ;; batch mode only, therefore. `temporary-file-directory' might
89 ;; be quoted, so we unquote it just in case.
90 (unless (and (null noninteractive) (file-directory-p "~/"))
91 (setenv "HOME" (file-name-unquote temporary-file-directory)))
92 (format "/mock::%s" temporary-file-directory)))
93 "Temporary directory for Tramp tests.")
94
95;; Filter suppressed remote file-notify libraries.
96(when (stringp (getenv "REMOTE_FILE_NOTIFY_LIBRARY"))
97 (dolist (lib '("inotifywait" "gio-monitor" "gvfs-monitor-dir"))
98 (unless (string-equal (getenv "REMOTE_FILE_NOTIFY_LIBRARY") lib)
99 (add-to-list 'tramp-connection-properties `(nil ,lib nil)))))
100
101(defvar auto-revert--test-enabled-remote-checked nil
102 "Cached result of `auto-revert--test-enabled-remote'.
103If the function did run, the value is a cons cell, the `cdr'
104being the result.")
105
106(defun auto-revert--test-enabled-remote ()
107 "Whether remote file access is enabled."
108 (unless (consp auto-revert--test-enabled-remote-checked)
109 (setq
110 auto-revert--test-enabled-remote-checked
111 (cons
112 t (ignore-errors
113 (and
114 (file-remote-p auto-revert-test-remote-temporary-file-directory)
115 (file-directory-p auto-revert-test-remote-temporary-file-directory)
116 (file-writable-p
117 auto-revert-test-remote-temporary-file-directory))))))
118 ;; Return result.
119 (cdr auto-revert--test-enabled-remote-checked))
120
38(defun auto-revert--wait-for-revert (buffer) 121(defun auto-revert--wait-for-revert (buffer)
39 "Wait until a message reports reversion of BUFFER. 122 "Wait until a message reports reversion of BUFFER.
40This expects `auto-revert--messages' to be bound by 123This expects `auto-revert--messages' to be bound by
41`ert-with-message-capture' before calling." 124`ert-with-message-capture' before calling."
42 (with-timeout (auto-revert--timeout nil) 125 ;; Remote files do not cooperate well with timers. So we count ourselves.
43 (while 126 (let ((ct (current-time)))
44 (null (string-match 127 (while (and (< (float-time (time-subtract (current-time) ct))
45 (format-message "Reverting buffer `%s'." (buffer-name buffer)) 128 auto-revert--timeout)
46 auto-revert--messages)) 129 (null (string-match
130 (format-message
131 "Reverting buffer `%s'\\." (buffer-name buffer))
132 auto-revert--messages)))
47 (if (with-current-buffer buffer auto-revert-use-notify) 133 (if (with-current-buffer buffer auto-revert-use-notify)
48 (read-event nil nil 0.1) 134 (read-event nil nil 0.1)
49 (sleep-for 0.1))))) 135 (sleep-for 0.1)))))
50 136
137(defmacro auto-revert--deftest-remote (test docstring)
138 "Define ert `TEST-remote' for remote files."
139 (declare (indent 1))
140 `(ert-deftest ,(intern (concat (symbol-name test) "-remote")) ()
141 ,docstring
142 :tags '(:expensive-test)
143 (let ((temporary-file-directory
144 auto-revert-test-remote-temporary-file-directory)
145 (auto-revert-remote-files t)
146 (ert-test (ert-get-test ',test))
147 vc-handled-backends)
148 (skip-unless (auto-revert--test-enabled-remote))
149 (tramp-cleanup-connection
150 (tramp-dissect-file-name temporary-file-directory) nil 'keep-password)
151 (funcall (ert-test-body ert-test)))))
152
51(ert-deftest auto-revert-test00-auto-revert-mode () 153(ert-deftest auto-revert-test00-auto-revert-mode ()
52 "Check autorevert for a file." 154 "Check autorevert for a file."
53 ;; `auto-revert-buffers' runs every 5". And we must wait, until the 155 ;; `auto-revert-buffers' runs every 5". And we must wait, until the
@@ -93,13 +195,16 @@ This expects `auto-revert--messages' to be bound by
93 (kill-buffer buf)) 195 (kill-buffer buf))
94 (ignore-errors (delete-file tmpfile))))) 196 (ignore-errors (delete-file tmpfile)))))
95 197
198(auto-revert--deftest-remote auto-revert-test00-auto-revert-mode
199 "Check autorevert for a remote file.")
200
96;; This is inspired by Bug#21841. 201;; This is inspired by Bug#21841.
97(ert-deftest auto-revert-test01-auto-revert-several-files () 202(ert-deftest auto-revert-test01-auto-revert-several-files ()
98 "Check autorevert for several files at once." 203 "Check autorevert for several files at once."
99 :tags '(:expensive-test) 204 :tags '(:expensive-test)
100 (skip-unless (executable-find "cp")) 205 (skip-unless (executable-find "cp" (file-remote-p temporary-file-directory)))
101 206
102 (let* ((cp (executable-find "cp")) 207 (let* ((cp (executable-find "cp" (file-remote-p temporary-file-directory)))
103 (tmpdir1 (make-temp-file "auto-revert-test" 'dir)) 208 (tmpdir1 (make-temp-file "auto-revert-test" 'dir))
104 (tmpdir2 (make-temp-file "auto-revert-test" 'dir)) 209 (tmpdir2 (make-temp-file "auto-revert-test" 'dir))
105 (tmpfile1 210 (tmpfile1
@@ -139,7 +244,9 @@ This expects `auto-revert--messages' to be bound by
139 ;; Strange, that `copy-directory' does not work as expected. 244 ;; Strange, that `copy-directory' does not work as expected.
140 ;; The following shell command is not portable on all 245 ;; The following shell command is not portable on all
141 ;; platforms, unfortunately. 246 ;; platforms, unfortunately.
142 (shell-command (format "%s -f %s/* %s" cp tmpdir2 tmpdir1)) 247 (shell-command
248 (format "%s -f %s/* %s"
249 cp (file-local-name tmpdir2) (file-local-name tmpdir1)))
143 250
144 ;; Check, that the buffers have been reverted. 251 ;; Check, that the buffers have been reverted.
145 (dolist (buf (list buf1 buf2)) 252 (dolist (buf (list buf1 buf2))
@@ -155,6 +262,9 @@ This expects `auto-revert--messages' to be bound by
155 (ignore-errors (delete-directory tmpdir1 'recursive)) 262 (ignore-errors (delete-directory tmpdir1 'recursive))
156 (ignore-errors (delete-directory tmpdir2 'recursive))))) 263 (ignore-errors (delete-directory tmpdir2 'recursive)))))
157 264
265(auto-revert--deftest-remote auto-revert-test01-auto-revert-several-files
266 "Check autorevert for several remote files at once.")
267
158;; This is inspired by Bug#23276. 268;; This is inspired by Bug#23276.
159(ert-deftest auto-revert-test02-auto-revert-deleted-file () 269(ert-deftest auto-revert-test02-auto-revert-deleted-file ()
160 "Check autorevert for a deleted file." 270 "Check autorevert for a deleted file."
@@ -185,8 +295,8 @@ This expects `auto-revert--messages' to be bound by
185 (add-hook 295 (add-hook
186 'before-revert-hook 296 'before-revert-hook
187 (lambda () 297 (lambda ()
188 ;; Temporarily. 298 (when auto-revert-debug
189 (message "%s deleted" buffer-file-name) 299 (message "%s deleted" buffer-file-name))
190 (delete-file buffer-file-name)) 300 (delete-file buffer-file-name))
191 nil t) 301 nil t)
192 302
@@ -199,7 +309,9 @@ This expects `auto-revert--messages' to be bound by
199 ;; polling. 309 ;; polling.
200 (should (string-match "any text" (buffer-string))) 310 (should (string-match "any text" (buffer-string)))
201 ;; With w32notify, the 'stopped' events are not sent. 311 ;; With w32notify, the 'stopped' events are not sent.
312 ;; Same for remote file name handlers. Why?
202 (or (eq file-notify--library 'w32notify) 313 (or (eq file-notify--library 'w32notify)
314 (file-remote-p temporary-file-directory)
203 (should-not auto-revert-notify-watch-descriptor)) 315 (should-not auto-revert-notify-watch-descriptor))
204 316
205 ;; Once the file has been recreated, the buffer shall be 317 ;; Once the file has been recreated, the buffer shall be
@@ -231,6 +343,9 @@ This expects `auto-revert--messages' to be bound by
231 (kill-buffer buf)) 343 (kill-buffer buf))
232 (ignore-errors (delete-file tmpfile))))) 344 (ignore-errors (delete-file tmpfile)))))
233 345
346(auto-revert--deftest-remote auto-revert-test02-auto-revert-deleted-file
347 "Check autorevert for a deleted remote file.")
348
234(ert-deftest auto-revert-test03-auto-revert-tail-mode () 349(ert-deftest auto-revert-test03-auto-revert-tail-mode ()
235 "Check autorevert tail mode." 350 "Check autorevert tail mode."
236 ;; `auto-revert-buffers' runs every 5". And we must wait, until the 351 ;; `auto-revert-buffers' runs every 5". And we must wait, until the
@@ -266,6 +381,9 @@ This expects `auto-revert--messages' to be bound by
266 (ignore-errors (kill-buffer buf)) 381 (ignore-errors (kill-buffer buf))
267 (ignore-errors (delete-file tmpfile))))) 382 (ignore-errors (delete-file tmpfile)))))
268 383
384(auto-revert--deftest-remote auto-revert-test03-auto-revert-tail-mode
385 "Check remote autorevert tail mode.")
386
269(ert-deftest auto-revert-test04-auto-revert-mode-dired () 387(ert-deftest auto-revert-test04-auto-revert-mode-dired ()
270 "Check autorevert for dired." 388 "Check autorevert for dired."
271 ;; `auto-revert-buffers' runs every 5". And we must wait, until the 389 ;; `auto-revert-buffers' runs every 5". And we must wait, until the
@@ -314,6 +432,9 @@ This expects `auto-revert--messages' to be bound by
314 (kill-buffer buf)) 432 (kill-buffer buf))
315 (ignore-errors (delete-file tmpfile))))) 433 (ignore-errors (delete-file tmpfile)))))
316 434
435(auto-revert--deftest-remote auto-revert-test04-auto-revert-mode-dired
436 "Check remote autorevert for dired.")
437
317(defun auto-revert-test-all (&optional interactive) 438(defun auto-revert-test-all (&optional interactive)
318 "Run all tests for \\[auto-revert]." 439 "Run all tests for \\[auto-revert]."
319 (interactive "p") 440 (interactive "p")
diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el
index a40dc720786..af2d0b33e08 100644
--- a/test/lisp/filenotify-tests.el
+++ b/test/lisp/filenotify-tests.el
@@ -195,7 +195,8 @@ Return nil when any other file notification watch is still active."
195 file-notify--test-events nil 195 file-notify--test-events nil
196 file-notify--test-monitors nil)) 196 file-notify--test-monitors nil))
197 197
198(setq password-cache-expiry nil 198(setq file-notify-debug nil
199 password-cache-expiry nil
199 tramp-verbose 0 200 tramp-verbose 0
200 tramp-message-show-message nil) 201 tramp-message-show-message nil)
201 202
@@ -515,8 +516,9 @@ and the event to `file-notify--test-events'."
515 (unless (string-match 516 (unless (string-match
516 (regexp-quote ".#") 517 (regexp-quote ".#")
517 (file-notify--event-file-name file-notify--test-event)) 518 (file-notify--event-file-name file-notify--test-event))
518 ;;(message "file-notify--test-event-handler result: %s event: %S" 519 (when file-notify-debug
519 ;;(null (ert-test-failed-p result)) file-notify--test-event) 520 (message "file-notify--test-event-handler result: %s event: %S"
521 (null (ert-test-failed-p result)) file-notify--test-event))
520 (setq file-notify--test-events 522 (setq file-notify--test-events
521 (append file-notify--test-events `(,file-notify--test-event)) 523 (append file-notify--test-events `(,file-notify--test-event))
522 file-notify--test-results 524 file-notify--test-results