diff options
| author | Michael Albinus | 2023-04-26 18:06:39 +0200 |
|---|---|---|
| committer | Michael Albinus | 2023-04-26 18:06:39 +0200 |
| commit | 022f50ebe616e04bb34487a26d529ca08954d287 (patch) | |
| tree | 617a2abdf09c7f17931a850f9e53709f7327b9f6 /test | |
| parent | d07815a7cc3540201afa06e3c80c061e9f497815 (diff) | |
| download | emacs-022f50ebe616e04bb34487a26d529ca08954d287.tar.gz emacs-022f50ebe616e04bb34487a26d529ca08954d287.zip | |
New command 'tramp-cleanup-some-buffers'
* doc/misc/tramp.texi (Cleanup remote connections):
Document tramp-cleanup-some-buffers and
tramp-cleanup-some-buffers-hook.
* etc/NEWS: New command 'tramp-cleanup-some-buffers'.
* lisp/net/tramp.el (tramp-handle-make-process):
* lisp/net/tramp-adb.el (tramp-adb-handle-make-process):
* lisp/net/tramp-sh.el (tramp-sh-handle-make-process):
Use `tramp-taint-remote-process-buffer'.
* lisp/net/tramp.el (tramp-post-process-creation): New defun.
(tramp-handle-make-process):
* lisp/net/tramp-adb.el (tramp-adb-maybe-open-connection):
* lisp/net/tramp-crypt.el (tramp-crypt-maybe-open-connection):
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-file-notify-add-watch)
(tramp-gvfs-maybe-open-connection):
* lisp/net/tramp-rclone.el (tramp-rclone-maybe-open-connection):
* lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band)
(tramp-sh-handle-file-notify-add-watch)
(tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-handle-copy-directory)
(tramp-smb-handle-file-acl, tramp-smb-handle-set-file-acl)
(tramp-smb-maybe-open-connection):
* lisp/net/tramp-sshfs.el (tramp-sshfs-maybe-open-connection):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-maybe-open-connection)
(tramp-sudoedit-send-command): Use it.
* lisp/net/tramp-cmds.el (tramp-tainted-remote-process-buffers):
New defvar.
(tramp-cleanup-dired-buffer-p)
(tramp-delete-tainted-remote-process-buffer-function)
(kill-buffer-hook, tramp-cleanup-remote-process-p)
(tramp-cleanup-some-buffers): New defuns.
(tramp-cleanup-some-buffers-hook): New defcustom. Add
`buffer-file-name', `tramp-cleanup-dired-buffer-p' and
`tramp-cleanup-remote-process-p' to the hook.
(kill-buffer-hook):
Add `tramp-delete-tainted-remote-process-buffer-function'.
(tramp-cleanup-all-buffers): Rework.
* lisp/net/tramp-compat.el (tramp-compat-always): New defalias.
* test/lisp/net/tramp-tests.el (tramp--test-always): Delete.
(tramp-test10-write-region, tramp-test21-file-links)
(tramp--test-deftest-direct-async-process)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-lock-file-name)
(tramp-test39-detect-external-change): Use `tramp-compat-always'.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 9bca6a03754..5fde783087e 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -297,16 +297,6 @@ is greater than 10. | |||
| 297 | (tramp--test-message | 297 | (tramp--test-message |
| 298 | "%s %f sec" ,message (float-time (time-subtract nil start)))))) | 298 | "%s %f sec" ,message (float-time (time-subtract nil start)))))) |
| 299 | 299 | ||
| 300 | ;; `always' is introduced with Emacs 28.1. | ||
| 301 | (defalias 'tramp--test-always | ||
| 302 | (if (fboundp 'always) | ||
| 303 | #'always | ||
| 304 | (lambda (&rest _arguments) | ||
| 305 | "Do nothing and return t. | ||
| 306 | This function accepts any number of ARGUMENTS, but ignores them. | ||
| 307 | Also see `ignore'." | ||
| 308 | t))) | ||
| 309 | |||
| 310 | (ert-deftest tramp-test00-availability () | 300 | (ert-deftest tramp-test00-availability () |
| 311 | "Test availability of Tramp functions." | 301 | "Test availability of Tramp functions." |
| 312 | :expected-result (if (tramp--test-enabled) :passed :failed) | 302 | :expected-result (if (tramp--test-enabled) :passed :failed) |
| @@ -2563,9 +2553,9 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 2563 | ;; `tramp-test39-make-lock-file-name'. | 2553 | ;; `tramp-test39-make-lock-file-name'. |
| 2564 | 2554 | ||
| 2565 | ;; Do not overwrite if excluded. | 2555 | ;; Do not overwrite if excluded. |
| 2566 | (cl-letf (((symbol-function #'y-or-n-p) #'tramp--test-always) | 2556 | (cl-letf (((symbol-function #'y-or-n-p) #'tramp-compat-always) |
| 2567 | ;; Ange-FTP. | 2557 | ;; Ange-FTP. |
| 2568 | ((symbol-function 'yes-or-no-p) #'tramp--test-always)) | 2558 | ((symbol-function 'yes-or-no-p) #'tramp-compat-always)) |
| 2569 | (write-region "foo" nil tmp-name nil nil nil 'mustbenew)) | 2559 | (write-region "foo" nil tmp-name nil nil nil 'mustbenew)) |
| 2570 | (should-error | 2560 | (should-error |
| 2571 | (cl-letf (((symbol-function #'y-or-n-p) #'ignore) | 2561 | (cl-letf (((symbol-function #'y-or-n-p) #'ignore) |
| @@ -3991,7 +3981,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 3991 | (should-error | 3981 | (should-error |
| 3992 | (make-symbolic-link tmp-name1 tmp-name2 0) | 3982 | (make-symbolic-link tmp-name1 tmp-name2 0) |
| 3993 | :type 'file-already-exists))) | 3983 | :type 'file-already-exists))) |
| 3994 | (cl-letf (((symbol-function #'yes-or-no-p) #'tramp--test-always)) | 3984 | (cl-letf (((symbol-function #'yes-or-no-p) #'tramp-compat-always)) |
| 3995 | (make-symbolic-link tmp-name1 tmp-name2 0) | 3985 | (make-symbolic-link tmp-name1 tmp-name2 0) |
| 3996 | (should | 3986 | (should |
| 3997 | (string-equal | 3987 | (string-equal |
| @@ -4071,7 +4061,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4071 | (should-error | 4061 | (should-error |
| 4072 | (add-name-to-file tmp-name1 tmp-name2 0) | 4062 | (add-name-to-file tmp-name1 tmp-name2 0) |
| 4073 | :type 'file-already-exists)) | 4063 | :type 'file-already-exists)) |
| 4074 | (cl-letf (((symbol-function #'yes-or-no-p) #'tramp--test-always)) | 4064 | (cl-letf (((symbol-function #'yes-or-no-p) #'tramp-compat-always)) |
| 4075 | (add-name-to-file tmp-name1 tmp-name2 0) | 4065 | (add-name-to-file tmp-name1 tmp-name2 0) |
| 4076 | (should (file-regular-p tmp-name2))) | 4066 | (should (file-regular-p tmp-name2))) |
| 4077 | (add-name-to-file tmp-name1 tmp-name2 'ok-if-already-exists) | 4067 | (add-name-to-file tmp-name1 tmp-name2 'ok-if-already-exists) |
| @@ -5202,7 +5192,7 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'." | |||
| 5202 | ;; `file-truename' does it by side-effect. Suppress | 5192 | ;; `file-truename' does it by side-effect. Suppress |
| 5203 | ;; `tramp--test-enabled', in order to keep the connection. | 5193 | ;; `tramp--test-enabled', in order to keep the connection. |
| 5204 | ;; Suppress "Process ... finished" messages. | 5194 | ;; Suppress "Process ... finished" messages. |
| 5205 | (cl-letf (((symbol-function #'tramp--test-enabled) #'tramp--test-always) | 5195 | (cl-letf (((symbol-function #'tramp--test-enabled) #'tramp-compat-always) |
| 5206 | ((symbol-function #'internal-default-process-sentinel) | 5196 | ((symbol-function #'internal-default-process-sentinel) |
| 5207 | #'ignore)) | 5197 | #'ignore)) |
| 5208 | (file-truename ert-remote-temporary-file-directory) | 5198 | (file-truename ert-remote-temporary-file-directory) |
| @@ -6410,7 +6400,7 @@ INPUT, if non-nil, is a string sent to the process." | |||
| 6410 | (tramp-cleanup-connection | 6400 | (tramp-cleanup-connection |
| 6411 | tramp-test-vec 'keep-debug 'keep-password) | 6401 | tramp-test-vec 'keep-debug 'keep-password) |
| 6412 | (cl-letf (((symbol-function #'yes-or-no-p) | 6402 | (cl-letf (((symbol-function #'yes-or-no-p) |
| 6413 | #'tramp--test-always)) | 6403 | #'tramp-compat-always)) |
| 6414 | (should (stringp (make-auto-save-file-name)))))))) | 6404 | (should (stringp (make-auto-save-file-name)))))))) |
| 6415 | 6405 | ||
| 6416 | ;; Cleanup. | 6406 | ;; Cleanup. |
| @@ -6556,8 +6546,7 @@ INPUT, if non-nil, is a string sent to the process." | |||
| 6556 | :type 'file-error)) | 6546 | :type 'file-error)) |
| 6557 | (tramp-cleanup-connection | 6547 | (tramp-cleanup-connection |
| 6558 | tramp-test-vec 'keep-debug 'keep-password) | 6548 | tramp-test-vec 'keep-debug 'keep-password) |
| 6559 | (cl-letf (((symbol-function #'yes-or-no-p) | 6549 | (cl-letf (((symbol-function #'yes-or-no-p) #'tramp-compat-always)) |
| 6560 | #'tramp--test-always)) | ||
| 6561 | (should (stringp (car (find-backup-file-name tmp-name1))))))) | 6550 | (should (stringp (car (find-backup-file-name tmp-name1))))))) |
| 6562 | 6551 | ||
| 6563 | ;; Cleanup. | 6552 | ;; Cleanup. |
| @@ -6712,8 +6701,7 @@ INPUT, if non-nil, is a string sent to the process." | |||
| 6712 | :type 'file-error)) | 6701 | :type 'file-error)) |
| 6713 | (tramp-cleanup-connection | 6702 | (tramp-cleanup-connection |
| 6714 | tramp-test-vec 'keep-debug 'keep-password) | 6703 | tramp-test-vec 'keep-debug 'keep-password) |
| 6715 | (cl-letf (((symbol-function #'yes-or-no-p) | 6704 | (cl-letf (((symbol-function #'yes-or-no-p) #'tramp-compat-always)) |
| 6716 | #'tramp--test-always)) | ||
| 6717 | (write-region "foo" nil tmp-name1)))) | 6705 | (write-region "foo" nil tmp-name1)))) |
| 6718 | 6706 | ||
| 6719 | ;; Cleanup. | 6707 | ;; Cleanup. |
| @@ -6783,7 +6771,8 @@ INPUT, if non-nil, is a string sent to the process." | |||
| 6783 | (should (file-locked-p tmp-name))))) | 6771 | (should (file-locked-p tmp-name))))) |
| 6784 | 6772 | ||
| 6785 | ;; `save-buffer' removes the file lock. | 6773 | ;; `save-buffer' removes the file lock. |
| 6786 | (cl-letf (((symbol-function 'yes-or-no-p) #'tramp--test-always) | 6774 | (cl-letf (((symbol-function 'yes-or-no-p) |
| 6775 | #'tramp-compat-always) | ||
| 6787 | ((symbol-function 'read-char-choice) | 6776 | ((symbol-function 'read-char-choice) |
| 6788 | (lambda (&rest _) ?y))) | 6777 | (lambda (&rest _) ?y))) |
| 6789 | (should (buffer-modified-p)) | 6778 | (should (buffer-modified-p)) |