diff options
| author | Michael Albinus | 2022-02-13 20:50:51 +0100 |
|---|---|---|
| committer | Michael Albinus | 2022-02-13 20:50:51 +0100 |
| commit | bd07d4fac9da40cecf6a5936fd4b4c8ebb751586 (patch) | |
| tree | 0acd5ceaa96eed064d242d5a23bd28f9731becfc | |
| parent | fc44bc6255733fa99e00932ca515f400b9c67aec (diff) | |
| download | emacs-bd07d4fac9da40cecf6a5936fd4b4c8ebb751586.tar.gz emacs-bd07d4fac9da40cecf6a5936fd4b4c8ebb751586.zip | |
Improve Tramp's process-file implementations
* lisp/net/tramp-adb.el (tramp-adb-handle-process-file)
* lisp/net/tramp-sh.el (tramp-sh-handle-process-file):
* lisp/net/tramp-smb.el (tramp-smb-handle-process-file):
* lisp/net/tramp-sshfs.el (tramp-sshfs-handle-process-file):
Improve implementation. (Bug#53854)
* test/lisp/net/tramp-tests.el (tramp-test28-process-file)
(tramp--test-check-files, tramp-test47-unload): Extend tests.
| -rw-r--r-- | lisp/net/tramp-adb.el | 6 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 4 | ||||
| -rw-r--r-- | lisp/net/tramp-smb.el | 2 | ||||
| -rw-r--r-- | lisp/net/tramp-sshfs.el | 55 | ||||
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 126 |
5 files changed, 153 insertions, 40 deletions
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 85cd2d9bc1e..c683f4c6e8a 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el | |||
| @@ -818,7 +818,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." | |||
| 818 | (setq infile (tramp-compat-file-name-unquote (expand-file-name infile))) | 818 | (setq infile (tramp-compat-file-name-unquote (expand-file-name infile))) |
| 819 | (if (tramp-equal-remote default-directory infile) | 819 | (if (tramp-equal-remote default-directory infile) |
| 820 | ;; INFILE is on the same remote host. | 820 | ;; INFILE is on the same remote host. |
| 821 | (setq input (tramp-file-local-name infile)) | 821 | (setq input (tramp-unquote-file-local-name infile)) |
| 822 | ;; INFILE must be copied to remote host. | 822 | ;; INFILE must be copied to remote host. |
| 823 | (setq input (tramp-make-tramp-temp-file v) | 823 | (setq input (tramp-make-tramp-temp-file v) |
| 824 | tmpinput (tramp-make-tramp-file-name v input)) | 824 | tmpinput (tramp-make-tramp-file-name v input)) |
| @@ -849,7 +849,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." | |||
| 849 | (setcar (cdr destination) (expand-file-name (cadr destination))) | 849 | (setcar (cdr destination) (expand-file-name (cadr destination))) |
| 850 | (if (tramp-equal-remote default-directory (cadr destination)) | 850 | (if (tramp-equal-remote default-directory (cadr destination)) |
| 851 | ;; stderr is on the same remote host. | 851 | ;; stderr is on the same remote host. |
| 852 | (setq stderr (tramp-file-local-name (cadr destination))) | 852 | (setq stderr (tramp-unquote-file-local-name (cadr destination))) |
| 853 | ;; stderr must be copied to remote host. The temporary | 853 | ;; stderr must be copied to remote host. The temporary |
| 854 | ;; file must be deleted after execution. | 854 | ;; file must be deleted after execution. |
| 855 | (setq stderr (tramp-make-tramp-temp-file v) | 855 | (setq stderr (tramp-make-tramp-temp-file v) |
| @@ -1264,7 +1264,7 @@ connection if a previous connection has died for some reason." | |||
| 1264 | (if (zerop (length device)) | 1264 | (if (zerop (length device)) |
| 1265 | (tramp-error vec 'file-error "Device %s not connected" host)) | 1265 | (tramp-error vec 'file-error "Device %s not connected" host)) |
| 1266 | (with-tramp-progress-reporter vec 3 "Opening adb shell connection" | 1266 | (with-tramp-progress-reporter vec 3 "Opening adb shell connection" |
| 1267 | (let* ((coding-system-for-read 'utf-8-dos) ;is this correct? | 1267 | (let* ((coding-system-for-read 'utf-8-dos) ; Is this correct? |
| 1268 | (process-connection-type tramp-process-connection-type) | 1268 | (process-connection-type tramp-process-connection-type) |
| 1269 | (args (if (> (length host) 0) | 1269 | (args (if (> (length host) 0) |
| 1270 | (list "-s" device "shell") | 1270 | (list "-s" device "shell") |
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index ea089224aef..40ddf106c99 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -3118,7 +3118,7 @@ implementation will be used." | |||
| 3118 | (setq infile (tramp-compat-file-name-unquote (expand-file-name infile))) | 3118 | (setq infile (tramp-compat-file-name-unquote (expand-file-name infile))) |
| 3119 | (if (tramp-equal-remote default-directory infile) | 3119 | (if (tramp-equal-remote default-directory infile) |
| 3120 | ;; INFILE is on the same remote host. | 3120 | ;; INFILE is on the same remote host. |
| 3121 | (setq input (tramp-file-local-name infile)) | 3121 | (setq input (tramp-unquote-file-local-name infile)) |
| 3122 | ;; INFILE must be copied to remote host. | 3122 | ;; INFILE must be copied to remote host. |
| 3123 | (setq input (tramp-make-tramp-temp-file v) | 3123 | (setq input (tramp-make-tramp-temp-file v) |
| 3124 | tmpinput (tramp-make-tramp-file-name v input)) | 3124 | tmpinput (tramp-make-tramp-file-name v input)) |
| @@ -3149,7 +3149,7 @@ implementation will be used." | |||
| 3149 | (setcar (cdr destination) (expand-file-name (cadr destination))) | 3149 | (setcar (cdr destination) (expand-file-name (cadr destination))) |
| 3150 | (if (tramp-equal-remote default-directory (cadr destination)) | 3150 | (if (tramp-equal-remote default-directory (cadr destination)) |
| 3151 | ;; stderr is on the same remote host. | 3151 | ;; stderr is on the same remote host. |
| 3152 | (setq stderr (tramp-file-local-name (cadr destination))) | 3152 | (setq stderr (tramp-unquote-file-local-name (cadr destination))) |
| 3153 | ;; stderr must be copied to remote host. The temporary | 3153 | ;; stderr must be copied to remote host. The temporary |
| 3154 | ;; file must be deleted after execution. | 3154 | ;; file must be deleted after execution. |
| 3155 | (setq stderr (tramp-make-tramp-temp-file v) | 3155 | (setq stderr (tramp-make-tramp-temp-file v) |
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index 6515519680c..f52fa0a93be 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el | |||
| @@ -1284,7 +1284,7 @@ component is used as the target of the symlink." | |||
| 1284 | (setq infile (tramp-compat-file-name-unquote (expand-file-name infile))) | 1284 | (setq infile (tramp-compat-file-name-unquote (expand-file-name infile))) |
| 1285 | (if (tramp-equal-remote default-directory infile) | 1285 | (if (tramp-equal-remote default-directory infile) |
| 1286 | ;; INFILE is on the same remote host. | 1286 | ;; INFILE is on the same remote host. |
| 1287 | (setq input (tramp-file-local-name infile)) | 1287 | (setq input (tramp-unquote-file-local-name infile)) |
| 1288 | ;; INFILE must be copied to remote host. | 1288 | ;; INFILE must be copied to remote host. |
| 1289 | (setq input (tramp-make-tramp-temp-file v) | 1289 | (setq input (tramp-make-tramp-temp-file v) |
| 1290 | tmpinput (tramp-make-tramp-file-name v input)) | 1290 | tmpinput (tramp-make-tramp-file-name v input)) |
diff --git a/lisp/net/tramp-sshfs.el b/lisp/net/tramp-sshfs.el index 664dbc31b14..3f23b1a8786 100644 --- a/lisp/net/tramp-sshfs.el +++ b/lisp/net/tramp-sshfs.el | |||
| @@ -240,12 +240,13 @@ arguments to pass to the OPERATION." | |||
| 240 | (error "Implementation does not handle immediate return")) | 240 | (error "Implementation does not handle immediate return")) |
| 241 | 241 | ||
| 242 | (with-parsed-tramp-file-name (expand-file-name default-directory) nil | 242 | (with-parsed-tramp-file-name (expand-file-name default-directory) nil |
| 243 | (let ((command | 243 | (let ((coding-system-for-read 'utf-8-dos) ; Is this correct? |
| 244 | (command | ||
| 244 | (format | 245 | (format |
| 245 | "cd %s && exec %s" | 246 | "cd %s && exec %s" |
| 246 | (tramp-unquote-shell-quote-argument localname) | 247 | (tramp-unquote-shell-quote-argument localname) |
| 247 | (mapconcat #'tramp-shell-quote-argument (cons program args) " "))) | 248 | (mapconcat #'tramp-shell-quote-argument (cons program args) " "))) |
| 248 | input tmpinput) | 249 | input tmpinput stderr tmpstderr outbuf) |
| 249 | 250 | ||
| 250 | ;; Determine input. | 251 | ;; Determine input. |
| 251 | (if (null infile) | 252 | (if (null infile) |
| @@ -253,18 +254,55 @@ arguments to pass to the OPERATION." | |||
| 253 | (setq infile (tramp-compat-file-name-unquote (expand-file-name infile))) | 254 | (setq infile (tramp-compat-file-name-unquote (expand-file-name infile))) |
| 254 | (if (tramp-equal-remote default-directory infile) | 255 | (if (tramp-equal-remote default-directory infile) |
| 255 | ;; INFILE is on the same remote host. | 256 | ;; INFILE is on the same remote host. |
| 256 | (setq input (tramp-file-local-name infile)) | 257 | (setq input (tramp-unquote-file-local-name infile)) |
| 257 | ;; INFILE must be copied to remote host. | 258 | ;; INFILE must be copied to remote host. |
| 258 | (setq input (tramp-make-tramp-temp-file v) | 259 | (setq input (tramp-make-tramp-temp-file v) |
| 259 | tmpinput (tramp-make-tramp-file-name v input)) | 260 | tmpinput (tramp-make-tramp-file-name v input)) |
| 260 | (copy-file infile tmpinput t))) | 261 | (copy-file infile tmpinput t))) |
| 261 | (when input (setq command (format "%s <%s" command input))) | 262 | (when input (setq command (format "%s <%s" command input))) |
| 262 | 263 | ||
| 264 | ;; Determine output. | ||
| 265 | (cond | ||
| 266 | ;; Just a buffer. | ||
| 267 | ((bufferp destination) | ||
| 268 | (setq outbuf destination)) | ||
| 269 | ;; A buffer name. | ||
| 270 | ((stringp destination) | ||
| 271 | (setq outbuf (get-buffer-create destination))) | ||
| 272 | ;; (REAL-DESTINATION ERROR-DESTINATION) | ||
| 273 | ((consp destination) | ||
| 274 | ;; output. | ||
| 275 | (cond | ||
| 276 | ((bufferp (car destination)) | ||
| 277 | (setq outbuf (car destination))) | ||
| 278 | ((stringp (car destination)) | ||
| 279 | (setq outbuf (get-buffer-create (car destination)))) | ||
| 280 | ((car destination) | ||
| 281 | (setq outbuf (current-buffer)))) | ||
| 282 | ;; stderr. | ||
| 283 | (cond | ||
| 284 | ((stringp (cadr destination)) | ||
| 285 | (setcar (cdr destination) (expand-file-name (cadr destination))) | ||
| 286 | (if (tramp-equal-remote default-directory (cadr destination)) | ||
| 287 | ;; stderr is on the same remote host. | ||
| 288 | (setq stderr (tramp-unquote-file-local-name (cadr destination))) | ||
| 289 | ;; stderr must be copied to remote host. The temporary | ||
| 290 | ;; file must be deleted after execution. | ||
| 291 | (setq stderr (tramp-make-tramp-temp-file v) | ||
| 292 | tmpstderr (tramp-make-tramp-file-name v stderr)))) | ||
| 293 | ;; stderr to be discarded. | ||
| 294 | ((null (cadr destination)) | ||
| 295 | (setq stderr (tramp-get-remote-null-device v))))) | ||
| 296 | ;; 't | ||
| 297 | (destination | ||
| 298 | (setq outbuf (current-buffer)))) | ||
| 299 | (when stderr (setq command (format "%s 2>%s" command stderr))) | ||
| 300 | |||
| 263 | (unwind-protect | 301 | (unwind-protect |
| 264 | (apply | 302 | (apply |
| 265 | #'tramp-call-process | 303 | #'tramp-call-process |
| 266 | v (tramp-get-method-parameter v 'tramp-login-program) | 304 | v (tramp-get-method-parameter v 'tramp-login-program) |
| 267 | nil destination display | 305 | nil outbuf display |
| 268 | (tramp-expand-args | 306 | (tramp-expand-args |
| 269 | v 'tramp-login-args | 307 | v 'tramp-login-args |
| 270 | ?h (or (tramp-file-name-host v) "") | 308 | ?h (or (tramp-file-name-host v) "") |
| @@ -272,6 +310,15 @@ arguments to pass to the OPERATION." | |||
| 272 | ?p (or (tramp-file-name-port v) "") | 310 | ?p (or (tramp-file-name-port v) "") |
| 273 | ?l command)) | 311 | ?l command)) |
| 274 | 312 | ||
| 313 | ;; Synchronize stderr. | ||
| 314 | (when tmpstderr | ||
| 315 | (tramp-cleanup-connection v 'keep-debug 'keep-password) | ||
| 316 | (tramp-fuse-unmount v)) | ||
| 317 | |||
| 318 | ;; Provide error file. | ||
| 319 | (when tmpstderr | ||
| 320 | (rename-file tmpstderr (cadr destination) t)) | ||
| 321 | |||
| 275 | ;; Cleanup. We remove all file cache values for the | 322 | ;; Cleanup. We remove all file cache values for the |
| 276 | ;; connection, because the remote process could have changed | 323 | ;; connection, because the remote process could have changed |
| 277 | ;; them. | 324 | ;; them. |
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index d78e8815b25..baddcd2d7ac 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -4398,6 +4398,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4398 | (let* ((tmp-name (tramp--test-make-temp-name nil quoted)) | 4398 | (let* ((tmp-name (tramp--test-make-temp-name nil quoted)) |
| 4399 | (fnnd (file-name-nondirectory tmp-name)) | 4399 | (fnnd (file-name-nondirectory tmp-name)) |
| 4400 | (default-directory tramp-test-temporary-file-directory) | 4400 | (default-directory tramp-test-temporary-file-directory) |
| 4401 | (buffer (get-buffer-create "*tramp-tests*")) | ||
| 4401 | kill-buffer-query-functions) | 4402 | kill-buffer-query-functions) |
| 4402 | (unwind-protect | 4403 | (unwind-protect |
| 4403 | (progn | 4404 | (progn |
| @@ -4430,31 +4431,47 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4430 | (tramp--test-shell-file-name) | 4431 | (tramp--test-shell-file-name) |
| 4431 | nil nil nil "-c" "kill -2 $$"))))) | 4432 | nil nil nil "-c" "kill -2 $$"))))) |
| 4432 | 4433 | ||
| 4433 | (with-temp-buffer | 4434 | ;; Check DESTINATION. |
| 4434 | (write-region "foo" nil tmp-name) | 4435 | (dolist (destination `(nil t ,buffer)) |
| 4435 | (should (file-exists-p tmp-name)) | 4436 | (when (bufferp destination) |
| 4436 | (should (zerop (process-file "ls" nil t nil fnnd))) | 4437 | (with-current-buffer destination |
| 4437 | ;; "ls" could produce colorized output. | 4438 | (delete-region (point-min) (point-max)))) |
| 4438 | (goto-char (point-min)) | 4439 | (with-temp-buffer |
| 4439 | (while | 4440 | (write-region "foo" nil tmp-name) |
| 4440 | (re-search-forward tramp-display-escape-sequence-regexp nil t) | 4441 | (should (file-exists-p tmp-name)) |
| 4441 | (replace-match "" nil nil)) | 4442 | (should (zerop (process-file "ls" nil destination nil fnnd))) |
| 4442 | (should (string-equal (format "%s\n" fnnd) (buffer-string))) | 4443 | (with-current-buffer |
| 4443 | (should-not (get-buffer-window (current-buffer) t)) | 4444 | (if (bufferp destination) destination (current-buffer)) |
| 4445 | ;; "ls" could produce colorized output. | ||
| 4446 | (goto-char (point-min)) | ||
| 4447 | (while (re-search-forward | ||
| 4448 | tramp-display-escape-sequence-regexp nil t) | ||
| 4449 | (replace-match "" nil nil)) | ||
| 4450 | (should | ||
| 4451 | (string-equal (if destination (format "%s\n" fnnd) "") | ||
| 4452 | (buffer-string))) | ||
| 4453 | (should-not (get-buffer-window (current-buffer) t)) | ||
| 4454 | (goto-char (point-max))) | ||
| 4455 | |||
| 4456 | ;; Second run. The output must be appended. | ||
| 4457 | (should (zerop (process-file "ls" nil destination t fnnd))) | ||
| 4458 | (with-current-buffer | ||
| 4459 | (if (bufferp destination) destination (current-buffer)) | ||
| 4460 | ;; "ls" could produce colorized output. | ||
| 4461 | (goto-char (point-min)) | ||
| 4462 | (while (re-search-forward | ||
| 4463 | tramp-display-escape-sequence-regexp nil t) | ||
| 4464 | (replace-match "" nil nil)) | ||
| 4465 | (should | ||
| 4466 | (string-equal | ||
| 4467 | (if destination (format "%s\n%s\n" fnnd fnnd) "") | ||
| 4468 | (buffer-string)))) | ||
| 4444 | 4469 | ||
| 4445 | ;; Second run. The output must be appended. | 4470 | (unless (eq destination t) |
| 4446 | (goto-char (point-max)) | 4471 | (should (string-empty-p (buffer-string)))) |
| 4447 | (should (zerop (process-file "ls" nil t t fnnd))) | 4472 | ;; A non-nil DISPLAY must not raise the buffer. |
| 4448 | ;; "ls" could produce colorized output. | 4473 | (should-not (get-buffer-window (current-buffer) t)) |
| 4449 | (goto-char (point-min)) | 4474 | (delete-file tmp-name))) |
| 4450 | (while | ||
| 4451 | (re-search-forward tramp-display-escape-sequence-regexp nil t) | ||
| 4452 | (replace-match "" nil nil)) | ||
| 4453 | (should | ||
| 4454 | (string-equal (format "%s\n%s\n" fnnd fnnd) (buffer-string))) | ||
| 4455 | ;; A non-nil DISPLAY must not raise the buffer. | ||
| 4456 | (should-not (get-buffer-window (current-buffer) t)) | ||
| 4457 | (delete-file tmp-name)) | ||
| 4458 | 4475 | ||
| 4459 | ;; Check remote and local INFILE. | 4476 | ;; Check remote and local INFILE. |
| 4460 | (dolist (local '(nil t)) | 4477 | (dolist (local '(nil t)) |
| @@ -4464,10 +4481,37 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4464 | (should (file-exists-p tmp-name)) | 4481 | (should (file-exists-p tmp-name)) |
| 4465 | (should (zerop (process-file "cat" tmp-name t))) | 4482 | (should (zerop (process-file "cat" tmp-name t))) |
| 4466 | (should (string-equal "foo" (buffer-string))) | 4483 | (should (string-equal "foo" (buffer-string))) |
| 4467 | (should-not (get-buffer-window (current-buffer) t))) | 4484 | (should-not (get-buffer-window (current-buffer) t)) |
| 4468 | (delete-file tmp-name))) | 4485 | (delete-file tmp-name))) |
| 4486 | |||
| 4487 | ;; Check remote and local DESTNATION file. This isn't | ||
| 4488 | ;; implemented yet ina all file name handler backends. | ||
| 4489 | ;; (dolist (local '(nil t)) | ||
| 4490 | ;; (setq tmp-name (tramp--test-make-temp-name local quoted)) | ||
| 4491 | ;; (should | ||
| 4492 | ;; (zerop (process-file "echo" nil `(:file ,tmp-name) nil "foo"))) | ||
| 4493 | ;; (with-temp-buffer | ||
| 4494 | ;; (insert-file-contents tmp-name) | ||
| 4495 | ;; (should (string-equal "foo" (buffer-string))) | ||
| 4496 | ;; (should-not (get-buffer-window (current-buffer) t)) | ||
| 4497 | ;; (delete-file tmp-name))) | ||
| 4498 | |||
| 4499 | ;; Check remote and local STDERR. | ||
| 4500 | (dolist (local '(nil t)) | ||
| 4501 | (setq tmp-name (tramp--test-make-temp-name local quoted)) | ||
| 4502 | (should-not | ||
| 4503 | (zerop | ||
| 4504 | (process-file "cat" nil `(t ,tmp-name) nil "/does-not-exist"))) | ||
| 4505 | (with-temp-buffer | ||
| 4506 | (insert-file-contents tmp-name) | ||
| 4507 | (should | ||
| 4508 | (string-match-p | ||
| 4509 | "cat:.* No such file or directory" (buffer-string))) | ||
| 4510 | (should-not (get-buffer-window (current-buffer) t)) | ||
| 4511 | (delete-file tmp-name)))) | ||
| 4469 | 4512 | ||
| 4470 | ;; Cleanup. | 4513 | ;; Cleanup. |
| 4514 | (ignore-errors (kill-buffer buffer)) | ||
| 4471 | (ignore-errors (delete-file tmp-name)))))) | 4515 | (ignore-errors (delete-file tmp-name)))))) |
| 4472 | 4516 | ||
| 4473 | ;; Must be a command, because used as `sigusr1' handler. | 4517 | ;; Must be a command, because used as `sigusr1' handler. |
| @@ -6479,7 +6523,13 @@ This requires restrictions of file name syntax." | |||
| 6479 | ;; `default-directory' with special characters. See | 6523 | ;; `default-directory' with special characters. See |
| 6480 | ;; Bug#53846. | 6524 | ;; Bug#53846. |
| 6481 | (when (and (tramp--test-expensive-test-p) | 6525 | (when (and (tramp--test-expensive-test-p) |
| 6482 | (tramp--test-supports-processes-p)) | 6526 | (tramp--test-supports-processes-p) |
| 6527 | ;; Prior Emacs 27, `shell-file-name' was | ||
| 6528 | ;; hard coded as "/bin/sh" for remote | ||
| 6529 | ;; processes in Emacs. That doesn't work | ||
| 6530 | ;; for tramp-adb.el. | ||
| 6531 | (or (not (tramp--test-adb-p)) | ||
| 6532 | (tramp--test-emacs27-p))) | ||
| 6483 | (let ((default-directory file1)) | 6533 | (let ((default-directory file1)) |
| 6484 | (dolist (this-shell-command | 6534 | (dolist (this-shell-command |
| 6485 | (append | 6535 | (append |
| @@ -7207,17 +7257,20 @@ Since it unloads Tramp, it shall be the last test to run." | |||
| 7207 | (should (featurep 'tramp-archive)) | 7257 | (should (featurep 'tramp-archive)) |
| 7208 | ;; This unloads also tramp-archive.el and tramp-theme.el if needed. | 7258 | ;; This unloads also tramp-archive.el and tramp-theme.el if needed. |
| 7209 | (unload-feature 'tramp 'force) | 7259 | (unload-feature 'tramp 'force) |
| 7210 | ;; No Tramp feature must be left. | 7260 | |
| 7261 | ;; No Tramp feature must be left except the test packages. | ||
| 7211 | (should-not (featurep 'tramp)) | 7262 | (should-not (featurep 'tramp)) |
| 7212 | (should-not (featurep 'tramp-archive)) | 7263 | (should-not (featurep 'tramp-archive)) |
| 7213 | (should-not (featurep 'tramp-theme)) | 7264 | (should-not (featurep 'tramp-theme)) |
| 7214 | (should-not | 7265 | (should-not |
| 7215 | (all-completions | 7266 | (all-completions |
| 7216 | "tramp" (delq 'tramp-tests (delq 'tramp-archive-tests features)))) | 7267 | "tramp" (delq 'tramp-tests (delq 'tramp-archive-tests features)))) |
| 7268 | |||
| 7217 | ;; `file-name-handler-alist' must be clean. | 7269 | ;; `file-name-handler-alist' must be clean. |
| 7218 | (should-not (all-completions "tramp" (mapcar #'cdr file-name-handler-alist))) | 7270 | (should-not (all-completions "tramp" (mapcar #'cdr file-name-handler-alist))) |
| 7271 | |||
| 7219 | ;; There shouldn't be left a bound symbol, except buffer-local | 7272 | ;; There shouldn't be left a bound symbol, except buffer-local |
| 7220 | ;; variables, and autoload functions. We do not regard our test | 7273 | ;; variables, and autoloaded functions. We do not regard our test |
| 7221 | ;; symbols, and the Tramp unload hooks. | 7274 | ;; symbols, and the Tramp unload hooks. |
| 7222 | (mapatoms | 7275 | (mapatoms |
| 7223 | (lambda (x) | 7276 | (lambda (x) |
| @@ -7231,6 +7284,7 @@ Since it unloads Tramp, it shall be the last test to run." | |||
| 7231 | (not (string-match-p "unload-hook$" (symbol-name x))) | 7284 | (not (string-match-p "unload-hook$" (symbol-name x))) |
| 7232 | (not (get x 'tramp-autoload)) | 7285 | (not (get x 'tramp-autoload)) |
| 7233 | (ert-fail (format "`%s' still bound" x))))) | 7286 | (ert-fail (format "`%s' still bound" x))))) |
| 7287 | |||
| 7234 | ;; The defstruct `tramp-file-name' and all its internal functions | 7288 | ;; The defstruct `tramp-file-name' and all its internal functions |
| 7235 | ;; shall be purged. | 7289 | ;; shall be purged. |
| 7236 | (should-not (cl--find-class 'tramp-file-name)) | 7290 | (should-not (cl--find-class 'tramp-file-name)) |
| @@ -7239,6 +7293,7 @@ Since it unloads Tramp, it shall be the last test to run." | |||
| 7239 | (and (functionp x) | 7293 | (and (functionp x) |
| 7240 | (string-match-p "tramp-file-name" (symbol-name x)) | 7294 | (string-match-p "tramp-file-name" (symbol-name x)) |
| 7241 | (ert-fail (format "Structure function `%s' still exists" x))))) | 7295 | (ert-fail (format "Structure function `%s' still exists" x))))) |
| 7296 | |||
| 7242 | ;; There shouldn't be left a hook function containing a Tramp | 7297 | ;; There shouldn't be left a hook function containing a Tramp |
| 7243 | ;; function. We do not regard the Tramp unload hooks. | 7298 | ;; function. We do not regard the Tramp unload hooks. |
| 7244 | (mapatoms | 7299 | (mapatoms |
| @@ -7248,7 +7303,18 @@ Since it unloads Tramp, it shall be the last test to run." | |||
| 7248 | (not (string-match-p "unload-hook$" (symbol-name x))) | 7303 | (not (string-match-p "unload-hook$" (symbol-name x))) |
| 7249 | (consp (symbol-value x)) | 7304 | (consp (symbol-value x)) |
| 7250 | (ignore-errors (all-completions "tramp" (symbol-value x))) | 7305 | (ignore-errors (all-completions "tramp" (symbol-value x))) |
| 7251 | (ert-fail (format "Hook `%s' still contains Tramp function" x)))))) | 7306 | (ert-fail (format "Hook `%s' still contains Tramp function" x))))) |
| 7307 | |||
| 7308 | ;; There shouldn't be left an advice function from Tramp. | ||
| 7309 | (mapatoms | ||
| 7310 | (lambda (x) | ||
| 7311 | (and (functionp x) | ||
| 7312 | (advice-mapc | ||
| 7313 | (lambda (fun _symbol) | ||
| 7314 | (and (string-match-p "^tramp" (symbol-name fun)) | ||
| 7315 | (ert-fail | ||
| 7316 | (format "Function `%s' still contains Tramp advice" x)))) | ||
| 7317 | x))))) | ||
| 7252 | 7318 | ||
| 7253 | (defun tramp-test-all (&optional interactive) | 7319 | (defun tramp-test-all (&optional interactive) |
| 7254 | "Run all tests for \\[tramp]. | 7320 | "Run all tests for \\[tramp]. |