aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2025-07-15 18:57:49 +0200
committerMichael Albinus2025-07-15 18:57:49 +0200
commit4c9b37660771776563cf79bb3a2b6e692aa05ca2 (patch)
tree092504ff9200345995e130a0ab9f8602f8379a42
parent0237e0d1a41a9095d7f1fdd32c0a123f60ffaace (diff)
downloademacs-4c9b37660771776563cf79bb3a2b6e692aa05ca2.tar.gz
emacs-4c9b37660771776563cf79bb3a2b6e692aa05ca2.zip
Improve autorevert-tests
* doc/misc/trampver.texi: * lisp/net/trampver.el: Change version to "2.8.1-pre". * lisp/autorevert.el (auto-revert-mode, auto-revert-tail-mode) (auto-revert-notify-handler, auto-revert--end-lockout): Use `auto-revert-buffer'. (auto-revert-notify-handler): Rearrange setting current buffer. (auto-revert-handler): Add debug message. Rearrange check. Cancel lockout timer if running. * lisp/net/tramp.el (tramp-barf-if-file-missing) (with-parsed-tramp-file-name, tramp-skeleton-file-truename): * lisp/net/tramp-archive.el (with-parsed-tramp-archive-file-name): * lisp/net/tramp-message.el (tramp-with-demoted-errors): Fix debug declatation. * lisp/net/tramp-sh.el (tramp-sh-gio-monitor-process-filter): Do not prepend remote prefix. * test/lisp/autorevert-tests.el: Unify file notification libraries "gio-monitor" and "gvfs-monitor-dir" to "gio". (top): Set some Tramp related variables. (auto-revert--timeout): Increase value. (auto-revert--test-enabled-remote) (auto-revert-test02-auto-revert-deleted-file): Do not check for EMACS_HYDRA_CI environment variable. (auto-revert--wait-for-revert): Fix regexp to search for. (auto-revert--deftest-remote): Fix debug declatation. Do not tag :unstable. (with-auto-revert-test): Fix debug declatation. Adapt revert intervals. (auto-revert-test*): Start with (file-notify-rm-all-watches). Use `buffer-string' and `string-match-p'. (auto-revert-test00-auto-revert-mode): Unlock initial lockout. (auto-revert-test01-auto-revert-several-files): Rearrange temporary directory and file settings. (auto-revert-test02-auto-revert-deleted-file): Adapt debug message. (auto-revert-test03-auto-revert-tail-mode): Use `with-auto-revert-test'. (auto-revert-test04-auto-revert-mode-dired): Use `ert-with-temp-directory'. Adapt prefix of tmpfile. (auto-revert-test04-auto-revert-mode-dired) (auto-revert-test05-global-notify, auto-revert-test06-write-file): Wait for proper file modification. (auto-revert-test--instrument-kill-buffer-hook): Fix debug message. (auto-revert-test07-auto-revert-several-buffers): Use `with-auto-revert-test. * test/lisp/filenotify-tests.el: Unify file notification libraries "gio-monitor" and "gvfs-monitor-dir" to "gio". (file-notify--deftest-remote): Fix debug declatation. Do not skip for "gio". (file-notify--test-with-actions): Fix debug declatation. * test/lisp/net/tramp-tests.el (filenotify): Require. (ert-remote-temporary-file-directory) (tramp-test41-special-characters, tramp-test42-utf8) (tramp-test45-asynchronous-requests): Do not check for EMACS_HYDRA_CI environment variable. (tramp-test46-file-notifications): New test.
-rw-r--r--doc/misc/trampver.texi2
-rw-r--r--lisp/autorevert.el62
-rw-r--r--lisp/net/tramp-archive.el2
-rw-r--r--lisp/net/tramp-message.el2
-rw-r--r--lisp/net/tramp-sh.el7
-rw-r--r--lisp/net/tramp.el6
-rw-r--r--lisp/net/trampver.el6
-rw-r--r--test/lisp/autorevert-tests.el355
-rw-r--r--test/lisp/filenotify-tests.el26
-rw-r--r--test/lisp/net/tramp-tests.el80
10 files changed, 342 insertions, 206 deletions
diff --git a/doc/misc/trampver.texi b/doc/misc/trampver.texi
index a6e305534aa..bfae103a782 100644
--- a/doc/misc/trampver.texi
+++ b/doc/misc/trampver.texi
@@ -7,7 +7,7 @@
7 7
8@c In the Tramp GIT, the version number and the bug report address 8@c In the Tramp GIT, the version number and the bug report address
9@c are auto-frobbed from configure.ac. 9@c are auto-frobbed from configure.ac.
10@set trampver 2.8.0 10@set trampver 2.8.1-pre
11@set trampurl https://www.gnu.org/software/tramp/ 11@set trampurl https://www.gnu.org/software/tramp/
12@set tramp-bug-report-address tramp-devel@@gnu.org 12@set tramp-bug-report-address tramp-devel@@gnu.org
13@set emacsver 28.1 13@set emacsver 28.1
diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index 4eaf42da89e..4eb1a0e85ba 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -415,7 +415,7 @@ without being changed in the part that is already in the buffer."
415 (auto-revert-remove-current-buffer)) 415 (auto-revert-remove-current-buffer))
416 (auto-revert-set-timer) 416 (auto-revert-set-timer)
417 (when auto-revert-mode 417 (when auto-revert-mode
418 (auto-revert-buffers) 418 (auto-revert-buffer (current-buffer))
419 (setq auto-revert-tail-mode nil))) 419 (setq auto-revert-tail-mode nil)))
420 420
421 421
@@ -470,7 +470,7 @@ Use `auto-revert-mode' for changes other than appends!"
470 (y-or-n-p "File changed on disk, content may be missing. \ 470 (y-or-n-p "File changed on disk, content may be missing. \
471Perform a full revert? ") 471Perform a full revert? ")
472 ;; Use this (not just revert-buffer) for point-preservation. 472 ;; Use this (not just revert-buffer) for point-preservation.
473 (auto-revert-buffers)) 473 (auto-revert-buffer (current-buffer)))
474 ;; else we might reappend our own end when we save 474 ;; else we might reappend our own end when we save
475 (add-hook 'before-save-hook (lambda () (auto-revert-tail-mode 0)) nil t) 475 (add-hook 'before-save-hook (lambda () (auto-revert-tail-mode 0)) nil t)
476 (or (local-variable-p 'auto-revert-tail-pos) ; don't lose prior position 476 (or (local-variable-p 'auto-revert-tail-pos) ; don't lose prior position
@@ -716,9 +716,9 @@ system.")
716 (message "auto-revert-notify-handler %S" event)) 716 (message "auto-revert-notify-handler %S" event))
717 717
718 (when (buffer-live-p buffer) 718 (when (buffer-live-p buffer)
719 (if (eq action 'stopped) 719 (with-current-buffer buffer
720 ;; File notification has stopped. Continue with polling. 720 (if (eq action 'stopped)
721 (with-current-buffer buffer 721 ;; File notification has stopped. Continue with polling.
722 (when (or 722 (when (or
723 ;; A buffer associated with a file. 723 ;; A buffer associated with a file.
724 (and (stringp buffer-file-name) 724 (and (stringp buffer-file-name)
@@ -730,9 +730,8 @@ system.")
730 (auto-revert-notify-rm-watch) 730 (auto-revert-notify-rm-watch)
731 ;; Restart the timer if it wasn't running. 731 ;; Restart the timer if it wasn't running.
732 (unless auto-revert-timer 732 (unless auto-revert-timer
733 (auto-revert-set-timer)))) 733 (auto-revert-set-timer)))
734 734
735 (with-current-buffer buffer
736 (when (or 735 (when (or
737 ;; A buffer associated with a file. 736 ;; A buffer associated with a file.
738 (and (stringp buffer-file-name) 737 (and (stringp buffer-file-name)
@@ -761,7 +760,7 @@ system.")
761 ;; Revert it when first entry or it was reverted intervals ago. 760 ;; Revert it when first entry or it was reverted intervals ago.
762 (when (> (float-time (time-since auto-revert--last-time)) 761 (when (> (float-time (time-since auto-revert--last-time))
763 auto-revert--lockout-interval) 762 auto-revert--lockout-interval)
764 (auto-revert-handler)))))))))) 763 (auto-revert-buffer buffer))))))))))
765 764
766(defun auto-revert--end-lockout (buffer) 765(defun auto-revert--end-lockout (buffer)
767 "End the lockout period after a notification. 766 "End the lockout period after a notification.
@@ -770,7 +769,7 @@ If the buffer needs to be reverted, do it now."
770 (with-current-buffer buffer 769 (with-current-buffer buffer
771 (setq auto-revert--lockout-timer nil) 770 (setq auto-revert--lockout-timer nil)
772 (when auto-revert-notify-modified-p 771 (when auto-revert-notify-modified-p
773 (auto-revert-handler))))) 772 (auto-revert-buffer buffer)))))
774 773
775;;;###autoload 774;;;###autoload
776(progn 775(progn
@@ -809,36 +808,37 @@ Run BODY."
809(defun auto-revert-handler () 808(defun auto-revert-handler ()
810 "Revert current buffer, if appropriate. 809 "Revert current buffer, if appropriate.
811This is an internal function used by Auto-Revert Mode." 810This is an internal function used by Auto-Revert Mode."
811 (when auto-revert-debug
812 (message "auto-revert-handler %S" (current-buffer)))
812 (let* ((buffer (current-buffer)) size 813 (let* ((buffer (current-buffer)) size
813 ;; Tramp caches the file attributes. Setting 814 ;; Tramp caches the file attributes. Setting
814 ;; `remote-file-name-inhibit-cache' forces Tramp to reread 815 ;; `remote-file-name-inhibit-cache' forces Tramp to reread
815 ;; the values. 816 ;; the values.
816 (remote-file-name-inhibit-cache t) 817 (remote-file-name-inhibit-cache t)
817 (revert 818 (revert
818 (if buffer-file-name 819 (and (or auto-revert-remote-files
819 (and (or auto-revert-remote-files 820 (not (file-remote-p default-directory)))
820 (not (file-remote-p buffer-file-name))) 821 (or (not auto-revert-notify-watch-descriptor)
821 (or (not auto-revert-notify-watch-descriptor) 822 auto-revert-notify-modified-p)
822 auto-revert-notify-modified-p) 823 (not (memq (current-buffer) inhibit-auto-revert-buffers))
823 (not (memq (current-buffer) inhibit-auto-revert-buffers)) 824 (if (and buffer-file-name auto-revert-tail-mode)
824 (if auto-revert-tail-mode 825 (and (file-readable-p buffer-file-name)
825 (and (file-readable-p buffer-file-name) 826 (/= auto-revert-tail-pos
826 (/= auto-revert-tail-pos 827 (setq size
827 (setq size 828 (file-attribute-size
828 (file-attribute-size 829 (file-attributes buffer-file-name)))))
829 (file-attributes buffer-file-name))))) 830 (and (or auto-revert-mode auto-revert--global-mode)
830 (funcall (or buffer-stale-function 831 (funcall (or buffer-stale-function
831 #'buffer-stale--default-function) 832 #'buffer-stale--default-function)
832 t))) 833 t)))))
833 (and (or auto-revert-mode
834 global-auto-revert-non-file-buffers)
835 (not (memq (current-buffer) inhibit-auto-revert-buffers))
836 (funcall (or buffer-stale-function
837 #'buffer-stale--default-function)
838 t))))
839 eob eoblist) 834 eob eoblist)
835 (when (timerp auto-revert--lockout-timer)
836 (cancel-timer auto-revert--lockout-timer))
840 (setq auto-revert-notify-modified-p nil 837 (setq auto-revert-notify-modified-p nil
841 auto-revert--last-time (current-time)) 838 auto-revert--last-time
839 (if revert (current-time) auto-revert--last-time)
840 auto-revert--lockout-timer nil)
841
842 (when revert 842 (when revert
843 (when (and auto-revert-verbose 843 (when (and auto-revert-verbose
844 (not (eq revert 'fast))) 844 (not (eq revert 'fast)))
diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el
index 0a1c44d3673..3de909911b4 100644
--- a/lisp/net/tramp-archive.el
+++ b/lisp/net/tramp-archive.el
@@ -557,7 +557,7 @@ A variable `foo-archive' (or `archive') will be bound to the
557archive name part of FILENAME, assuming `foo' (or nil) is the 557archive name part of FILENAME, assuming `foo' (or nil) is the
558value of VAR. OTOH, the variable `foo-hop' (or `hop') won't be 558value of VAR. OTOH, the variable `foo-hop' (or `hop') won't be
559offered." 559offered."
560 (declare (debug (form symbolp body)) 560 (declare (debug (form symbolp &rest body))
561 (indent 2)) 561 (indent 2))
562 (let ((bindings 562 (let ((bindings
563 (mapcar 563 (mapcar
diff --git a/lisp/net/tramp-message.el b/lisp/net/tramp-message.el
index d87c62a4b50..5131e5fced9 100644
--- a/lisp/net/tramp-message.el
+++ b/lisp/net/tramp-message.el
@@ -454,7 +454,7 @@ an input event arrives. The other arguments are passed to `tramp-error'."
454BODY is executed like wrapped by `with-demoted-errors'. FORMAT 454BODY is executed like wrapped by `with-demoted-errors'. FORMAT
455is a format-string containing a %-sequence meaning to substitute 455is a format-string containing a %-sequence meaning to substitute
456the resulting error message." 456the resulting error message."
457 (declare (indent 2) (debug (symbolp form body))) 457 (declare (indent 2) (debug (symbolp form &rest body)))
458 (let ((err (make-symbol "err"))) 458 (let ((err (make-symbol "err")))
459 `(condition-case-unless-debug ,err 459 `(condition-case-unless-debug ,err
460 (progn ,@body) 460 (progn ,@body)
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 41a1cdf3409..457c9cf6b0e 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -3864,8 +3864,6 @@ Fall back to normal file name handler if no Tramp handler exists."
3864(defun tramp-sh-gio-monitor-process-filter (proc string) 3864(defun tramp-sh-gio-monitor-process-filter (proc string)
3865 "Read output from \"gio monitor\" and add corresponding `file-notify' events." 3865 "Read output from \"gio monitor\" and add corresponding `file-notify' events."
3866 (let ((events (process-get proc 'tramp-events)) 3866 (let ((events (process-get proc 'tramp-events))
3867 (remote-prefix
3868 (file-remote-p (tramp-get-default-directory (process-buffer proc))))
3869 (rest-string (process-get proc 'tramp-rest-string)) 3867 (rest-string (process-get proc 'tramp-rest-string))
3870 pos) 3868 pos)
3871 (when rest-string 3869 (when rest-string
@@ -3927,10 +3925,7 @@ Fall back to normal file name handler if no Tramp handler exists."
3927 proc 3925 proc
3928 (list 3926 (list
3929 (intern-soft (match-string 2 string))) 3927 (intern-soft (match-string 2 string)))
3930 ;; File names are returned as absolute paths. We 3928 file file1)))
3931 ;; must add the remote prefix.
3932 (concat remote-prefix file)
3933 (when file1 (concat remote-prefix file1)))))
3934 (setq string (replace-match "" nil nil string)) 3929 (setq string (replace-match "" nil nil string))
3935 ;; Add an Emacs event now. 3930 ;; Add an Emacs event now.
3936 ;; `insert-special-event' exists since Emacs 31. 3931 ;; `insert-special-event' exists since Emacs 31.
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index d64f6ba37ac..5a19e4be1ae 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -2102,7 +2102,7 @@ of `current-buffer'."
2102 "Execute BODY and return the result. 2102 "Execute BODY and return the result.
2103In case of an error, raise a `file-missing' error if FILENAME 2103In case of an error, raise a `file-missing' error if FILENAME
2104does not exist, otherwise propagate the error." 2104does not exist, otherwise propagate the error."
2105 (declare (indent 2) (debug (symbolp form body))) 2105 (declare (indent 2) (debug (tramp-file-name-p form &rest body)))
2106 (let ((err (make-symbol "err"))) 2106 (let ((err (make-symbol "err")))
2107 `(condition-case ,err 2107 `(condition-case ,err
2108 (let (signal-hook-function) ,@body) 2108 (let (signal-hook-function) ,@body)
@@ -2141,7 +2141,7 @@ Remaining args are Lisp expressions to be evaluated (inside an implicit
2141 2141
2142If VAR is nil, then we bind `v' to the structure and `method', `user', 2142If VAR is nil, then we bind `v' to the structure and `method', `user',
2143`domain', `host', `port', `localname', `hop' to the components." 2143`domain', `host', `port', `localname', `hop' to the components."
2144 (declare (indent 2) (debug (form symbolp body))) 2144 (declare (indent 2) (debug (form symbolp &rest body)))
2145 (let ((bindings 2145 (let ((bindings
2146 (mapcar 2146 (mapcar
2147 (lambda (elem) 2147 (lambda (elem)
@@ -3601,7 +3601,7 @@ BODY is the backend specific code."
3601(defmacro tramp-skeleton-file-truename (filename &rest body) 3601(defmacro tramp-skeleton-file-truename (filename &rest body)
3602 "Skeleton for `tramp-*-handle-file-truename'. 3602 "Skeleton for `tramp-*-handle-file-truename'.
3603BODY is the backend specific code." 3603BODY is the backend specific code."
3604 (declare (indent 1) (debug (form body))) 3604 (declare (indent 1) (debug (form &rest body)))
3605 ;; Preserve trailing "/". 3605 ;; Preserve trailing "/".
3606 `(funcall 3606 `(funcall
3607 (if (directory-name-p ,filename) #'file-name-as-directory #'identity) 3607 (if (directory-name-p ,filename) #'file-name-as-directory #'identity)
diff --git a/lisp/net/trampver.el b/lisp/net/trampver.el
index 65e60c0464a..56e525e8d81 100644
--- a/lisp/net/trampver.el
+++ b/lisp/net/trampver.el
@@ -7,7 +7,7 @@
7;; Maintainer: Michael Albinus <michael.albinus@gmx.de> 7;; Maintainer: Michael Albinus <michael.albinus@gmx.de>
8;; Keywords: comm, processes 8;; Keywords: comm, processes
9;; Package: tramp 9;; Package: tramp
10;; Version: 2.8.0 10;; Version: 2.8.1-pre
11;; Package-Requires: ((emacs "28.1")) 11;; Package-Requires: ((emacs "28.1"))
12;; Package-Type: multi 12;; Package-Type: multi
13;; URL: https://www.gnu.org/software/tramp/ 13;; URL: https://www.gnu.org/software/tramp/
@@ -40,7 +40,7 @@
40;; ./configure" to change them. 40;; ./configure" to change them.
41 41
42;;;###tramp-autoload 42;;;###tramp-autoload
43(defconst tramp-version "2.8.0" 43(defconst tramp-version "2.8.1-pre"
44 "This version of Tramp.") 44 "This version of Tramp.")
45 45
46;;;###tramp-autoload 46;;;###tramp-autoload
@@ -76,7 +76,7 @@
76;; Check for Emacs version. 76;; Check for Emacs version.
77(let ((x (if (not (string-version-lessp emacs-version "28.1")) 77(let ((x (if (not (string-version-lessp emacs-version "28.1"))
78 "ok" 78 "ok"
79 (format "Tramp 2.8.0 is not fit for %s" 79 (format "Tramp 2.8.1-pre is not fit for %s"
80 (replace-regexp-in-string "\n" "" (emacs-version)))))) 80 (replace-regexp-in-string "\n" "" (emacs-version))))))
81 (unless (string-equal "ok" x) (error "%s" x))) 81 (unless (string-equal "ok" x) (error "%s" x)))
82 82
diff --git a/test/lisp/autorevert-tests.el b/test/lisp/autorevert-tests.el
index 4aab58a6f02..9b46ec68b99 100644
--- a/test/lisp/autorevert-tests.el
+++ b/test/lisp/autorevert-tests.el
@@ -37,7 +37,7 @@
37;; of a respective command. The first command found is used. In 37;; of a respective command. The first command found is used. In
38;; order to use a dedicated one, the environment variable 38;; order to use a dedicated one, the environment variable
39;; $REMOTE_FILE_NOTIFY_LIBRARY shall be set, possible values are 39;; $REMOTE_FILE_NOTIFY_LIBRARY shall be set, possible values are
40;; "inotifywait", "gio-monitor" and "gvfs-monitor-dir". 40;; "inotifywait", "gio" and "smb-notify".
41 41
42;; Local file-notify libraries are auto-detected during Emacs 42;; Local file-notify libraries are auto-detected during Emacs
43;; configuration. This can be changed with a respective configuration 43;; configuration. This can be changed with a respective configuration
@@ -56,22 +56,33 @@
56(require 'ert-x) 56(require 'ert-x)
57(require 'autorevert) 57(require 'autorevert)
58 58
59(setq auto-revert-debug nil 59(setq auth-source-cache-expiry nil
60 auth-source-save-behavior nil
61 auto-revert-debug nil
60 auto-revert-notify-exclude-dir-regexp "nothing-to-be-excluded" 62 auto-revert-notify-exclude-dir-regexp "nothing-to-be-excluded"
61 auto-revert-stop-on-user-input nil 63 auto-revert-stop-on-user-input nil
64 ert-temp-file-prefix "auto-revert-test"
65 ert-temp-file-suffix ""
62 file-notify-debug nil 66 file-notify-debug nil
63 tramp-verbose 0) 67 password-cache-expiry nil
68 remote-file-name-inhibit-cache nil
69 tramp-allow-unsafe-temporary-files t
70 tramp-cache-read-persistent-data t ;; For auth-sources.
71 tramp-verbose 0
72 ;; When the remote user id is 0, Tramp refuses unsafe temporary files.
73 tramp-allow-unsafe-temporary-files
74 (or tramp-allow-unsafe-temporary-files noninteractive))
64 75
65(defun auto-revert--timeout () 76(defun auto-revert--timeout ()
66 "Time to wait for a message." 77 "Time to wait for a message."
67 (+ auto-revert-interval 0.1)) 78 (+ auto-revert-interval 1))
68 79
69(defvar auto-revert--messages nil 80(defvar auto-revert--messages nil
70 "Used to collect messages issued during a section of a test.") 81 "Used to collect messages issued during a section of a test.")
71 82
72;; Filter suppressed remote file-notify libraries. 83;; Filter suppressed remote file-notify libraries.
73(when (stringp (getenv "REMOTE_FILE_NOTIFY_LIBRARY")) 84(when (stringp (getenv "REMOTE_FILE_NOTIFY_LIBRARY"))
74 (dolist (lib '("inotifywait" "gio-monitor" "gvfs-monitor-dir")) 85 (dolist (lib '("inotifywait" "gio" "smb-notify"))
75 (unless (string-equal (getenv "REMOTE_FILE_NOTIFY_LIBRARY") lib) 86 (unless (string-equal (getenv "REMOTE_FILE_NOTIFY_LIBRARY") lib)
76 (add-to-list 'tramp-connection-properties `(nil ,lib nil))))) 87 (add-to-list 'tramp-connection-properties `(nil ,lib nil)))))
77 88
@@ -88,7 +99,6 @@ being the result.")
88 (cons 99 (cons
89 t (ignore-errors 100 t (ignore-errors
90 (and 101 (and
91 (not (getenv "EMACS_HYDRA_CI"))
92 (file-remote-p ert-remote-temporary-file-directory) 102 (file-remote-p ert-remote-temporary-file-directory)
93 (file-directory-p ert-remote-temporary-file-directory) 103 (file-directory-p ert-remote-temporary-file-directory)
94 (file-writable-p ert-remote-temporary-file-directory)))))) 104 (file-writable-p ert-remote-temporary-file-directory))))))
@@ -100,12 +110,13 @@ being the result.")
100This expects `auto-revert--messages' to be bound by 110This expects `auto-revert--messages' to be bound by
101`ert-with-message-capture' before calling." 111`ert-with-message-capture' before calling."
102 ;; Remote files do not cooperate well with timers. So we count ourselves. 112 ;; Remote files do not cooperate well with timers. So we count ourselves.
103 (let ((ct (current-time))) 113 (let ((ct (current-time))
114 (text-quoting-style 'grave))
104 (while (and (< (float-time (time-subtract nil ct)) 115 (while (and (< (float-time (time-subtract nil ct))
105 (auto-revert--timeout)) 116 (auto-revert--timeout))
106 (null (string-match 117 (null (string-match-p
107 (format-message 118 (rx bol "Reverting buffer `"
108 "Reverting buffer `%s'" (buffer-name buffer)) 119 (literal (buffer-name buffer)) "'" eol)
109 (or auto-revert--messages "")))) 120 (or auto-revert--messages ""))))
110 (if (and (or file-notify--library 121 (if (and (or file-notify--library
111 (file-remote-p temporary-file-directory)) 122 (file-remote-p temporary-file-directory))
@@ -115,10 +126,10 @@ This expects `auto-revert--messages' to be bound by
115 126
116(defmacro auto-revert--deftest-remote (test docstring) 127(defmacro auto-revert--deftest-remote (test docstring)
117 "Define ert `TEST-remote' for remote files." 128 "Define ert `TEST-remote' for remote files."
118 (declare (indent 1)) 129 (declare (indent 1) (debug (symbolp stringp)))
119 `(ert-deftest ,(intern (concat (symbol-name test) "-remote")) () 130 `(ert-deftest ,(intern (concat (symbol-name test) "-remote")) ()
120 ,docstring 131 ,docstring
121 :tags '(:expensive-test :unstable) 132 :tags '(:expensive-test)
122 (let ((temporary-file-directory 133 (let ((temporary-file-directory
123 ert-remote-temporary-file-directory) 134 ert-remote-temporary-file-directory)
124 (auto-revert-remote-files t) 135 (auto-revert-remote-files t)
@@ -132,12 +143,14 @@ This expects `auto-revert--messages' to be bound by
132 (error (message "%s" err) (signal (car err) (cdr err))))))) 143 (error (message "%s" err) (signal (car err) (cdr err)))))))
133 144
134(defmacro with-auto-revert-test (&rest body) 145(defmacro with-auto-revert-test (&rest body)
146 (declare (debug t))
135 `(let ((auto-revert-interval-orig auto-revert-interval) 147 `(let ((auto-revert-interval-orig auto-revert-interval)
136 (auto-revert--lockout-interval-orig auto-revert--lockout-interval)) 148 (auto-revert--lockout-interval-orig auto-revert--lockout-interval))
137 (unwind-protect 149 (unwind-protect
138 (progn 150 (progn
139 (customize-set-variable 'auto-revert-interval 0.1) 151 (unless (file-remote-p temporary-file-directory)
140 (setq auto-revert--lockout-interval 0.05) 152 (customize-set-variable 'auto-revert-interval 0.1)
153 (setq auto-revert--lockout-interval 0.05))
141 ,@body) 154 ,@body)
142 (customize-set-variable 'auto-revert-interval auto-revert-interval-orig) 155 (customize-set-variable 'auto-revert-interval auto-revert-interval-orig)
143 (setq auto-revert--lockout-interval auto-revert--lockout-interval-orig)))) 156 (setq auto-revert--lockout-interval auto-revert--lockout-interval-orig))))
@@ -148,6 +161,8 @@ This expects `auto-revert--messages' to be bound by
148 161
149(ert-deftest auto-revert-test00-auto-revert-mode () 162(ert-deftest auto-revert-test00-auto-revert-mode ()
150 "Check autorevert for a file." 163 "Check autorevert for a file."
164 (file-notify-rm-all-watches)
165
151 ;; `auto-revert-buffers' runs every 5". And we must wait, until the 166 ;; `auto-revert-buffers' runs every 5". And we must wait, until the
152 ;; file has been reverted. 167 ;; file has been reverted.
153 (with-auto-revert-test 168 (with-auto-revert-test
@@ -160,18 +175,30 @@ This expects `auto-revert--messages' to be bound by
160 (setq buf (find-file-noselect tmpfile)) 175 (setq buf (find-file-noselect tmpfile))
161 (with-current-buffer buf 176 (with-current-buffer buf
162 (ert-with-message-capture auto-revert--messages 177 (ert-with-message-capture auto-revert--messages
163 (should (string-equal (buffer-string) "any text")) 178 (should
179 (string-equal
180 (substring-no-properties (buffer-string)) "any text"))
164 ;; `buffer-stale--default-function' checks for 181 ;; `buffer-stale--default-function' checks for
165 ;; `verify-visited-file-modtime'. We must ensure that it 182 ;; `verify-visited-file-modtime'. We must ensure that it
166 ;; returns nil. 183 ;; returns nil. We also clean up.
167 (auto-revert-mode 1) 184 (auto-revert-mode 1)
168 (should auto-revert-mode) 185 (should auto-revert-mode)
186 ;; There was already an initial call of
187 ;; `auto-revert-handler', which locks file
188 ;; notification. Reset this lock.
189 (setq auto-revert--last-time 0)
190 (auto-revert-test--wait-for
191 (lambda () (null auto-revert--lockout-timer))
192 (auto-revert--timeout))
169 193
170 (auto-revert-tests--write-file "another text" tmpfile (pop times)) 194 (auto-revert-tests--write-file
195 "another text" tmpfile (pop times))
171 196
172 ;; Check, that the buffer has been reverted. 197 ;; Check, that the buffer has been reverted.
173 (auto-revert--wait-for-revert buf)) 198 (auto-revert--wait-for-revert buf))
174 (should (string-match "another text" (buffer-string))) 199 (should
200 (string-match-p
201 "another text" (substring-no-properties (buffer-string))))
175 202
176 ;; When the buffer is modified, it shall not be reverted. 203 ;; When the buffer is modified, it shall not be reverted.
177 (ert-with-message-capture auto-revert--messages 204 (ert-with-message-capture auto-revert--messages
@@ -180,7 +207,9 @@ This expects `auto-revert--messages' to be bound by
180 207
181 ;; Check, that the buffer hasn't been reverted. 208 ;; Check, that the buffer hasn't been reverted.
182 (auto-revert--wait-for-revert buf)) 209 (auto-revert--wait-for-revert buf))
183 (should-not (string-match "any text" (buffer-string))))) 210 (should-not
211 (string-match-p
212 "any text" (substring-no-properties (buffer-string))))))
184 213
185 ;; Exit. 214 ;; Exit.
186 (ignore-errors 215 (ignore-errors
@@ -194,27 +223,35 @@ This expects `auto-revert--messages' to be bound by
194(ert-deftest auto-revert-test01-auto-revert-several-files () 223(ert-deftest auto-revert-test01-auto-revert-several-files ()
195 "Check autorevert for several files at once." 224 "Check autorevert for several files at once."
196 (skip-unless (executable-find "cp" (file-remote-p temporary-file-directory))) 225 (skip-unless (executable-find "cp" (file-remote-p temporary-file-directory)))
226 (file-notify-rm-all-watches)
197 227
198 (ert-with-temp-directory tmpdir1 228 (with-auto-revert-test
199 (ert-with-temp-directory tmpdir2 229 (ert-with-temp-directory tmpdir1
200 (ert-with-temp-file tmpfile1 230 :prefix "auto-revert-test-parent"
201 :prefix (expand-file-name "auto-revert-test" tmpdir1) 231 (ert-with-temp-directory tmpdir2
202 (ert-with-temp-file tmpfile2 232 :prefix "auto-revert-test-parent"
203 :prefix (expand-file-name "auto-revert-test" tmpdir1) 233 (ert-with-temp-file tmpfile1
204 (with-auto-revert-test 234 :prefix (expand-file-name "auto-revert-test" tmpdir1)
205 (let* ((cp (executable-find "cp" (file-remote-p temporary-file-directory))) 235 (ert-with-temp-file tmpfile2
236 :prefix (expand-file-name "auto-revert-test" tmpdir1)
237 (let* ((cp (executable-find
238 "cp" (file-remote-p temporary-file-directory)))
206 (times '(120 60 30 15)) 239 (times '(120 60 30 15))
207 buf1 buf2) 240 buf1 buf2)
208 (unwind-protect 241 (unwind-protect
209 (ert-with-message-capture auto-revert--messages 242 (ert-with-message-capture auto-revert--messages
210 (auto-revert-tests--write-file "any text" tmpfile1 (pop times)) 243 (auto-revert-tests--write-file
244 "any text" tmpfile1 (pop times))
211 (setq buf1 (find-file-noselect tmpfile1)) 245 (setq buf1 (find-file-noselect tmpfile1))
212 (auto-revert-tests--write-file "any text" tmpfile2 (pop times)) 246 (auto-revert-tests--write-file
247 "any text" tmpfile2 (pop times))
213 (setq buf2 (find-file-noselect tmpfile2)) 248 (setq buf2 (find-file-noselect tmpfile2))
214 249
215 (dolist (buf (list buf1 buf2)) 250 (dolist (buf (list buf1 buf2))
216 (with-current-buffer buf 251 (with-current-buffer buf
217 (should (string-equal (buffer-string) "any text")) 252 (should
253 (string-equal
254 (substring-no-properties (buffer-string)) "any text"))
218 ;; `buffer-stale--default-function' checks for 255 ;; `buffer-stale--default-function' checks for
219 ;; `verify-visited-file-modtime'. We must ensure that 256 ;; `verify-visited-file-modtime'. We must ensure that
220 ;; it returns nil. 257 ;; it returns nil.
@@ -236,14 +273,17 @@ This expects `auto-revert--messages' to be bound by
236 ;; The following shell command is not portable on all 273 ;; The following shell command is not portable on all
237 ;; platforms, unfortunately. 274 ;; platforms, unfortunately.
238 (shell-command 275 (shell-command
239 (format "%s -f %s/* %s" 276 (format "%s -f %s/* %s" cp
240 cp (file-local-name tmpdir2) (file-local-name tmpdir1))) 277 (file-local-name tmpdir2) (file-local-name tmpdir1)))
241 278
242 ;; Check, that the buffers have been reverted. 279 ;; Check, that the buffers have been reverted.
243 (dolist (buf (list buf1 buf2)) 280 (dolist (buf (list buf1 buf2))
244 (with-current-buffer buf 281 (with-current-buffer buf
245 (auto-revert--wait-for-revert buf) 282 (auto-revert--wait-for-revert buf)
246 (should (string-match "another text" (buffer-string)))))) 283 (should
284 (string-match-p
285 "another text"
286 (substring-no-properties (buffer-string)))))))
247 287
248 ;; Exit. 288 ;; Exit.
249 (ignore-errors 289 (ignore-errors
@@ -257,16 +297,11 @@ This expects `auto-revert--messages' to be bound by
257;; This is inspired by Bug#23276. 297;; This is inspired by Bug#23276.
258(ert-deftest auto-revert-test02-auto-revert-deleted-file () 298(ert-deftest auto-revert-test02-auto-revert-deleted-file ()
259 "Check autorevert for a deleted file." 299 "Check autorevert for a deleted file."
260 ;; Repeated unpredictable failures, bug#32645. 300 (file-notify-rm-all-watches)
261 :tags '(:unstable) 301
262 ;; Unlikely to be hydra-specific?
263 ;; (skip-when (getenv "EMACS_HYDRA_CI"))
264 (with-auto-revert-test 302 (with-auto-revert-test
265 (ert-with-temp-file tmpfile 303 (ert-with-temp-file tmpfile
266 (let (;; Try to catch bug#32645. 304 (let ((times '(120 60 30 15))
267 (auto-revert-debug (getenv "EMACS_HYDRA_CI"))
268 (file-notify-debug (getenv "EMACS_HYDRA_CI"))
269 (times '(120 60 30 15))
270 buf desc) 305 buf desc)
271 (unwind-protect 306 (unwind-protect
272 (progn 307 (progn
@@ -275,7 +310,9 @@ This expects `auto-revert--messages' to be bound by
275 (with-current-buffer buf 310 (with-current-buffer buf
276 (should-not 311 (should-not
277 (file-notify-valid-p auto-revert-notify-watch-descriptor)) 312 (file-notify-valid-p auto-revert-notify-watch-descriptor))
278 (should (string-equal (buffer-string) "any text")) 313 (should
314 (string-equal
315 (substring-no-properties (buffer-string)) "any text"))
279 ;; `buffer-stale--default-function' checks for 316 ;; `buffer-stale--default-function' checks for
280 ;; `verify-visited-file-modtime'. We must ensure that 317 ;; `verify-visited-file-modtime'. We must ensure that
281 ;; it returns nil. 318 ;; it returns nil.
@@ -289,51 +326,47 @@ This expects `auto-revert--messages' to be bound by
289 'before-revert-hook 326 'before-revert-hook
290 (lambda () 327 (lambda ()
291 (when auto-revert-debug 328 (when auto-revert-debug
292 (message "%s deleted" buffer-file-name)) 329 (message "before-revert-hook %s deleted" buffer-file-name))
293 (delete-file buffer-file-name)) 330 (delete-file buffer-file-name))
294 nil t) 331 nil t)
295 332
296 (ert-with-message-capture auto-revert--messages 333 (ert-with-message-capture auto-revert--messages
297 (auto-revert-tests--write-file "another text" tmpfile (pop times)) 334 (auto-revert-tests--write-file
335 "another text" tmpfile (pop times))
298 (should (eq desc auto-revert-notify-watch-descriptor)) 336 (should (eq desc auto-revert-notify-watch-descriptor))
299 (auto-revert--wait-for-revert buf)) 337 (auto-revert--wait-for-revert buf))
300 ;; Check, that the buffer hasn't been reverted. File 338 ;; Check, that the buffer hasn't been reverted. File
301 ;; notification should be disabled, falling back to 339 ;; notification should be disabled, falling back to
302 ;; polling. 340 ;; polling.
303 (should (string-match "any text" (buffer-string))) 341 (should
304 ;; With w32notify, and on emba, the `stopped' events are not sent. 342 (string-match-p
305 (or (eq file-notify--library 'w32notify) 343 "any text" (substring-no-properties (buffer-string))))
306 (getenv "EMACS_EMBA_CI")
307 (should-not
308 ;; The auto-revert timer is wont to establish a new
309 ;; watch soon after the previous descriptor is
310 ;; destroyed, which not unnaturally interferes with
311 ;; our testing for its destruction, since descriptor
312 ;; IDs are reused. Therefore, test the identity of
313 ;; the previous descriptor, not just its validity.
314 (and (eq desc auto-revert-notify-watch-descriptor)
315 (file-notify-valid-p auto-revert-notify-watch-descriptor))))
316 344
317 ;; Once the file has been recreated, the buffer shall be 345 ;; Once the file has been recreated, the buffer shall be
318 ;; reverted. 346 ;; reverted.
319 (kill-local-variable 'before-revert-hook) 347 (kill-local-variable 'before-revert-hook)
320 (ert-with-message-capture auto-revert--messages 348 (ert-with-message-capture auto-revert--messages
321 (auto-revert-tests--write-file "another text" tmpfile (pop times)) 349 (auto-revert-tests--write-file
350 "another text" tmpfile (pop times))
322 (auto-revert--wait-for-revert buf)) 351 (auto-revert--wait-for-revert buf))
323 ;; Check, that the buffer has been reverted. 352 ;; Check, that the buffer has been reverted.
324 (should (string-match "another text" (buffer-string))) 353 (should
354 (string-match-p
355 "another text" (substring-no-properties (buffer-string))))
325 ;; When file notification is used, it must be reenabled 356 ;; When file notification is used, it must be reenabled
326 ;; after recreation of the file. We cannot expect that 357 ;; after recreation of the file. We cannot expect that
327 ;; the descriptor is the same, so we just check the 358 ;; the descriptor is the same, so we just check the
328 ;; existence. 359 ;; existence.
329 (should (eq (null desc) (null auto-revert-notify-watch-descriptor))) 360 (should
361 (eq (null desc) (null auto-revert-notify-watch-descriptor)))
330 362
331 ;; An empty file shall still be reverted. 363 ;; An empty file shall still be reverted.
332 (ert-with-message-capture auto-revert--messages 364 (ert-with-message-capture auto-revert--messages
333 (auto-revert-tests--write-file "" tmpfile (pop times)) 365 (auto-revert-tests--write-file "" tmpfile (pop times))
334 (auto-revert--wait-for-revert buf)) 366 (auto-revert--wait-for-revert buf))
335 ;; Check, that the buffer has been reverted. 367 ;; Check, that the buffer has been reverted.
336 (should (string-equal "" (buffer-string))))) 368 (should
369 (string-equal "" (substring-no-properties (buffer-string))))))
337 370
338 ;; Exit. 371 ;; Exit.
339 (ignore-errors 372 (ignore-errors
@@ -345,6 +378,9 @@ This expects `auto-revert--messages' to be bound by
345 378
346(ert-deftest auto-revert-test03-auto-revert-tail-mode () 379(ert-deftest auto-revert-test03-auto-revert-tail-mode ()
347 "Check autorevert tail mode." 380 "Check autorevert tail mode."
381 (file-notify-rm-all-watches)
382
383 (with-auto-revert-test
348 ;; `auto-revert-buffers' runs every 5". And we must wait, until the 384 ;; `auto-revert-buffers' runs every 5". And we must wait, until the
349 ;; file has been reverted. 385 ;; file has been reverted.
350 (ert-with-temp-file tmpfile 386 (ert-with-temp-file tmpfile
@@ -365,69 +401,90 @@ This expects `auto-revert--messages' to be bound by
365 (set-buffer-modified-p nil) 401 (set-buffer-modified-p nil)
366 402
367 ;; Modify file. 403 ;; Modify file.
368 (auto-revert-tests--write-file "another text" tmpfile (pop times) 'append) 404 (auto-revert-tests--write-file
405 "another text" tmpfile (pop times) 'append)
369 406
370 ;; Check, that the buffer has been reverted. 407 ;; Check, that the buffer has been reverted.
371 (auto-revert--wait-for-revert buf) 408 (auto-revert--wait-for-revert buf)
372 (should 409 (should
373 (string-match "modified text\nanother text" (buffer-string))))) 410 (string-match-p
411 "modified text\nanother text"
412 (substring-no-properties (buffer-string))))))
374 413
375 ;; Exit. 414 ;; Exit.
376 (ignore-errors (kill-buffer buf)))))) 415 (ignore-errors (kill-buffer buf)))))))
377 416
378(auto-revert--deftest-remote auto-revert-test03-auto-revert-tail-mode 417(auto-revert--deftest-remote auto-revert-test03-auto-revert-tail-mode
379 "Check remote autorevert tail mode.") 418 "Check remote autorevert tail mode.")
380 419
381(ert-deftest auto-revert-test04-auto-revert-mode-dired () 420(ert-deftest auto-revert-test04-auto-revert-mode-dired ()
382 "Check autorevert for dired." 421 "Check autorevert for dired."
422 (file-notify-rm-all-watches)
423
383 ;; `auto-revert-buffers' runs every 5". And we must wait, until the 424 ;; `auto-revert-buffers' runs every 5". And we must wait, until the
384 ;; file has been reverted. 425 ;; file has been reverted.
385 (with-auto-revert-test 426 (with-auto-revert-test
386 (ert-with-temp-file tmpfile 427 (ert-with-temp-directory tmpdir
387 (let* ((name (file-name-nondirectory tmpfile)) 428 :prefix "auto-revert-test-parent"
388 (times '(30)) 429 (ert-with-temp-file tmpfile
389 buf) 430 :prefix (expand-file-name "auto-revert-test" tmpdir)
390 (unwind-protect 431 (let* ((name (file-name-nondirectory tmpfile))
391 (progn 432 (times '(30))
392 (setq buf (dired-noselect temporary-file-directory)) 433 buf)
393 (with-current-buffer buf 434 (unwind-protect
394 ;; `buffer-stale--default-function' checks for 435 (progn
395 ;; `verify-visited-file-modtime'. We must ensure that it 436 (setq buf (dired-noselect tmpdir))
396 ;; returns nil. 437 (with-current-buffer buf
397 (auto-revert-mode 1) 438 ;; `buffer-stale--default-function' checks for
398 (should auto-revert-mode) 439 ;; `verify-visited-file-modtime'. We must ensure that
399 (should 440 ;; it returns nil.
400 (string-match name (substring-no-properties (buffer-string)))) 441 (auto-revert-mode 1)
401 ;; If we don't sleep for a while, this test fails on 442 (should auto-revert-mode)
402 ;; MS-Windows. 443 (should
403 (if (eq system-type 'windows-nt) 444 (string-match-p
404 (sleep-for 0.5)) 445 (rx bow (literal name) eow)
405 446 (substring-no-properties (buffer-string))))
406 (ert-with-message-capture auto-revert--messages 447 ;; If we don't sleep for a while, this test fails on
407 ;; Delete file. 448 ;; MS-Windows.
408 (delete-file tmpfile) 449 (if (eq system-type 'windows-nt)
409 (auto-revert--wait-for-revert buf)) 450 (sleep-for 0.5))
410 (if (eq system-type 'windows-nt) 451
411 (sleep-for 1)) 452 ;; File stamps of remote files have an accuracy of 1
412 ;; Check, that the buffer has been reverted. 453 ;; second. Wait a little bit.
413 (should-not 454 (when (file-remote-p tmpfile)
414 (string-match name (substring-no-properties (buffer-string)))) 455 (sleep-for (auto-revert--timeout)))
415 456 (ert-with-message-capture auto-revert--messages
416 (ert-with-message-capture auto-revert--messages 457 ;; Delete file.
417 ;; Make dired buffer modified. Check, that the buffer has 458 (delete-file tmpfile)
418 ;; been still reverted. 459 (auto-revert--wait-for-revert buf))
419 (set-buffer-modified-p t) 460 (if (eq system-type 'windows-nt)
420 (auto-revert-tests--write-file "any text" tmpfile (pop times)) 461 (sleep-for 1))
462 ;; Check, that the buffer has been reverted.
463 (should-not
464 (string-match-p
465 (rx bow (literal name) eow)
466 (substring-no-properties (buffer-string))))
467
468 ;; File stamps of remote files have an accuracy of 1
469 ;; second. Wait a little bit.
470 (when (file-remote-p tmpfile)
471 (sleep-for (auto-revert--timeout)))
472 (ert-with-message-capture auto-revert--messages
473 ;; Make dired buffer modified. Check, that the
474 ;; buffer has been still reverted.
475 (set-buffer-modified-p t)
476 (auto-revert-tests--write-file "any text" tmpfile (pop times))
477 (auto-revert--wait-for-revert buf))
478 ;; Check, that the buffer has been reverted.
479 (should
480 (string-match-p
481 (rx bow (literal name) eow)
482 (substring-no-properties (buffer-string))))))
421 483
422 (auto-revert--wait-for-revert buf)) 484 ;; Exit.
423 ;; Check, that the buffer has been reverted. 485 (ignore-errors
424 (should 486 (with-current-buffer buf (set-buffer-modified-p nil))
425 (string-match name (substring-no-properties (buffer-string)))))) 487 (kill-buffer buf))))))))
426
427 ;; Exit.
428 (ignore-errors
429 (with-current-buffer buf (set-buffer-modified-p nil))
430 (kill-buffer buf)))))))
431 488
432(auto-revert--deftest-remote auto-revert-test04-auto-revert-mode-dired 489(auto-revert--deftest-remote auto-revert-test04-auto-revert-mode-dired
433 "Check remote autorevert for dired.") 490 "Check remote autorevert for dired.")
@@ -439,7 +496,7 @@ This expects `auto-revert--messages' to be bound by
439(defun auto-revert-test--buffer-string (buffer) 496(defun auto-revert-test--buffer-string (buffer)
440 "Contents of BUFFER as a string." 497 "Contents of BUFFER as a string."
441 (with-current-buffer buffer 498 (with-current-buffer buffer
442 (buffer-string))) 499 (substring-no-properties (buffer-string))))
443 500
444(defun auto-revert-test--wait-for (pred max-wait) 501(defun auto-revert-test--wait-for (pred max-wait)
445 "Wait until PRED is true, or MAX-WAIT seconds elapsed." 502 "Wait until PRED is true, or MAX-WAIT seconds elapsed."
@@ -462,13 +519,15 @@ This expects `auto-revert--messages' to be bound by
462 'kill-buffer-hook 519 'kill-buffer-hook
463 (lambda () 520 (lambda ()
464 (message 521 (message
465 "%s killed\n%s" (current-buffer) (with-output-to-string (backtrace)))) 522 "%S killed\n%s" (current-buffer) (with-output-to-string (backtrace))))
466 nil 'local)))) 523 nil 'local))))
467 524
468(ert-deftest auto-revert-test05-global-notify () 525(ert-deftest auto-revert-test05-global-notify ()
469 "Test `global-auto-revert-mode' without polling." 526 "Test `global-auto-revert-mode' without polling."
470 (skip-unless (or file-notify--library 527 (skip-unless (or file-notify--library
471 (file-remote-p temporary-file-directory))) 528 (file-remote-p temporary-file-directory)))
529 (file-notify-rm-all-watches)
530
472 (with-auto-revert-test 531 (with-auto-revert-test
473 (ert-with-temp-file file-1 532 (ert-with-temp-file file-1
474 (ert-with-temp-file file-2 533 (ert-with-temp-file file-2
@@ -484,8 +543,13 @@ This expects `auto-revert--messages' to be bound by
484 (auto-revert-test--instrument-kill-buffer-hook buf-1) 543 (auto-revert-test--instrument-kill-buffer-hook buf-1)
485 (setq buf-2 (find-file-noselect file-2)) 544 (setq buf-2 (find-file-noselect file-2))
486 (auto-revert-test--instrument-kill-buffer-hook buf-2) 545 (auto-revert-test--instrument-kill-buffer-hook buf-2)
546 ;; File stamps of remote files have an accuracy of 1
547 ;; second. Wait a little bit.
548 (when (file-remote-p file-1)
549 (sleep-for (auto-revert--timeout)))
487 (auto-revert-test--write-file "1-a" file-1) 550 (auto-revert-test--write-file "1-a" file-1)
488 (should (equal (auto-revert-test--buffer-string buf-1) "")) 551 (should
552 (string-equal (auto-revert-test--buffer-string buf-1) ""))
489 553
490 (global-auto-revert-mode 1) ; Turn it on. 554 (global-auto-revert-mode 1) ; Turn it on.
491 555
@@ -494,15 +558,20 @@ This expects `auto-revert--messages' to be bound by
494 (should (buffer-local-value 558 (should (buffer-local-value
495 'auto-revert-notify-watch-descriptor buf-2)) 559 'auto-revert-notify-watch-descriptor buf-2))
496 560
561 ;; Allow for some time to handle notification events.
562 (auto-revert-test--wait-for-buffer-text
563 buf-1 "1-a" (auto-revert--timeout))
497 ;; buf-1 should have been reverted immediately when the mode 564 ;; buf-1 should have been reverted immediately when the mode
498 ;; was enabled. 565 ;; was enabled.
499 (should (equal (auto-revert-test--buffer-string buf-1) "1-a")) 566 (should
567 (string-equal (auto-revert-test--buffer-string buf-1) "1-a"))
500 568
501 ;; Alter a file. 569 ;; Alter a file.
502 (auto-revert-test--write-file "2-a" file-2) 570 (auto-revert-test--write-file "2-a" file-2)
503 ;; Allow for some time to handle notification events. 571 ;; Allow for some time to handle notification events.
504 (auto-revert-test--wait-for-buffer-text buf-2 "2-a" 1) 572 (auto-revert-test--wait-for-buffer-text buf-2 "2-a" 1)
505 (should (equal (auto-revert-test--buffer-string buf-2) "2-a")) 573 (should
574 (string-equal (auto-revert-test--buffer-string buf-2) "2-a"))
506 575
507 ;; Visit a file, and modify it on disk. 576 ;; Visit a file, and modify it on disk.
508 (setq buf-3 (find-file-noselect file-3)) 577 (setq buf-3 (find-file-noselect file-3))
@@ -517,11 +586,13 @@ This expects `auto-revert--messages' to be bound by
517 'auto-revert-notify-watch-descriptor buf-3)) 586 'auto-revert-notify-watch-descriptor buf-3))
518 (auto-revert-test--write-file "3-a" file-3) 587 (auto-revert-test--write-file "3-a" file-3)
519 (auto-revert-test--wait-for-buffer-text buf-3 "3-a" 1) 588 (auto-revert-test--wait-for-buffer-text buf-3 "3-a" 1)
520 (should (equal (auto-revert-test--buffer-string buf-3) "3-a")) 589 (should
590 (string-equal (auto-revert-test--buffer-string buf-3) "3-a"))
521 591
522 ;; Delete a visited file, and re-create it with new contents. 592 ;; Delete a visited file, and re-create it with new contents.
523 (delete-file file-1) 593 (delete-file file-1)
524 (should (equal (auto-revert-test--buffer-string buf-1) "1-a")) 594 (should
595 (string-equal (auto-revert-test--buffer-string buf-1) "1-a"))
525 (auto-revert-test--write-file "1-b" file-1) 596 (auto-revert-test--write-file "1-b" file-1)
526 ;; Since the file is deleted, it needs at least 597 ;; Since the file is deleted, it needs at least
527 ;; `auto-revert-interval' to recognize the new file, 598 ;; `auto-revert-interval' to recognize the new file,
@@ -531,10 +602,12 @@ This expects `auto-revert--messages' to be bound by
531 (should (buffer-local-value 602 (should (buffer-local-value
532 'auto-revert-notify-watch-descriptor buf-1)) 603 'auto-revert-notify-watch-descriptor buf-1))
533 604
534 ;; Write a buffer to a new file, then modify the new file on disk. 605 ;; Write a buffer to a new file, then modify the new
606 ;; file on disk.
535 (with-current-buffer buf-2 607 (with-current-buffer buf-2
536 (write-file file-2b)) 608 (write-file file-2b))
537 (should (equal (auto-revert-test--buffer-string buf-2) "2-a")) 609 (should
610 (string-equal (auto-revert-test--buffer-string buf-2) "2-a"))
538 (auto-revert-test--write-file "2-b" file-2b) 611 (auto-revert-test--write-file "2-b" file-2b)
539 (auto-revert-test--wait-for-buffer-text 612 (auto-revert-test--wait-for-buffer-text
540 buf-2 "2-b" (auto-revert--timeout)) 613 buf-2 "2-b" (auto-revert--timeout))
@@ -557,6 +630,8 @@ This expects `auto-revert--messages' to be bound by
557 "Verify that notification follows `write-file' correctly." 630 "Verify that notification follows `write-file' correctly."
558 (skip-unless (or file-notify--library 631 (skip-unless (or file-notify--library
559 (file-remote-p temporary-file-directory))) 632 (file-remote-p temporary-file-directory)))
633 (file-notify-rm-all-watches)
634
560 (with-auto-revert-test 635 (with-auto-revert-test
561 (ert-with-temp-file file-1 636 (ert-with-temp-file file-1
562 (let* ((auto-revert-use-notify t) 637 (let* ((auto-revert-use-notify t)
@@ -574,10 +649,15 @@ This expects `auto-revert--messages' to be bound by
574 (insert "B") 649 (insert "B")
575 (write-file file-2) 650 (write-file file-2)
576 651
652 ;; File stamps of remote files have an accuracy of 1
653 ;; second. Wait a little bit.
654 (when (file-remote-p file-1)
655 (sleep-for (auto-revert--timeout)))
577 (auto-revert-test--write-file "C" file-2) 656 (auto-revert-test--write-file "C" file-2)
578 (auto-revert-test--wait-for-buffer-text 657 (auto-revert-test--wait-for-buffer-text
579 buf "C" (auto-revert--timeout)) 658 buf "C" (auto-revert--timeout))
580 (should (equal (buffer-string) "C")))) 659 (should
660 (string-equal (substring-no-properties (buffer-string)) "C"))))
581 661
582 ;; Clean up. 662 ;; Clean up.
583 (ignore-errors (kill-buffer buf)) 663 (ignore-errors (kill-buffer buf))
@@ -591,7 +671,9 @@ This expects `auto-revert--messages' to be bound by
591 "Check autorevert for several buffers visiting the same file." 671 "Check autorevert for several buffers visiting the same file."
592 (skip-unless (or file-notify--library 672 (skip-unless (or file-notify--library
593 (file-remote-p temporary-file-directory))) 673 (file-remote-p temporary-file-directory)))
594 ;; (with-auto-revert-test 674 (file-notify-rm-all-watches)
675
676 (with-auto-revert-test
595 (ert-with-temp-file tmpfile 677 (ert-with-temp-file tmpfile
596 (let ((auto-revert-use-notify t) 678 (let ((auto-revert-use-notify t)
597 (times '(120 60 30 15)) 679 (times '(120 60 30 15))
@@ -604,7 +686,9 @@ This expects `auto-revert--messages' to be bound by
604 (auto-revert-tests--write-file "any text" tmpfile (pop times)) 686 (auto-revert-tests--write-file "any text" tmpfile (pop times))
605 (push (find-file-noselect tmpfile) buffers) 687 (push (find-file-noselect tmpfile) buffers)
606 (with-current-buffer (car buffers) 688 (with-current-buffer (car buffers)
607 (should (string-equal (buffer-string) "any text")) 689 (should
690 (string-equal
691 (substring-no-properties (buffer-string)) "any text"))
608 ;; `buffer-stale--default-function' checks for 692 ;; `buffer-stale--default-function' checks for
609 ;; `verify-visited-file-modtime'. We must ensure that 693 ;; `verify-visited-file-modtime'. We must ensure that
610 ;; it returns nil. 694 ;; it returns nil.
@@ -622,7 +706,9 @@ This expects `auto-revert--messages' to be bound by
622 (setq buffers (nreverse buffers)) 706 (setq buffers (nreverse buffers))
623 (dolist (buf buffers) 707 (dolist (buf buffers)
624 (with-current-buffer buf 708 (with-current-buffer buf
625 (should (string-equal (buffer-string) "any text")) 709 (should
710 (string-equal
711 (substring-no-properties (buffer-string)) "any text"))
626 (if (string-suffix-p "-nil" (buffer-name buf)) 712 (if (string-suffix-p "-nil" (buffer-name buf))
627 (should-not auto-revert-mode) 713 (should-not auto-revert-mode)
628 (should auto-revert-mode)))) 714 (should auto-revert-mode))))
@@ -632,7 +718,9 @@ This expects `auto-revert--messages' to be bound by
632 (auto-revert--wait-for-revert (car buffers)) 718 (auto-revert--wait-for-revert (car buffers))
633 (dolist (buf buffers) 719 (dolist (buf buffers)
634 (with-current-buffer buf 720 (with-current-buffer buf
635 (should (string-equal (buffer-string) "another text")))) 721 (should
722 (string-equal
723 (substring-no-properties (buffer-string)) "another text"))))
636 724
637 ;; Disabling autorevert in an indirect buffer does not 725 ;; Disabling autorevert in an indirect buffer does not
638 ;; disable autorevert in the corresponding base buffer. 726 ;; disable autorevert in the corresponding base buffer.
@@ -677,7 +765,9 @@ This expects `auto-revert--messages' to be bound by
677 (dolist (buf buffers) 765 (dolist (buf buffers)
678 (with-current-buffer buf 766 (with-current-buffer buf
679 (insert-file-contents tmpfile 'visit) 767 (insert-file-contents tmpfile 'visit)
680 (should (string-equal (buffer-string) "any text")) 768 (should
769 (string-equal
770 (substring-no-properties (buffer-string)) "any text"))
681 (auto-revert-mode 1) 771 (auto-revert-mode 1)
682 (should auto-revert-mode))) 772 (should auto-revert-mode)))
683 773
@@ -686,19 +776,23 @@ This expects `auto-revert--messages' to be bound by
686 (dolist (buf buffers) 776 (dolist (buf buffers)
687 (auto-revert--wait-for-revert buf) 777 (auto-revert--wait-for-revert buf)
688 (with-current-buffer buf 778 (with-current-buffer buf
689 (should (string-equal (buffer-string) "another text"))))) 779 (should
780 (string-equal
781 (substring-no-properties (buffer-string)) "another text")))))
690 782
691 ;; Exit. 783 ;; Exit.
692 (ignore-errors 784 (ignore-errors
693 (dolist (buf buffers) 785 (dolist (buf buffers)
694 (with-current-buffer buf (set-buffer-modified-p nil)) 786 (with-current-buffer buf (set-buffer-modified-p nil))
695 (kill-buffer buf)))))));) 787 (kill-buffer buf))))))))
696 788
697(auto-revert--deftest-remote auto-revert-test07-auto-revert-several-buffers 789(auto-revert--deftest-remote auto-revert-test07-auto-revert-several-buffers
698 "Check autorevert for several buffers visiting the same remote file.") 790 "Check autorevert for several buffers visiting the same remote file.")
699 791
700(ert-deftest auto-revert-test08-auto-revert-inhibit-auto-revert () 792(ert-deftest auto-revert-test08-auto-revert-inhibit-auto-revert ()
701 "Check the power of `inhibit-auto-revert'." 793 "Check the power of `inhibit-auto-revert'."
794 (file-notify-rm-all-watches)
795
702 ;; `auto-revert-buffers' runs every 5". And we must wait, until the 796 ;; `auto-revert-buffers' runs every 5". And we must wait, until the
703 ;; file has been reverted. 797 ;; file has been reverted.
704 (with-auto-revert-test 798 (with-auto-revert-test
@@ -715,14 +809,19 @@ This expects `auto-revert--messages' to be bound by
715 (auto-revert-mode 1) 809 (auto-revert-mode 1)
716 (should auto-revert-mode) 810 (should auto-revert-mode)
717 811
718 (auto-revert-tests--write-file "another text" tmpfile (pop times)) 812 (auto-revert-tests--write-file
813 "another text" tmpfile (pop times))
719 ;; Check, that the buffer hasn't been reverted. 814 ;; Check, that the buffer hasn't been reverted.
720 (auto-revert--wait-for-revert buf) 815 (auto-revert--wait-for-revert buf)
721 (should-not (string-match "another text" (buffer-string)))) 816 (should-not
817 (string-match-p
818 "another text" (substring-no-properties (buffer-string)))))
722 819
723 ;; Check, that the buffer has been reverted. 820 ;; Check, that the buffer has been reverted.
724 (auto-revert--wait-for-revert buf) 821 (auto-revert--wait-for-revert buf)
725 (should (string-match "another text" (buffer-string)))))) 822 (should
823 (string-match-p
824 "another text" (substring-no-properties (buffer-string)))))))
726 825
727 ;; Exit. 826 ;; Exit.
728 (ignore-errors 827 (ignore-errors
diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el
index 1a041b0c46c..506d79ecfb3 100644
--- a/test/lisp/filenotify-tests.el
+++ b/test/lisp/filenotify-tests.el
@@ -33,11 +33,11 @@
33;; remote host, set this environment variable to "/dev/null" or 33;; remote host, set this environment variable to "/dev/null" or
34;; whatever is appropriate on your system. 34;; whatever is appropriate on your system.
35 35
36;; For the remote file-notify library, Tramp checks for the existence 36;; For the remote file-notify library, Tramp checks for the existence of
37;; of a respective command. The first command found is used. In 37;; a respective command. The first command found is used. In order to
38;; order to use a dedicated one, the environment variable 38;; use a dedicated one, the environment variable
39;; $REMOTE_FILE_NOTIFY_LIBRARY shall be set, possible values are 39;; $REMOTE_FILE_NOTIFY_LIBRARY shall be set, possible values are
40;; "inotifywait", "gio-monitor", "gvfs-monitor-dir", and "smb-notify". 40;; "inotifywait", "gio", and "smb-notify".
41 41
42;; Local file-notify libraries are auto-detected during Emacs 42;; Local file-notify libraries are auto-detected during Emacs
43;; configuration. This can be changed with a respective configuration 43;; configuration. This can be changed with a respective configuration
@@ -58,7 +58,7 @@
58 58
59;; Filter suppressed remote file-notify libraries. 59;; Filter suppressed remote file-notify libraries.
60(when (stringp (getenv "REMOTE_FILE_NOTIFY_LIBRARY")) 60(when (stringp (getenv "REMOTE_FILE_NOTIFY_LIBRARY"))
61 (dolist (lib '("inotifywait" "gio-monitor" "gvfs-monitor-dir" "smb-notify")) 61 (dolist (lib '("inotifywait" "gio" "smb-notify"))
62 (unless (string-equal (getenv "REMOTE_FILE_NOTIFY_LIBRARY") lib) 62 (unless (string-equal (getenv "REMOTE_FILE_NOTIFY_LIBRARY") lib)
63 (add-to-list 'tramp-connection-properties `(nil ,lib nil))))) 63 (add-to-list 'tramp-connection-properties `(nil ,lib nil)))))
64 64
@@ -238,9 +238,9 @@ remote host, or nil."
238 238
239(defun file-notify--test-monitor () 239(defun file-notify--test-monitor ()
240 "The used monitor for the test, as a symbol. 240 "The used monitor for the test, as a symbol.
241This returns only for (local) gfilenotify or (remote) gio library; 241This returns only for (local) gfilenotify, (remote) gio or (remote)
242otherwise it is nil. `file-notify--test-desc' must be a valid 242smb-notify libraries; otherwise it is nil. `file-notify--test-desc'
243watch descriptor." 243must be a valid watch descriptor."
244 ;; We cache the result, because after `file-notify-rm-watch', 244 ;; We cache the result, because after `file-notify-rm-watch',
245 ;; `gfile-monitor-name' does not return a proper result anymore. 245 ;; `gfile-monitor-name' does not return a proper result anymore.
246 ;; But we still need this information. So far, we know the monitors 246 ;; But we still need this information. So far, we know the monitors
@@ -277,7 +277,7 @@ watch descriptor."
277(defmacro file-notify--deftest-remote (test docstring &optional unstable) 277(defmacro file-notify--deftest-remote (test docstring &optional unstable)
278 "Define ert `TEST-remote' for remote files. 278 "Define ert `TEST-remote' for remote files.
279If UNSTABLE is non-nil, the test is tagged as `:unstable'." 279If UNSTABLE is non-nil, the test is tagged as `:unstable'."
280 (declare (indent 1)) 280 (declare (indent 1) (debug (symbolp stringp &optional form)))
281 `(ert-deftest ,(intern (concat (symbol-name test) "-remote")) () 281 `(ert-deftest ,(intern (concat (symbol-name test) "-remote")) ()
282 ,docstring 282 ,docstring
283 :tags (if ,unstable '(:expensive-test :unstable) '(:expensive-test)) 283 :tags (if ,unstable '(:expensive-test :unstable) '(:expensive-test))
@@ -285,9 +285,6 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
285 (ert-test (ert-get-test ',test)) 285 (ert-test (ert-get-test ',test))
286 vc-handled-backends) 286 vc-handled-backends)
287 (skip-unless (file-notify--test-remote-enabled)) 287 (skip-unless (file-notify--test-remote-enabled))
288 ;; These tests do not work for remote gio/GInotifyFileMonitor.
289 ;; Needs further investigation.
290 (skip-when (string-equal (file-notify--test-library) "gio"))
291 (tramp-cleanup-connection 288 (tramp-cleanup-connection
292 (tramp-dissect-file-name temporary-file-directory) t 'keep-password) 289 (tramp-dissect-file-name temporary-file-directory) t 'keep-password)
293 (file-notify--test-cleanup) 290 (file-notify--test-cleanup)
@@ -623,7 +620,7 @@ just an indicator for comparison.
623 620
624Don't wait longer than timeout seconds for the actions to be 621Don't wait longer than timeout seconds for the actions to be
625delivered." 622delivered."
626 (declare (indent 1) (debug (form body))) 623 (declare (indent 1) (debug (form &rest body)))
627 `(let* ((actions (if (consp (car ,actions)) ,actions (list ,actions))) 624 `(let* ((actions (if (consp (car ,actions)) ,actions (list ,actions)))
628 (max-length 625 (max-length
629 (apply 626 (apply
@@ -1615,7 +1612,8 @@ the file watch."
1615 "Check that file notification does not use too many resources." 1612 "Check that file notification does not use too many resources."
1616 :tags '(:expensive-test) 1613 :tags '(:expensive-test)
1617 (skip-unless (file-notify--test-local-enabled)) 1614 (skip-unless (file-notify--test-local-enabled))
1618 ;; This test is intended for kqueue only. 1615 ;; This test is intended for kqueue only. We cannot check for
1616 ;; GKqueueFileMonitor, because `file-notify--test-desc' is not set yet.
1619 (skip-unless (string-equal (file-notify--test-library) "kqueue")) 1617 (skip-unless (string-equal (file-notify--test-library) "kqueue"))
1620 1618
1621 (should 1619 (should
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index f67a33467de..8ac1d3e5a06 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -45,8 +45,8 @@
45;; might be too heavy. Setting $REMOTE_PARALLEL_PROCESSES to a proper 45;; might be too heavy. Setting $REMOTE_PARALLEL_PROCESSES to a proper
46;; value less than 10 could help. 46;; value less than 10 could help.
47 47
48;; This test suite obeys the environment variables $EMACS_HYDRA_CI and 48;; This test suite obeys the environment variable $EMACS_EMBA_CI, used
49;; $EMACS_EMBA_CI, used on the Emacs CI/CD platforms. 49;; on the Emacs CI/CD platforms.
50 50
51;; The following test tags are used: `:expensive-test', 51;; The following test tags are used: `:expensive-test',
52;; `:tramp-asynchronous-processes' and `:unstable'. 52;; `:tramp-asynchronous-processes' and `:unstable'.
@@ -60,6 +60,7 @@
60(require 'dired-aux) 60(require 'dired-aux)
61(require 'tramp) 61(require 'tramp)
62(require 'ert-x) 62(require 'ert-x)
63(require 'filenotify)
63(require 'tar-mode) 64(require 'tar-mode)
64(require 'trace) 65(require 'trace)
65(require 'vc) 66(require 'vc)
@@ -121,11 +122,7 @@
121 (unless (and (null noninteractive) (file-directory-p "~/")) 122 (unless (and (null noninteractive) (file-directory-p "~/"))
122 (setenv "HOME" temporary-file-directory)) 123 (setenv "HOME" temporary-file-directory))
123 (format "/mock::%s" temporary-file-directory))) 124 (format "/mock::%s" temporary-file-directory)))
124 "Temporary directory for remote file tests.") 125 "Temporary directory for remote file tests.")))
125
126 ;; This should happen on hydra only.
127 (when (getenv "EMACS_HYDRA_CI")
128 (add-to-list 'tramp-remote-path 'tramp-own-remote-path))))
129 126
130;; Beautify batch mode. 127;; Beautify batch mode.
131(when noninteractive 128(when noninteractive
@@ -2436,8 +2433,7 @@ This checks also `file-name-as-directory', `file-name-directory',
2436 ;; Bug#10085. 2433 ;; Bug#10085.
2437 (when (tramp--test-enabled) ;; Packages like tramp-gvfs.el might be disabled. 2434 (when (tramp--test-enabled) ;; Packages like tramp-gvfs.el might be disabled.
2438 (dolist (non-essential '(nil t)) 2435 (dolist (non-essential '(nil t))
2439 ;; We must clear `tramp-default-method'. On hydra, it is "ftp", 2436 ;; We must clear `tramp-default-method'.
2440 ;; which ruins the tests.
2441 (let ((tramp-default-method 2437 (let ((tramp-default-method
2442 (file-remote-p ert-remote-temporary-file-directory 'method)) 2438 (file-remote-p ert-remote-temporary-file-directory 'method))
2443 (host-port 2439 (host-port
@@ -5222,7 +5218,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
5222 (unwind-protect 5218 (unwind-protect
5223 (progn 5219 (progn
5224 ;; We cannot use "/bin/true" and "/bin/false"; those paths 5220 ;; We cannot use "/bin/true" and "/bin/false"; those paths
5225 ;; do not exist on hydra and on MS Windows. 5221 ;; do not exist on MS Windows.
5226 (should (zerop (process-file "true"))) 5222 (should (zerop (process-file "true")))
5227 (should-not (zerop (process-file "false"))) 5223 (should-not (zerop (process-file "false")))
5228 (should-not (zerop (process-file "binary-does-not-exist"))) 5224 (should-not (zerop (process-file "binary-does-not-exist")))
@@ -7665,7 +7661,6 @@ This requires restrictions of file name syntax."
7665(ert-deftest tramp-test41-special-characters () 7661(ert-deftest tramp-test41-special-characters ()
7666 "Check special characters in file names." 7662 "Check special characters in file names."
7667 (skip-unless (tramp--test-enabled)) 7663 (skip-unless (tramp--test-enabled))
7668 (skip-unless (not (getenv "EMACS_HYDRA_CI"))) ; SLOW ~ 245s
7669 (skip-unless (not (tramp--test-rsync-p))) 7664 (skip-unless (not (tramp--test-rsync-p)))
7670 (skip-unless (not (tramp--test-rclone-p))) 7665 (skip-unless (not (tramp--test-rclone-p)))
7671 (skip-unless (not (or (eq system-type 'darwin) (tramp--test-macos-p)))) 7666 (skip-unless (not (or (eq system-type 'darwin) (tramp--test-macos-p))))
@@ -7744,7 +7739,6 @@ This requires restrictions of file name syntax."
7744(ert-deftest tramp-test42-utf8 () 7739(ert-deftest tramp-test42-utf8 ()
7745 "Check UTF8 encoding in file names and file contents." 7740 "Check UTF8 encoding in file names and file contents."
7746 (skip-unless (tramp--test-enabled)) 7741 (skip-unless (tramp--test-enabled))
7747 (skip-unless (not (getenv "EMACS_HYDRA_CI"))) ; SLOW ~ 620s
7748 (skip-unless (not (tramp--test-container-p))) 7742 (skip-unless (not (tramp--test-container-p)))
7749 (skip-unless (not (tramp--test-rsync-p))) 7743 (skip-unless (not (tramp--test-rsync-p)))
7750 (skip-unless (not (tramp--test-scp-p))) 7744 (skip-unless (not (tramp--test-scp-p)))
@@ -7902,17 +7896,12 @@ process sentinels. They shall not disturb each other."
7902 (cond 7896 (cond
7903 ((ignore-errors 7897 ((ignore-errors
7904 (string-to-number (getenv "REMOTE_PARALLEL_PROCESSES")))) 7898 (string-to-number (getenv "REMOTE_PARALLEL_PROCESSES"))))
7905 ((getenv "EMACS_HYDRA_CI") 5)
7906 (t 10))) 7899 (t 10)))
7907 ;; PuTTY-based methods can only share up to 10 connections. 7900 ;; PuTTY-based methods can only share up to 10 connections.
7908 (tramp-use-connection-share 7901 (tramp-use-connection-share
7909 (if (and (tramp--test-putty-p) (>= number-proc 10)) 7902 (if (and (tramp--test-putty-p) (>= number-proc 10))
7910 'suppress (bound-and-true-p tramp-use-connection-share))) 7903 'suppress (bound-and-true-p tramp-use-connection-share)))
7911 ;; On hydra, timings are bad. 7904 (timer-repeat 1)
7912 (timer-repeat
7913 (cond
7914 ((getenv "EMACS_HYDRA_CI") 10)
7915 (t 1)))
7916 ;; This is when all timers start. We check inside the 7905 ;; This is when all timers start. We check inside the
7917 ;; timer function, that we don't exceed timeout. 7906 ;; timer function, that we don't exceed timeout.
7918 (timer-start (current-time)) 7907 (timer-start (current-time))
@@ -8102,6 +8091,58 @@ process sentinels. They shall not disturb each other."
8102 (delete-directory tmp-name) 8091 (delete-directory tmp-name)
8103 (delete-file (concat tmp-name ".tar.gz")))) 8092 (delete-file (concat tmp-name ".tar.gz"))))
8104 8093
8094;; More exhaustive tests are performed in filenotify-tests.el,
8095;; selector "remote".
8096(ert-deftest tramp-test46-file-notifications ()
8097 "Check that Tramp handles file notifications."
8098 (skip-unless (tramp--test-enabled))
8099
8100 (let* ((tmp-name (tramp--test-make-temp-name))
8101 ;(file-notify-debug t)
8102 (desc1
8103 (ignore-error file-notify-error
8104 (file-notify-add-watch
8105 tmp-name '(change attribute-change) #'ignore)))
8106 (desc2
8107 (ignore-error file-notify-error
8108 (file-notify-add-watch
8109 ert-remote-temporary-file-directory
8110 '(change attribute-change) #'ignore))))
8111 (skip-unless (and desc1 desc2))
8112
8113 (unwind-protect
8114 (progn
8115 (tramp--test-message "%S" desc1)
8116 (should-not (file-exists-p tmp-name))
8117 (should (file-notify-valid-p desc1))
8118 (should (file-notify-valid-p desc2))
8119
8120 ;; Create the file.
8121 (write-region "foo" nil tmp-name)
8122 (should (file-exists-p tmp-name))
8123 ;; Modify.
8124 (write-region "foo" nil tmp-name)
8125 (should (file-exists-p tmp-name))
8126 ;; Delete.
8127 (delete-file tmp-name)
8128 (should-not (file-exists-p tmp-name))
8129
8130 (while (read-event nil nil 0.1))
8131 ;; This has been stopped because the file was deleted.
8132 (should-not (file-notify-valid-p desc1))
8133
8134 ;; This is still valid.
8135 (should (file-notify-valid-p desc2))
8136 (file-notify-rm-watch desc2)
8137 (should-not (file-notify-valid-p desc2)))
8138
8139 ;; Cleanup.
8140 (ignore-errors (delete-file tmp-name))
8141 ;; `file-notify-rm-all-watches' exists since Emacs 30.1.
8142 ;; We don't want to see compiler warnings for older Emacsen.
8143 (when (fboundp 'file-notify-rm-all-watches)
8144 (with-no-warnings (file-notify-rm-all-watches))))))
8145
8105(ert-deftest tramp-test47-read-password () 8146(ert-deftest tramp-test47-read-password ()
8106 "Check Tramp password handling." 8147 "Check Tramp password handling."
8107 :tags '(:expensive-test) 8148 :tags '(:expensive-test)
@@ -8656,6 +8697,9 @@ If INTERACTIVE is non-nil, the tests are run interactively."
8656;; * Check, why direct async processes do not work for 8697;; * Check, why direct async processes do not work for
8657;; `tramp-test45-asynchronous-requests'. 8698;; `tramp-test45-asynchronous-requests'.
8658 8699
8700;; Starting with Emacs 29, use `ert-with-temp-file' and
8701;; `ert-with-temp-directory'.
8702
8659(provide 'tramp-tests) 8703(provide 'tramp-tests)
8660 8704
8661;;; tramp-tests.el ends here 8705;;; tramp-tests.el ends here