aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMichael Albinus2023-01-06 13:34:33 +0100
committerMichael Albinus2023-01-06 13:34:33 +0100
commit6602ec3abc0804ce87d36908bca885e0b27758e5 (patch)
tree2ec2d3ce4b5e0077727bed314a0ccdf4467c389e /test
parent3fcbb865853d7c364cf7c2986ead9e258f449f97 (diff)
downloademacs-6602ec3abc0804ce87d36908bca885e0b27758e5.tar.gz
emacs-6602ec3abc0804ce87d36908bca885e0b27758e5.zip
Remove Emacs 26 compatibility from Tramp
* doc/misc/tramp.texi (Remote processes): Don't mention Emacs version. (Frequently Asked Questions): Adapt supported Emacs versions. * doc/misc/trampver.texi: * lisp/net/trampver.el: Change version to "2.7.0-pre". * lisp/net/tramp-compat.el (tramp-compat-file-name-quoted-p) (tramp-compat-file-name-quote, tramp-compat-file-name-unquote) (tramp-compat-tramp-syntax, tramp-compat-exec-path) (tramp-compat-time-equal-p, tramp-compat-flatten-tree) (tramp-compat-progress-reporter-update) (tramp-compat-ignore-error, tramp-compat-rx--transform-item) (tramp-compat-rx--transform, tramp-compat-rx): Remove. * lisp/net/tramp-adb.el: * lisp/net/tramp-archive.el: * lisp/net/tramp-cache.el: * lisp/net/tramp-cmds.el: * lisp/net/tramp-crypt.el: * lisp/net/tramp-fuse.el: * lisp/net/tramp-gvfs.el: * lisp/net/tramp-integration.el: * lisp/net/tramp-rclone.el: * lisp/net/tramp-sh.el: * lisp/net/tramp-smb.el: * lisp/net/tramp-sshfs.el: * lisp/net/tramp-sudoedit.el: * lisp/net/tramp.el: * lisp/net/trampver.el: Replace the removed `tramp-compat-*' items by their real definition. Don't use `tramp-compat-funcall' when not needed. Remove `with-no-warnings' and `ignore-errors' where appropriate. * lisp/net/tramp.el (tramp-file-name-for-operation): Rearrange list. (tramp-handle-file-newer-than-file-p): Simplify. (tramp-get-process-attributes): Don't check for existence of `connection-local-criteria-for-default-directory'. (tramp-handle-shell-command): Don't check for existence of `shell-command-save-pos-or-erase', `async-shell-command-width' and `shell-command-set-point-after-cmd'. (tramp-handle-start-file-process): Call `make-process' directly. (tramp-defined-time): New defsubst. (tramp-get-local-gid): Don't check for existence of `group-name'. * lisp/net/tramp-adb.el (tramp-adb-handle-set-file-times): Use `tramp-defined-time'. (tramp-adb-get-signal-strings): Don't bind `shell-file-name' and `shell-command-switch'. * lisp/net/tramp-archive.el (top, tramp-archive-file-name-handler): Don't bind `max-specpdl-size' any longer. (tramp-archive-autoload-file-name-regexp): Remove Emacs 26 specific code. (top): Don't call `tramp-register-archive-autoload-file-name-handler'. * lisp/net/tramp-gvfs.el (top): Don't bind `max-specpdl-size' any longer. (tramp-gvfs-handle-set-file-times): Use `tramp-defined-time'. * lisp/net/tramp-sh.el (tramp-sh-handle-set-file-times): Use `tramp-defined-time'. * test/lisp/net/tramp-archive-tests.el (tramp-archive--test-emacs27-p): Remove. (all): * test/lisp/net/tramp-tests.el (all): Don't skip for Emacs 26. Replace the removed `tramp-compat-*' items by their real definition. Don't use `tramp-compat-funcall' when not needed. Remove `with-no-warnings' and `ignore-errors' where appropriate. (with-connection-local-variables) (shell-command-dont-erase-buffer): Don't declare. (tramp-test10-write-region): Don't check for `make-empty-file'. (tramp-test32-shell-command): Simplify. (tramp-test34-explicit-shell-file-name): Don't protect `explicit-shell-file-name' any longer. (tramp--test-emacs27-p): Remove.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/net/tramp-archive-tests.el27
-rw-r--r--test/lisp/net/tramp-tests.el437
2 files changed, 157 insertions, 307 deletions
diff --git a/test/lisp/net/tramp-archive-tests.el b/test/lisp/net/tramp-archive-tests.el
index 96c1e78e37a..85766f95cda 100644
--- a/test/lisp/net/tramp-archive-tests.el
+++ b/test/lisp/net/tramp-archive-tests.el
@@ -121,12 +121,6 @@ the origin of the temporary TMPFILE, have no write permissions."
121 (directory-files tmpfile 'full directory-files-no-dot-files-regexp)) 121 (directory-files tmpfile 'full directory-files-no-dot-files-regexp))
122 (delete-directory tmpfile))) 122 (delete-directory tmpfile)))
123 123
124(defun tramp-archive--test-emacs27-p ()
125 "Check for Emacs version >= 27.1.
126Some semantics has been changed for there, without new functions or
127variables, so we check the Emacs version directly."
128 (>= emacs-major-version 27))
129
130(ert-deftest tramp-archive-test00-availability () 124(ert-deftest tramp-archive-test00-availability ()
131 "Test availability of archive file name functions." 125 "Test availability of archive file name functions."
132 :expected-result (if tramp-archive-enabled :passed :failed) 126 :expected-result (if tramp-archive-enabled :passed :failed)
@@ -615,16 +609,13 @@ This checks also `file-name-as-directory', `file-name-directory',
615 (with-temp-buffer 609 (with-temp-buffer
616 (insert-directory tramp-archive-test-archive nil) 610 (insert-directory tramp-archive-test-archive nil)
617 (goto-char (point-min)) 611 (goto-char (point-min))
618 (should 612 (should (looking-at-p (rx (literal tramp-archive-test-archive)))))
619 (looking-at-p
620 (tramp-compat-rx (literal tramp-archive-test-archive)))))
621 (with-temp-buffer 613 (with-temp-buffer
622 (insert-directory tramp-archive-test-archive "-al") 614 (insert-directory tramp-archive-test-archive "-al")
623 (goto-char (point-min)) 615 (goto-char (point-min))
624 (should 616 (should
625 (looking-at-p 617 (looking-at-p
626 (tramp-compat-rx 618 (rx bol (+ nonl) blank (literal tramp-archive-test-archive) eol))))
627 bol (+ nonl) blank (literal tramp-archive-test-archive) eol))))
628 (with-temp-buffer 619 (with-temp-buffer
629 (insert-directory 620 (insert-directory
630 (file-name-as-directory tramp-archive-test-archive) 621 (file-name-as-directory tramp-archive-test-archive)
@@ -877,12 +868,8 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
877(ert-deftest tramp-archive-test43-file-system-info () 868(ert-deftest tramp-archive-test43-file-system-info ()
878 "Check that `file-system-info' returns proper values." 869 "Check that `file-system-info' returns proper values."
879 (skip-unless tramp-archive-enabled) 870 (skip-unless tramp-archive-enabled)
880 ;; Since Emacs 27.1.
881 (skip-unless (fboundp 'file-system-info))
882 871
883 ;; `file-system-info' exists since Emacs 27. We don't want to see 872 (let ((fsi (file-system-info tramp-archive-test-archive)))
884 ;; compiler warnings for older Emacsen.
885 (let ((fsi (with-no-warnings (file-system-info tramp-archive-test-archive))))
886 (skip-unless fsi) 873 (skip-unless fsi)
887 (should (and (consp fsi) 874 (should (and (consp fsi)
888 (= (length fsi) 3) 875 (= (length fsi) 3)
@@ -895,8 +882,6 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
895 "Check that `tramp-archive' autoloads properly." 882 "Check that `tramp-archive' autoloads properly."
896 :tags '(:expensive-test) 883 :tags '(:expensive-test)
897 (skip-unless tramp-archive-enabled) 884 (skip-unless tramp-archive-enabled)
898 ;; Autoloading tramp-archive works since Emacs 27.1.
899 (skip-unless (tramp-archive--test-emacs27-p))
900 885
901 ;; tramp-archive is neither loaded at Emacs startup, nor when 886 ;; tramp-archive is neither loaded at Emacs startup, nor when
902 ;; loading a file like "/mock::foo" (which loads Tramp). 887 ;; loading a file like "/mock::foo" (which loads Tramp).
@@ -919,7 +904,7 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
919 (dolist (file `("/mock::foo" ,(concat tramp-archive-test-archive "foo"))) 904 (dolist (file `("/mock::foo" ,(concat tramp-archive-test-archive "foo")))
920 (should 905 (should
921 (string-match 906 (string-match
922 (tramp-compat-rx 907 (rx
923 "tramp-archive loaded: " 908 "tramp-archive loaded: "
924 (literal (symbol-name 909 (literal (symbol-name
925 (tramp-archive-file-name-p default-directory))) 910 (tramp-archive-file-name-p default-directory)))
@@ -942,8 +927,6 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
942 "Check that `tramp-archive' is loaded lazily, only when needed." 927 "Check that `tramp-archive' is loaded lazily, only when needed."
943 :tags '(:expensive-test) 928 :tags '(:expensive-test)
944 (skip-unless tramp-archive-enabled) 929 (skip-unless tramp-archive-enabled)
945 ;; Autoloading tramp-archive works since Emacs 27.1.
946 (skip-unless (tramp-archive--test-emacs27-p))
947 930
948 ;; tramp-archive is neither loaded at Emacs startup, nor when 931 ;; tramp-archive is neither loaded at Emacs startup, nor when
949 ;; loading a file like "/foo.tar". It is loaded only when 932 ;; loading a file like "/foo.tar". It is loaded only when
@@ -964,7 +947,7 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
964 (dolist (tae '(t nil)) 947 (dolist (tae '(t nil))
965 (should 948 (should
966 (string-match 949 (string-match
967 (tramp-compat-rx 950 (rx
968 "tramp-archive loaded: nil" (+ ascii) 951 "tramp-archive loaded: nil" (+ ascii)
969 "tramp-archive loaded: nil" (+ ascii) 952 "tramp-archive loaded: nil" (+ ascii)
970 "tramp-archive loaded: " (literal (symbol-name tae))) 953 "tramp-archive loaded: " (literal (symbol-name tae)))
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 6fb9fa1fae9..90f6fcd6b15 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -74,14 +74,10 @@
74(defvar tramp-remote-path) 74(defvar tramp-remote-path)
75(defvar tramp-remote-process-environment) 75(defvar tramp-remote-process-environment)
76 76
77;; Needed for Emacs 26.
78(declare-function with-connection-local-variables "files-x")
79;; Needed for Emacs 27. 77;; Needed for Emacs 27.
80(defvar lock-file-name-transforms) 78(defvar lock-file-name-transforms)
81(defvar process-file-return-signal-string) 79(defvar process-file-return-signal-string)
82(defvar remote-file-name-inhibit-locks) 80(defvar remote-file-name-inhibit-locks)
83(defvar shell-command-dont-erase-buffer)
84;; Needed for Emacs 28.
85(defvar dired-copy-dereference) 81(defvar dired-copy-dereference)
86 82
87;; `ert-resource-file' was introduced in Emacs 28.1. 83;; `ert-resource-file' was introduced in Emacs 28.1.
@@ -224,7 +220,7 @@ If LOCAL is non-nil, a local file name is returned.
224If QUOTED is non-nil, the local part of the file name is quoted. 220If QUOTED is non-nil, the local part of the file name is quoted.
225The temporary file is not created." 221The temporary file is not created."
226 (funcall 222 (funcall
227 (if quoted #'tramp-compat-file-name-quote #'identity) 223 (if quoted #'file-name-quote #'identity)
228 (expand-file-name 224 (expand-file-name
229 (make-temp-name "tramp-test") 225 (make-temp-name "tramp-test")
230 (if local temporary-file-directory ert-remote-temporary-file-directory)))) 226 (if local temporary-file-directory ert-remote-temporary-file-directory))))
@@ -2296,10 +2292,9 @@ This checks also `file-name-as-directory', `file-name-directory',
2296 2292
2297 ;; Check `directory-abbrev-alist' abbreviation. 2293 ;; Check `directory-abbrev-alist' abbreviation.
2298 (let ((directory-abbrev-alist 2294 (let ((directory-abbrev-alist
2299 `((,(tramp-compat-rx bos (literal home-dir) "/foo") 2295 `((,(rx bos (literal home-dir) "/foo") . ,(concat home-dir "/f"))
2300 . ,(concat home-dir "/f")) 2296 (,(rx bos (literal remote-host) "/nowhere")
2301 (,(tramp-compat-rx bos (literal remote-host) "/nowhere") 2297 . ,(concat remote-host "/nw")))))
2302 . ,(concat remote-host "/nw")))))
2303 (should (equal (abbreviate-file-name (concat home-dir "/foo/bar")) 2298 (should (equal (abbreviate-file-name (concat home-dir "/foo/bar"))
2304 (concat remote-host-nohop "~/f/bar"))) 2299 (concat remote-host-nohop "~/f/bar")))
2305 (should (equal (abbreviate-file-name 2300 (should (equal (abbreviate-file-name
@@ -2479,17 +2474,14 @@ This checks also `file-name-as-directory', `file-name-directory',
2479 (should (string-equal (buffer-string) "foo"))) 2474 (should (string-equal (buffer-string) "foo")))
2480 2475
2481 ;; Write empty string. Used for creation of temporary files. 2476 ;; Write empty string. Used for creation of temporary files.
2482 ;; Since Emacs 27.1. 2477 (should-error
2483 (when (fboundp 'make-empty-file) 2478 (make-empty-file tmp-name)
2484 (with-no-warnings 2479 :type 'file-already-exists)
2485 (should-error 2480 (delete-file tmp-name)
2486 (make-empty-file tmp-name) 2481 (make-empty-file tmp-name)
2487 :type 'file-already-exists) 2482 (with-temp-buffer
2488 (delete-file tmp-name) 2483 (insert-file-contents tmp-name)
2489 (make-empty-file tmp-name) 2484 (should (string-equal (buffer-string) "")))
2490 (with-temp-buffer
2491 (insert-file-contents tmp-name)
2492 (should (string-equal (buffer-string) "")))))
2493 2485
2494 ;; Write partly. 2486 ;; Write partly.
2495 (with-temp-buffer 2487 (with-temp-buffer
@@ -2511,8 +2503,7 @@ This checks also `file-name-as-directory', `file-name-directory',
2511 (string-match-p 2503 (string-match-p
2512 (if (and (null noninteractive) 2504 (if (and (null noninteractive)
2513 (or (eq visit t) (null visit) (stringp visit))) 2505 (or (eq visit t) (null visit) (stringp visit)))
2514 (tramp-compat-rx 2506 (rx bol "Wrote " (literal tmp-name) "\n" eos)
2515 bol "Wrote " (literal tmp-name) "\n" eos)
2516 (rx bos)) 2507 (rx bos))
2517 tramp--test-messages)))))) 2508 tramp--test-messages))))))
2518 2509
@@ -2542,8 +2533,6 @@ This checks also `file-name-as-directory', `file-name-directory',
2542 "Check that `file-precious-flag' is respected with Tramp in use." 2533 "Check that `file-precious-flag' is respected with Tramp in use."
2543 (skip-unless (tramp--test-enabled)) 2534 (skip-unless (tramp--test-enabled))
2544 (skip-unless (tramp--test-sh-p)) 2535 (skip-unless (tramp--test-sh-p))
2545 ;; The bug is fixed in Emacs 27.1.
2546 (skip-unless (tramp--test-emacs27-p))
2547 2536
2548 (let* ((tmp-name (tramp--test-make-temp-name)) 2537 (let* ((tmp-name (tramp--test-make-temp-name))
2549 (inhibit-message t) 2538 (inhibit-message t)
@@ -2626,10 +2615,7 @@ This checks also `file-name-as-directory', `file-name-directory',
2626 "Check `copy-file'." 2615 "Check `copy-file'."
2627 (skip-unless (tramp--test-enabled)) 2616 (skip-unless (tramp--test-enabled))
2628 2617
2629 ;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579. 2618 (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil)))
2630 (dolist (quoted
2631 (if (and (tramp--test-expensive-test-p) (tramp--test-emacs27-p))
2632 '(nil t) '(nil)))
2633 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted)) 2619 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
2634 (tmp-name2 (tramp--test-make-temp-name nil quoted)) 2620 (tmp-name2 (tramp--test-make-temp-name nil quoted))
2635 (tmp-name3 (tramp--test-make-temp-name 'local quoted))) 2621 (tmp-name3 (tramp--test-make-temp-name 'local quoted)))
@@ -2738,10 +2724,7 @@ This checks also `file-name-as-directory', `file-name-directory',
2738 "Check `rename-file'." 2724 "Check `rename-file'."
2739 (skip-unless (tramp--test-enabled)) 2725 (skip-unless (tramp--test-enabled))
2740 2726
2741 ;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579. 2727 (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil)))
2742 (dolist (quoted
2743 (if (and (tramp--test-expensive-test-p) (tramp--test-emacs27-p))
2744 '(nil t) '(nil)))
2745 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted)) 2728 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
2746 (tmp-name2 (tramp--test-make-temp-name nil quoted)) 2729 (tmp-name2 (tramp--test-make-temp-name nil quoted))
2747 (tmp-name3 (tramp--test-make-temp-name 'local quoted))) 2730 (tmp-name3 (tramp--test-make-temp-name 'local quoted)))
@@ -2925,13 +2908,11 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
2925 (delete-directory tmp-name1 'recursive) 2908 (delete-directory tmp-name1 'recursive)
2926 (should-not (file-directory-p tmp-name1)) 2909 (should-not (file-directory-p tmp-name1))
2927 2910
2928 ;; Trashing directories works only since Emacs 27.1. It doesn't 2911 ;; Trashing directories doesn't work when
2929 ;; work when `system-move-file-to-trash' is defined (on MS 2912 ;; `system-move-file-to-trash' is defined (on MS Windows and
2930 ;; Windows and macOS), for encrypted remote directories and for 2913 ;; macOS), for encrypted remote directories and for ange-ftp.
2931 ;; ange-ftp.
2932 (when (and (not (fboundp 'system-move-file-to-trash)) 2914 (when (and (not (fboundp 'system-move-file-to-trash))
2933 (not (tramp--test-crypt-p)) (not (tramp--test-ftp-p)) 2915 (not (tramp--test-crypt-p)) (not (tramp--test-ftp-p)))
2934 (tramp--test-emacs27-p))
2935 (let ((trash-directory (tramp--test-make-temp-name 'local quoted)) 2916 (let ((trash-directory (tramp--test-make-temp-name 'local quoted))
2936 (delete-by-moving-to-trash t)) 2917 (delete-by-moving-to-trash t))
2937 (make-directory trash-directory) 2918 (make-directory trash-directory)
@@ -3200,9 +3181,6 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
3200 ;; (this is performed by `dired'). If FULL is nil, it shows just 3181 ;; (this is performed by `dired'). If FULL is nil, it shows just
3201 ;; one file. So we refrain from testing. 3182 ;; one file. So we refrain from testing.
3202 (skip-unless (not (tramp--test-ange-ftp-p))) 3183 (skip-unless (not (tramp--test-ange-ftp-p)))
3203 ;; `insert-directory' of encrypted remote directories works only
3204 ;; since Emacs 27.1.
3205 (skip-unless (or (not (tramp--test-crypt-p)) (tramp--test-emacs27-p)))
3206 3184
3207 (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil))) 3185 (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil)))
3208 (let* ((tmp-name1 3186 (let* ((tmp-name1
@@ -3220,26 +3198,23 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
3220 (with-temp-buffer 3198 (with-temp-buffer
3221 (insert-directory tmp-name1 nil) 3199 (insert-directory tmp-name1 nil)
3222 (goto-char (point-min)) 3200 (goto-char (point-min))
3223 (should (looking-at-p (tramp-compat-rx (literal tmp-name1))))) 3201 (should (looking-at-p (rx (literal tmp-name1)))))
3224 (with-temp-buffer 3202 (with-temp-buffer
3225 (insert-directory (file-name-as-directory tmp-name1) nil) 3203 (insert-directory (file-name-as-directory tmp-name1) nil)
3226 (goto-char (point-min)) 3204 (goto-char (point-min))
3227 (should 3205 (should
3228 (looking-at-p 3206 (looking-at-p (rx (literal (file-name-as-directory tmp-name1))))))
3229 (tramp-compat-rx (literal (file-name-as-directory tmp-name1))))))
3230 (with-temp-buffer 3207 (with-temp-buffer
3231 (insert-directory tmp-name1 "-al") 3208 (insert-directory tmp-name1 "-al")
3232 (goto-char (point-min)) 3209 (goto-char (point-min))
3233 (should 3210 (should
3234 (looking-at-p 3211 (looking-at-p (rx bol (+ nonl) blank (literal tmp-name1) eol))))
3235 (tramp-compat-rx bol (+ nonl) blank (literal tmp-name1) eol))))
3236 (with-temp-buffer 3212 (with-temp-buffer
3237 (insert-directory (file-name-as-directory tmp-name1) "-al") 3213 (insert-directory (file-name-as-directory tmp-name1) "-al")
3238 (goto-char (point-min)) 3214 (goto-char (point-min))
3239 (should 3215 (should
3240 (looking-at-p 3216 (looking-at-p
3241 (tramp-compat-rx 3217 (rx bol (+ nonl) blank (literal tmp-name1) "/" eol))))
3242 bol (+ nonl) blank (literal tmp-name1) "/" eol))))
3243 (with-temp-buffer 3218 (with-temp-buffer
3244 (insert-directory 3219 (insert-directory
3245 (file-name-as-directory tmp-name1) "-al" nil 'full-directory-p) 3220 (file-name-as-directory tmp-name1) "-al" nil 'full-directory-p)
@@ -3300,7 +3275,7 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
3300 (tmp-name4 (expand-file-name "bar" tmp-name2)) 3275 (tmp-name4 (expand-file-name "bar" tmp-name2))
3301 (ert-remote-temporary-file-directory 3276 (ert-remote-temporary-file-directory
3302 (funcall 3277 (funcall
3303 (if quoted #'tramp-compat-file-name-quote #'identity) 3278 (if quoted #'file-name-quote #'identity)
3304 ert-remote-temporary-file-directory)) 3279 ert-remote-temporary-file-directory))
3305 buffer) 3280 buffer)
3306 (unwind-protect 3281 (unwind-protect
@@ -3323,14 +3298,14 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
3323 (goto-char (point-min)) 3298 (goto-char (point-min))
3324 (should 3299 (should
3325 (re-search-forward 3300 (re-search-forward
3326 (tramp-compat-rx 3301 (rx
3327 (literal 3302 (literal
3328 (file-relative-name 3303 (file-relative-name
3329 tmp-name1 ert-remote-temporary-file-directory))))) 3304 tmp-name1 ert-remote-temporary-file-directory)))))
3330 (goto-char (point-min)) 3305 (goto-char (point-min))
3331 (should 3306 (should
3332 (re-search-forward 3307 (re-search-forward
3333 (tramp-compat-rx 3308 (rx
3334 (literal 3309 (literal
3335 (file-relative-name 3310 (file-relative-name
3336 tmp-name2 ert-remote-temporary-file-directory)))))) 3311 tmp-name2 ert-remote-temporary-file-directory))))))
@@ -3345,14 +3320,14 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
3345 (goto-char (point-min)) 3320 (goto-char (point-min))
3346 (should 3321 (should
3347 (re-search-forward 3322 (re-search-forward
3348 (tramp-compat-rx 3323 (rx
3349 (literal 3324 (literal
3350 (file-relative-name 3325 (file-relative-name
3351 tmp-name3 ert-remote-temporary-file-directory))))) 3326 tmp-name3 ert-remote-temporary-file-directory)))))
3352 (goto-char (point-min)) 3327 (goto-char (point-min))
3353 (should 3328 (should
3354 (re-search-forward 3329 (re-search-forward
3355 (tramp-compat-rx 3330 (rx
3356 (literal 3331 (literal
3357 (file-relative-name 3332 (file-relative-name
3358 tmp-name4 3333 tmp-name4
@@ -3375,14 +3350,14 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
3375 (goto-char (point-min)) 3350 (goto-char (point-min))
3376 (should 3351 (should
3377 (re-search-forward 3352 (re-search-forward
3378 (tramp-compat-rx 3353 (rx
3379 (literal 3354 (literal
3380 (file-relative-name 3355 (file-relative-name
3381 tmp-name3 ert-remote-temporary-file-directory))))) 3356 tmp-name3 ert-remote-temporary-file-directory)))))
3382 (goto-char (point-min)) 3357 (goto-char (point-min))
3383 (should 3358 (should
3384 (re-search-forward 3359 (re-search-forward
3385 (tramp-compat-rx 3360 (rx
3386 (literal 3361 (literal
3387 (file-relative-name 3362 (file-relative-name
3388 tmp-name4 3363 tmp-name4
@@ -3552,7 +3527,7 @@ This tests also `access-file', `file-readable-p',
3552 (should 3527 (should
3553 (string-equal 3528 (string-equal
3554 (funcall 3529 (funcall
3555 (if quoted #'tramp-compat-file-name-quote #'identity) 3530 (if quoted #'file-name-quote #'identity)
3556 (file-attribute-type attr)) 3531 (file-attribute-type attr))
3557 (file-remote-p (file-truename tmp-name1) 'localname))) 3532 (file-remote-p (file-truename tmp-name1) 'localname)))
3558 (delete-file tmp-name2)) 3533 (delete-file tmp-name2))
@@ -3616,9 +3591,6 @@ This tests also `access-file', `file-readable-p',
3616 (cons '(nil "perl" nil) 3591 (cons '(nil "perl" nil)
3617 tramp-connection-properties))) 3592 tramp-connection-properties)))
3618 (progn 3593 (progn
3619 ;; `ert-test-result-duration' exists since Emacs 27. It
3620 ;; doesn't hurt to call it unconditionally, because
3621 ;; `skip-unless' hides the error.
3622 (skip-unless (< (ert-test-result-duration result) 300)) 3594 (skip-unless (< (ert-test-result-duration result) 300))
3623 (funcall (ert-test-body ert-test))) 3595 (funcall (ert-test-body ert-test)))
3624 (ert-skip (format "Test `%s' must run before" ',test))))) 3596 (ert-skip (format "Test `%s' must run before" ',test)))))
@@ -3647,9 +3619,6 @@ This tests also `access-file', `file-readable-p',
3647 (nil "id" nil)) 3619 (nil "id" nil))
3648 tramp-connection-properties))) 3620 tramp-connection-properties)))
3649 (progn 3621 (progn
3650 ;; `ert-test-result-duration' exists since Emacs 27. It
3651 ;; doesn't hurt to call it unconditionally, because
3652 ;; `skip-unless' hides the error.
3653 (skip-unless (< (ert-test-result-duration result) 300)) 3622 (skip-unless (< (ert-test-result-duration result) 300))
3654 (funcall (ert-test-body ert-test))) 3623 (funcall (ert-test-body ert-test)))
3655 (ert-skip (format "Test `%s' must run before" ',test))))) 3624 (ert-skip (format "Test `%s' must run before" ',test)))))
@@ -3676,9 +3645,6 @@ This tests also `access-file', `file-readable-p',
3676 (nil "readlink" nil)) 3645 (nil "readlink" nil))
3677 tramp-connection-properties))) 3646 tramp-connection-properties)))
3678 (progn 3647 (progn
3679 ;; `ert-test-result-duration' exists since Emacs 27. It
3680 ;; doesn't hurt to call it unconditionally, because
3681 ;; `skip-unless' hides the error.
3682 (skip-unless (< (ert-test-result-duration result) 300)) 3648 (skip-unless (< (ert-test-result-duration result) 300))
3683 (funcall (ert-test-body ert-test))) 3649 (funcall (ert-test-body ert-test)))
3684 (ert-skip (format "Test `%s' must run before" ',test))))) 3650 (ert-skip (format "Test `%s' must run before" ',test)))))
@@ -3714,9 +3680,9 @@ They might differ only in time attributes or directory size."
3714 ;; few seconds). We use a test start time minus 10 seconds, in 3680 ;; few seconds). We use a test start time minus 10 seconds, in
3715 ;; order to compensate a possible timestamp resolution higher than 3681 ;; order to compensate a possible timestamp resolution higher than
3716 ;; a second on the remote machine. 3682 ;; a second on the remote machine.
3717 (when (or (tramp-compat-time-equal-p 3683 (when (or (time-equal-p
3718 (file-attribute-modification-time attr1) tramp-time-dont-know) 3684 (file-attribute-modification-time attr1) tramp-time-dont-know)
3719 (tramp-compat-time-equal-p 3685 (time-equal-p
3720 (file-attribute-modification-time attr2) tramp-time-dont-know)) 3686 (file-attribute-modification-time attr2) tramp-time-dont-know))
3721 (setcar (nthcdr 5 attr1) tramp-time-dont-know) 3687 (setcar (nthcdr 5 attr1) tramp-time-dont-know)
3722 (setcar (nthcdr 5 attr2) tramp-time-dont-know)) 3688 (setcar (nthcdr 5 attr2) tramp-time-dont-know))
@@ -3727,9 +3693,9 @@ They might differ only in time attributes or directory size."
3727 (float-time (file-attribute-modification-time attr2))) 3693 (float-time (file-attribute-modification-time attr2)))
3728 (setcar (nthcdr 5 attr2) tramp-time-dont-know)) 3694 (setcar (nthcdr 5 attr2) tramp-time-dont-know))
3729 ;; Status change time. Ditto. 3695 ;; Status change time. Ditto.
3730 (when (or (tramp-compat-time-equal-p 3696 (when (or (time-equal-p
3731 (file-attribute-status-change-time attr1) tramp-time-dont-know) 3697 (file-attribute-status-change-time attr1) tramp-time-dont-know)
3732 (tramp-compat-time-equal-p 3698 (time-equal-p
3733 (file-attribute-status-change-time attr2) tramp-time-dont-know)) 3699 (file-attribute-status-change-time attr2) tramp-time-dont-know))
3734 (setcar (nthcdr 6 attr1) tramp-time-dont-know) 3700 (setcar (nthcdr 6 attr1) tramp-time-dont-know)
3735 (setcar (nthcdr 6 attr2) tramp-time-dont-know)) 3701 (setcar (nthcdr 6 attr2) tramp-time-dont-know))
@@ -3868,7 +3834,7 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
3868 (should 3834 (should
3869 (string-equal 3835 (string-equal
3870 (funcall 3836 (funcall
3871 (if quoted #'tramp-compat-file-name-unquote #'identity) 3837 (if quoted #'file-name-unquote #'identity)
3872 (file-remote-p tmp-name1 'localname)) 3838 (file-remote-p tmp-name1 'localname))
3873 (file-symlink-p tmp-name2))) 3839 (file-symlink-p tmp-name2)))
3874 ;; Both report the modes of `tmp-name1'. 3840 ;; Both report the modes of `tmp-name1'.
@@ -3938,7 +3904,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3938 (should 3904 (should
3939 (string-equal 3905 (string-equal
3940 (funcall 3906 (funcall
3941 (if quoted #'tramp-compat-file-name-unquote #'identity) 3907 (if quoted #'file-name-unquote #'identity)
3942 (file-remote-p tmp-name1 'localname)) 3908 (file-remote-p tmp-name1 'localname))
3943 (file-symlink-p tmp-name2))) 3909 (file-symlink-p tmp-name2)))
3944 (when (tramp--test-expensive-test-p) 3910 (when (tramp--test-expensive-test-p)
@@ -3956,14 +3922,14 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3956 (should 3922 (should
3957 (string-equal 3923 (string-equal
3958 (funcall 3924 (funcall
3959 (if quoted #'tramp-compat-file-name-unquote #'identity) 3925 (if quoted #'file-name-unquote #'identity)
3960 (file-remote-p tmp-name1 'localname)) 3926 (file-remote-p tmp-name1 'localname))
3961 (file-symlink-p tmp-name2)))) 3927 (file-symlink-p tmp-name2))))
3962 (make-symbolic-link tmp-name1 tmp-name2 'ok-if-already-exists) 3928 (make-symbolic-link tmp-name1 tmp-name2 'ok-if-already-exists)
3963 (should 3929 (should
3964 (string-equal 3930 (string-equal
3965 (funcall 3931 (funcall
3966 (if quoted #'tramp-compat-file-name-unquote #'identity) 3932 (if quoted #'file-name-unquote #'identity)
3967 (file-remote-p tmp-name1 'localname)) 3933 (file-remote-p tmp-name1 'localname))
3968 (file-symlink-p tmp-name2))) 3934 (file-symlink-p tmp-name2)))
3969 ;; If we use the local part of `tmp-name1', it shall still work. 3935 ;; If we use the local part of `tmp-name1', it shall still work.
@@ -3973,7 +3939,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3973 (should 3939 (should
3974 (string-equal 3940 (string-equal
3975 (funcall 3941 (funcall
3976 (if quoted #'tramp-compat-file-name-unquote #'identity) 3942 (if quoted #'file-name-unquote #'identity)
3977 (file-remote-p tmp-name1 'localname)) 3943 (file-remote-p tmp-name1 'localname))
3978 (file-symlink-p tmp-name2))) 3944 (file-symlink-p tmp-name2)))
3979 ;; `tmp-name3' is a local file name. Therefore, the link 3945 ;; `tmp-name3' is a local file name. Therefore, the link
@@ -3993,7 +3959,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3993 (should 3959 (should
3994 (string-equal 3960 (string-equal
3995 (funcall 3961 (funcall
3996 (if quoted #'tramp-compat-file-name-unquote #'identity) 3962 (if quoted #'file-name-unquote #'identity)
3997 (file-remote-p tmp-name1 'localname)) 3963 (file-remote-p tmp-name1 'localname))
3998 (file-symlink-p tmp-name5))) 3964 (file-symlink-p tmp-name5)))
3999 ;; Check, that files in symlinked directories still work. 3965 ;; Check, that files in symlinked directories still work.
@@ -4082,15 +4048,13 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4082 "/[penguin/motd]" "/penguin:motd:"))) 4048 "/[penguin/motd]" "/penguin:motd:")))
4083 (delete-file tmp-name2) 4049 (delete-file tmp-name2)
4084 (make-symbolic-link 4050 (make-symbolic-link
4085 (funcall 4051 (funcall (if quoted #'file-name-unquote #'identity) penguin)
4086 (if quoted #'tramp-compat-file-name-unquote #'identity) penguin)
4087 tmp-name2) 4052 tmp-name2)
4088 (should (file-symlink-p tmp-name2)) 4053 (should (file-symlink-p tmp-name2))
4089 (should 4054 (should
4090 (string-equal 4055 (string-equal
4091 (file-truename tmp-name2) 4056 (file-truename tmp-name2)
4092 (tramp-compat-file-name-quote 4057 (file-name-quote (concat (file-remote-p tmp-name2) penguin)))))
4093 (concat (file-remote-p tmp-name2) penguin)))))
4094 ;; `tmp-name3' is a local file name. 4058 ;; `tmp-name3' is a local file name.
4095 ;; `make-symbolic-link' might not be permitted on w32 systems. 4059 ;; `make-symbolic-link' might not be permitted on w32 systems.
4096 (unless (tramp--test-windows-nt-p) 4060 (unless (tramp--test-windows-nt-p)
@@ -4102,7 +4066,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4102 (should 4066 (should
4103 (string-equal 4067 (string-equal
4104 (file-truename tmp-name1) 4068 (file-truename tmp-name1)
4105 (tramp-compat-file-name-unquote (file-truename tmp-name3)))))) 4069 (file-name-unquote (file-truename tmp-name3))))))
4106 4070
4107 ;; Cleanup. 4071 ;; Cleanup.
4108 (ignore-errors 4072 (ignore-errors
@@ -4175,7 +4139,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4175 (let* ((dir1 4139 (let* ((dir1
4176 (directory-file-name 4140 (directory-file-name
4177 (funcall 4141 (funcall
4178 (if quoted #'tramp-compat-file-name-quote #'identity) 4142 (if quoted #'file-name-quote #'identity)
4179 ert-remote-temporary-file-directory))) 4143 ert-remote-temporary-file-directory)))
4180 (dir2 (file-name-as-directory dir1))) 4144 (dir2 (file-name-as-directory dir1)))
4181 (should (string-equal (file-truename dir1) (expand-file-name dir1))) 4145 (should (string-equal (file-truename dir1) (expand-file-name dir1)))
@@ -4204,12 +4168,12 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4204 (skip-unless (set-file-times tmp-name1 (seconds-to-time 60))) 4168 (skip-unless (set-file-times tmp-name1 (seconds-to-time 60)))
4205 ;; Dumb remote shells without perl(1) or stat(1) are not 4169 ;; Dumb remote shells without perl(1) or stat(1) are not
4206 ;; able to return the date correctly. They say "don't know". 4170 ;; able to return the date correctly. They say "don't know".
4207 (unless (tramp-compat-time-equal-p 4171 (unless (time-equal-p
4208 (file-attribute-modification-time 4172 (file-attribute-modification-time
4209 (file-attributes tmp-name1)) 4173 (file-attributes tmp-name1))
4210 tramp-time-dont-know) 4174 tramp-time-dont-know)
4211 (should 4175 (should
4212 (tramp-compat-time-equal-p 4176 (time-equal-p
4213 (file-attribute-modification-time (file-attributes tmp-name1)) 4177 (file-attribute-modification-time (file-attributes tmp-name1))
4214 (seconds-to-time 60))) 4178 (seconds-to-time 60)))
4215 ;; Setting the time for not existing files shall fail. 4179 ;; Setting the time for not existing files shall fail.
@@ -4228,7 +4192,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4228 (with-no-warnings 4192 (with-no-warnings
4229 (set-file-times tmp-name1 (seconds-to-time 60) 'nofollow) 4193 (set-file-times tmp-name1 (seconds-to-time 60) 'nofollow)
4230 (should 4194 (should
4231 (tramp-compat-time-equal-p 4195 (time-equal-p
4232 (file-attribute-modification-time 4196 (file-attribute-modification-time
4233 (file-attributes tmp-name1)) 4197 (file-attributes tmp-name1))
4234 (seconds-to-time 60))))))) 4198 (seconds-to-time 60)))))))
@@ -4274,10 +4238,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4274 (skip-unless (file-acl ert-remote-temporary-file-directory)) 4238 (skip-unless (file-acl ert-remote-temporary-file-directory))
4275 (skip-unless (not (tramp--test-crypt-p))) 4239 (skip-unless (not (tramp--test-crypt-p)))
4276 4240
4277 ;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579. 4241 (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil)))
4278 (dolist (quoted
4279 (if (and (tramp--test-expensive-test-p) (tramp--test-emacs27-p))
4280 '(nil t) '(nil)))
4281 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted)) 4242 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
4282 (tmp-name2 (tramp--test-make-temp-name nil quoted)) 4243 (tmp-name2 (tramp--test-make-temp-name nil quoted))
4283 (tmp-name3 (tramp--test-make-temp-name 'local quoted))) 4244 (tmp-name3 (tramp--test-make-temp-name 'local quoted)))
@@ -4354,10 +4315,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4354 '(nil nil nil nil)))) 4315 '(nil nil nil nil))))
4355 (skip-unless (not (tramp--test-crypt-p))) 4316 (skip-unless (not (tramp--test-crypt-p)))
4356 4317
4357 ;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579. 4318 (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil)))
4358 (dolist (quoted
4359 (if (and (tramp--test-expensive-test-p) (tramp--test-emacs27-p))
4360 '(nil t) '(nil)))
4361 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted)) 4319 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
4362 (tmp-name2 (tramp--test-make-temp-name nil quoted)) 4320 (tmp-name2 (tramp--test-make-temp-name nil quoted))
4363 (tmp-name3 (tramp--test-make-temp-name 'local quoted))) 4321 (tmp-name3 (tramp--test-make-temp-name 'local quoted)))
@@ -4862,9 +4820,10 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4862 (unless (tramp--test-sshfs-p) 4820 (unless (tramp--test-sshfs-p)
4863 (unwind-protect 4821 (unwind-protect
4864 (with-temp-buffer 4822 (with-temp-buffer
4865 (setq command '("cat") 4823 (setq command '("cat")
4866 proc 4824 proc
4867 (apply #'start-file-process "test4" (current-buffer) command)) 4825 (apply
4826 #'start-file-process "test4" (current-buffer) command))
4868 (should (processp proc)) 4827 (should (processp proc))
4869 (should (equal (process-status proc) 'run)) 4828 (should (equal (process-status proc) 'run))
4870 (should (equal (process-get proc 'remote-command) command)) 4829 (should (equal (process-get proc 'remote-command) command))
@@ -4884,12 +4843,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4884 ;; Process connection type. 4843 ;; Process connection type.
4885 (when (and (tramp--test-sh-p) 4844 (when (and (tramp--test-sh-p)
4886 (not (tramp-direct-async-process-p)) 4845 (not (tramp-direct-async-process-p))
4887 ;; `executable-find' has changed the number of 4846 (executable-find "hexdump" 'remote))
4888 ;; parameters in Emacs 27.1, so we use `apply' for
4889 ;; older Emacsen.
4890 (ignore-errors
4891 (with-no-warnings
4892 (apply #'executable-find '("hexdump" remote)))))
4893 (dolist (process-connection-type '(nil pipe t pty)) 4847 (dolist (process-connection-type '(nil pipe t pty))
4894 (unwind-protect 4848 (unwind-protect
4895 (with-temp-buffer 4849 (with-temp-buffer
@@ -4946,33 +4900,29 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4946 "Define ert test `TEST-direct-async' for direct async processes. 4900 "Define ert test `TEST-direct-async' for direct async processes.
4947If UNSTABLE is non-nil, the test is tagged as `:unstable'." 4901If UNSTABLE is non-nil, the test is tagged as `:unstable'."
4948 (declare (indent 1)) 4902 (declare (indent 1))
4949 ;; `make-process' supports file name handlers since Emacs 27. We 4903 `(ert-deftest ,(intern (concat (symbol-name test) "-direct-async")) ()
4950 ;; cannot use `tramp--test-always' during compilation of the macro. 4904 ;; This is the docstring. However, it must be expanded to a
4951 (when (let ((file-name-handler-alist '(("" . (lambda (&rest _) t))))) 4905 ;; string inside the macro. No idea.
4952 (ignore-errors (make-process :file-handler t))) 4906 ;; (concat (ert-test-documentation (get ',test 'ert--test))
4953 `(ert-deftest ,(intern (concat (symbol-name test) "-direct-async")) () 4907 ;; "\nUse direct async process.")
4954 ;; This is the docstring. However, it must be expanded to a 4908 :tags (append '(:expensive-test :tramp-asynchronous-processes)
4955 ;; string inside the macro. No idea. 4909 (and ,unstable '(:unstable)))
4956 ;; (concat (ert-test-documentation (get ',test 'ert--test)) 4910 (skip-unless (tramp--test-enabled))
4957 ;; "\nUse direct async process.") 4911 (let ((default-directory ert-remote-temporary-file-directory)
4958 :tags (append '(:expensive-test :tramp-asynchronous-processes) 4912 (ert-test (ert-get-test ',test))
4959 (and ,unstable '(:unstable))) 4913 (tramp-connection-properties
4960 (skip-unless (tramp--test-enabled)) 4914 (cons '(nil "direct-async-process" t)
4961 (let ((default-directory ert-remote-temporary-file-directory) 4915 tramp-connection-properties)))
4962 (ert-test (ert-get-test ',test)) 4916 (skip-unless (tramp-direct-async-process-p))
4963 (tramp-connection-properties 4917 ;; We do expect an established connection already,
4964 (cons '(nil "direct-async-process" t) 4918 ;; `file-truename' does it by side-effect. Suppress
4965 tramp-connection-properties))) 4919 ;; `tramp--test-enabled', in order to keep the connection.
4966 (skip-unless (tramp-direct-async-process-p)) 4920 ;; Suppress "Process ... finished" messages.
4967 ;; We do expect an established connection already, 4921 (cl-letf (((symbol-function #'tramp--test-enabled) #'tramp--test-always)
4968 ;; `file-truename' does it by side-effect. Suppress 4922 ((symbol-function #'internal-default-process-sentinel)
4969 ;; `tramp--test-enabled', in order to keep the connection. 4923 #'ignore))
4970 ;; Suppress "Process ... finished" messages. 4924 (file-truename ert-remote-temporary-file-directory)
4971 (cl-letf (((symbol-function #'tramp--test-enabled) #'tramp--test-always) 4925 (funcall (ert-test-body ert-test))))))
4972 ((symbol-function #'internal-default-process-sentinel)
4973 #'ignore))
4974 (file-truename ert-remote-temporary-file-directory)
4975 (funcall (ert-test-body ert-test)))))))
4976 4926
4977(tramp--test-deftest-direct-async-process tramp-test29-start-file-process) 4927(tramp--test-deftest-direct-async-process tramp-test29-start-file-process)
4978 4928
@@ -4983,24 +4933,21 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
4983 '(:unstable))) 4933 '(:unstable)))
4984 (skip-unless (tramp--test-enabled)) 4934 (skip-unless (tramp--test-enabled))
4985 (skip-unless (tramp--test-supports-processes-p)) 4935 (skip-unless (tramp--test-supports-processes-p))
4986 ;; `make-process' supports file name handlers since Emacs 27.
4987 (skip-unless (tramp--test-emacs27-p))
4988 4936
4989 (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil))) 4937 (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil)))
4990 (let ((default-directory ert-remote-temporary-file-directory) 4938 (let ((default-directory ert-remote-temporary-file-directory)
4991 (tmp-name (tramp--test-make-temp-name nil quoted)) 4939 (tmp-name (tramp--test-make-temp-name nil quoted))
4992 kill-buffer-query-functions command proc) 4940 kill-buffer-query-functions command proc)
4993 (with-no-warnings (should-not (make-process))) 4941 (should-not (make-process))
4994 4942
4995 ;; Simple process. 4943 ;; Simple process.
4996 (unwind-protect 4944 (unwind-protect
4997 (with-temp-buffer 4945 (with-temp-buffer
4998 (setq command '("cat") 4946 (setq command '("cat")
4999 proc 4947 proc
5000 (with-no-warnings 4948 (make-process
5001 (make-process 4949 :name "test1" :buffer (current-buffer) :command command
5002 :name "test1" :buffer (current-buffer) :command command 4950 :file-handler t))
5003 :file-handler t)))
5004 (should (processp proc)) 4951 (should (processp proc))
5005 (should (equal (process-status proc) 'run)) 4952 (should (equal (process-status proc) 'run))
5006 (should (equal (process-get proc 'remote-command) command)) 4953 (should (equal (process-get proc 'remote-command) command))
@@ -5022,10 +4969,9 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
5022 (should (file-exists-p tmp-name)) 4969 (should (file-exists-p tmp-name))
5023 (setq command `("cat" ,(file-name-nondirectory tmp-name)) 4970 (setq command `("cat" ,(file-name-nondirectory tmp-name))
5024 proc 4971 proc
5025 (with-no-warnings 4972 (make-process
5026 (make-process 4973 :name "test2" :buffer (current-buffer) :command command
5027 :name "test2" :buffer (current-buffer) :command command 4974 :file-handler t))
5028 :file-handler t)))
5029 (should (processp proc)) 4975 (should (processp proc))
5030 (should (equal (process-get proc 'remote-command) command)) 4976 (should (equal (process-get proc 'remote-command) command))
5031 ;; Read output. 4977 ;; Read output.
@@ -5044,13 +4990,12 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
5044 (with-temp-buffer 4990 (with-temp-buffer
5045 (setq command '("cat") 4991 (setq command '("cat")
5046 proc 4992 proc
5047 (with-no-warnings 4993 (make-process
5048 (make-process 4994 :name "test3" :buffer (current-buffer) :command command
5049 :name "test3" :buffer (current-buffer) :command command 4995 :filter
5050 :filter 4996 (lambda (p s)
5051 (lambda (p s) 4997 (with-current-buffer (process-buffer p) (insert s)))
5052 (with-current-buffer (process-buffer p) (insert s))) 4998 :file-handler t))
5053 :file-handler t)))
5054 (should (processp proc)) 4999 (should (processp proc))
5055 (should (equal (process-status proc) 'run)) 5000 (should (equal (process-status proc) 'run))
5056 (should (equal (process-get proc 'remote-command) command)) 5001 (should (equal (process-get proc 'remote-command) command))
@@ -5071,11 +5016,9 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
5071 (with-temp-buffer 5016 (with-temp-buffer
5072 (setq command '("cat") 5017 (setq command '("cat")
5073 proc 5018 proc
5074 (with-no-warnings 5019 (make-process
5075 (make-process 5020 :name "test4" :buffer (current-buffer) :command command
5076 :name "test4" :buffer (current-buffer) :command command 5021 :filter t :file-handler t))
5077 :filter t
5078 :file-handler t)))
5079 (should (processp proc)) 5022 (should (processp proc))
5080 (should (equal (process-status proc) 'run)) 5023 (should (equal (process-status proc) 'run))
5081 (should (equal (process-get proc 'remote-command) command)) 5024 (should (equal (process-get proc 'remote-command) command))
@@ -5096,13 +5039,12 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
5096 (with-temp-buffer 5039 (with-temp-buffer
5097 (setq command '("cat") 5040 (setq command '("cat")
5098 proc 5041 proc
5099 (with-no-warnings 5042 (make-process
5100 (make-process 5043 :name "test5" :buffer (current-buffer) :command command
5101 :name "test5" :buffer (current-buffer) :command command 5044 :sentinel
5102 :sentinel 5045 (lambda (p s)
5103 (lambda (p s) 5046 (with-current-buffer (process-buffer p) (insert s)))
5104 (with-current-buffer (process-buffer p) (insert s))) 5047 :file-handler t))
5105 :file-handler t)))
5106 (should (processp proc)) 5048 (should (processp proc))
5107 (should (equal (process-status proc) 'run)) 5049 (should (equal (process-status proc) 'run))
5108 (should (equal (process-get proc 'remote-command) command)) 5050 (should (equal (process-get proc 'remote-command) command))
@@ -5128,11 +5070,9 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
5128 (with-temp-buffer 5070 (with-temp-buffer
5129 (setq command '("cat" "/does-not-exist") 5071 (setq command '("cat" "/does-not-exist")
5130 proc 5072 proc
5131 (with-no-warnings 5073 (make-process
5132 (make-process 5074 :name "test6" :buffer (current-buffer) :command command
5133 :name "test6" :buffer (current-buffer) :command command 5075 :stderr stderr :file-handler t))
5134 :stderr stderr
5135 :file-handler t)))
5136 (should (processp proc)) 5076 (should (processp proc))
5137 (should (equal (process-get proc 'remote-command) command)) 5077 (should (equal (process-get proc 'remote-command) command))
5138 ;; Read output. 5078 ;; Read output.
@@ -5161,11 +5101,9 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
5161 (with-temp-buffer 5101 (with-temp-buffer
5162 (setq command '("cat" "/does-not-exist") 5102 (setq command '("cat" "/does-not-exist")
5163 proc 5103 proc
5164 (with-no-warnings 5104 (make-process
5165 (make-process 5105 :name "test7" :buffer (current-buffer) :command command
5166 :name "test7" :buffer (current-buffer) :command command 5106 :stderr tmp-name :file-handler t))
5167 :stderr tmp-name
5168 :file-handler t)))
5169 (should (processp proc)) 5107 (should (processp proc))
5170 (should (equal (process-get proc 'remote-command) command)) 5108 (should (equal (process-get proc 'remote-command) command))
5171 ;; Read stderr. 5109 ;; Read stderr.
@@ -5186,12 +5124,7 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
5186 ;; Process connection type. 5124 ;; Process connection type.
5187 (when (and (tramp--test-sh-p) 5125 (when (and (tramp--test-sh-p)
5188 (not (tramp-direct-async-process-p)) 5126 (not (tramp-direct-async-process-p))
5189 ;; `executable-find' has changed the number of 5127 (executable-find "hexdump" 'remote))
5190 ;; parameters in Emacs 27.1, so we use `apply' for
5191 ;; older Emacsen.
5192 (ignore-errors
5193 (with-no-warnings
5194 (apply #'executable-find '("hexdump" remote)))))
5195 (dolist (connection-type '(nil pipe t pty)) 5128 (dolist (connection-type '(nil pipe t pty))
5196 ;; `process-connection-type' is taken when 5129 ;; `process-connection-type' is taken when
5197 ;; `:connection-type' is nil. 5130 ;; `:connection-type' is nil.
@@ -5201,15 +5134,14 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
5201 (with-temp-buffer 5134 (with-temp-buffer
5202 (setq command '("hexdump" "-v" "-e" "/1 \"%02X\n\"") 5135 (setq command '("hexdump" "-v" "-e" "/1 \"%02X\n\"")
5203 proc 5136 proc
5204 (with-no-warnings 5137 (make-process
5205 (make-process 5138 :name
5206 :name 5139 (format "test8-%s-%s"
5207 (format "test8-%s-%s" 5140 connection-type process-connection-type)
5208 connection-type process-connection-type) 5141 :buffer (current-buffer)
5209 :buffer (current-buffer) 5142 :connection-type connection-type
5210 :connection-type connection-type 5143 :command command
5211 :command command 5144 :file-handler t))
5212 :file-handler t)))
5213 (should (processp proc)) 5145 (should (processp proc))
5214 (should (equal (process-status proc) 'run)) 5146 (should (equal (process-status proc) 'run))
5215 (should (equal (process-get proc 'remote-command) command)) 5147 (should (equal (process-get proc 'remote-command) command))
@@ -5245,8 +5177,6 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
5245 (skip-unless (tramp--test-sh-p)) 5177 (skip-unless (tramp--test-sh-p))
5246 (skip-unless (not (tramp--test-windows-nt-p))) 5178 (skip-unless (not (tramp--test-windows-nt-p)))
5247 (skip-unless (not (tramp--test-crypt-p))) 5179 (skip-unless (not (tramp--test-crypt-p)))
5248 ;; Since Emacs 27.1.
5249 (skip-unless (macrop 'with-connection-local-variables))
5250 5180
5251 ;; We must use `file-truename' for the temporary directory, in 5181 ;; We must use `file-truename' for the temporary directory, in
5252 ;; order to establish the connection prior running an asynchronous 5182 ;; order to establish the connection prior running an asynchronous
@@ -5288,8 +5218,6 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
5288 (skip-unless (tramp--test-sh-p)) 5218 (skip-unless (tramp--test-sh-p))
5289 (skip-unless (not (tramp--test-windows-nt-p))) 5219 (skip-unless (not (tramp--test-windows-nt-p)))
5290 (skip-unless (not (tramp--test-crypt-p))) 5220 (skip-unless (not (tramp--test-crypt-p)))
5291 ;; Since Emacs 27.1.
5292 (skip-unless (macrop 'with-connection-local-variables))
5293 ;; Since Emacs 29.1. 5221 ;; Since Emacs 29.1.
5294 (skip-unless (boundp 'signal-process-functions)) 5222 (skip-unless (boundp 'signal-process-functions))
5295 5223
@@ -5416,11 +5344,9 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
5416INPUT, if non-nil, is a string sent to the process." 5344INPUT, if non-nil, is a string sent to the process."
5417 (let ((proc (async-shell-command command output-buffer error-buffer)) 5345 (let ((proc (async-shell-command command output-buffer error-buffer))
5418 (delete-exited-processes t)) 5346 (delete-exited-processes t))
5419 ;; Since Emacs 27.1. 5347 (should (equal (process-get proc 'remote-command)
5420 (when (macrop 'with-connection-local-variables) 5348 (with-connection-local-variables
5421 (should (equal (process-get proc 'remote-command) 5349 `(,shell-file-name ,shell-command-switch ,command))))
5422 (with-connection-local-variables
5423 `(,shell-file-name ,shell-command-switch ,command)))))
5424 (cl-letf (((symbol-function #'shell-command-sentinel) #'ignore)) 5350 (cl-letf (((symbol-function #'shell-command-sentinel) #'ignore))
5425 (when (stringp input) 5351 (when (stringp input)
5426 (process-send-string proc input)) 5352 (process-send-string proc input))
@@ -5441,10 +5367,6 @@ INPUT, if non-nil, is a string sent to the process."
5441 :tags '(:expensive-test) 5367 :tags '(:expensive-test)
5442 (skip-unless (tramp--test-enabled)) 5368 (skip-unless (tramp--test-enabled))
5443 (skip-unless (tramp--test-supports-processes-p)) 5369 (skip-unless (tramp--test-supports-processes-p))
5444 ;; Prior Emacs 27, `shell-file-name' was hard coded as "/bin/sh" for
5445 ;; remote processes in Emacs. That doesn't work for tramp-adb.el.
5446 (when (tramp--test-adb-p)
5447 (skip-unless (tramp--test-emacs27-p)))
5448 5370
5449 (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil))) 5371 (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil)))
5450 (let ((tmp-name (tramp--test-make-temp-name nil quoted)) 5372 (let ((tmp-name (tramp--test-make-temp-name nil quoted))
@@ -5512,7 +5434,7 @@ INPUT, if non-nil, is a string sent to the process."
5512 (should 5434 (should
5513 (string-match-p 5435 (string-match-p
5514 ;; Some shells echo, for example the "adb" or "docker" methods. 5436 ;; Some shells echo, for example the "adb" or "docker" methods.
5515 (tramp-compat-rx 5437 (rx
5516 bos (** 1 2 (literal (file-name-nondirectory tmp-name)) "\n") 5438 bos (** 1 2 (literal (file-name-nondirectory tmp-name)) "\n")
5517 eos) 5439 eos)
5518 (buffer-string)))) 5440 (buffer-string))))
@@ -5520,10 +5442,8 @@ INPUT, if non-nil, is a string sent to the process."
5520 ;; Cleanup. 5442 ;; Cleanup.
5521 (ignore-errors (delete-file tmp-name)))))) 5443 (ignore-errors (delete-file tmp-name))))))
5522 5444
5523 ;; Test `async-shell-command-width'. It exists since Emacs 26.1, 5445 ;; Test `async-shell-command-width'.
5524 ;; but seems to work since Emacs 27.1 only. 5446 (when (and (tramp--test-asynchronous-processes-p) (tramp--test-sh-p))
5525 (when (and (tramp--test-asynchronous-processes-p)
5526 (tramp--test-sh-p) (tramp--test-emacs27-p))
5527 (let* ((async-shell-command-width 1024) 5447 (let* ((async-shell-command-width 1024)
5528 (default-directory ert-remote-temporary-file-directory) 5448 (default-directory ert-remote-temporary-file-directory)
5529 (cols (ignore-errors 5449 (cols (ignore-errors
@@ -5543,8 +5463,6 @@ INPUT, if non-nil, is a string sent to the process."
5543 (skip-unless (tramp--test-enabled)) 5463 (skip-unless (tramp--test-enabled))
5544 (skip-unless nil) 5464 (skip-unless nil)
5545 (skip-unless (tramp--test-supports-processes-p)) 5465 (skip-unless (tramp--test-supports-processes-p))
5546 ;; Prior Emacs 27, `shell-command-dont-erase-buffer' wasn't working properly.
5547 (skip-unless (tramp--test-emacs27-p))
5548 5466
5549 ;; (message " s-c-d-e-b current-buffer buffer-string point") 5467 ;; (message " s-c-d-e-b current-buffer buffer-string point")
5550 ;; (message "===============================================") 5468 ;; (message "===============================================")
@@ -5719,8 +5637,7 @@ INPUT, if non-nil, is a string sent to the process."
5719 ;; Variable is set. 5637 ;; Variable is set.
5720 (should 5638 (should
5721 (string-match-p 5639 (string-match-p
5722 (tramp-compat-rx (literal envvar)) 5640 (rx (literal envvar)) (funcall this-shell-command-to-string "set"))))
5723 (funcall this-shell-command-to-string "set"))))
5724 5641
5725 (unless (tramp-direct-async-process-p) 5642 (unless (tramp-direct-async-process-p)
5726 ;; We force a reconnect, in order to have a clean environment. 5643 ;; We force a reconnect, in order to have a clean environment.
@@ -5746,7 +5663,7 @@ INPUT, if non-nil, is a string sent to the process."
5746 ;; Variable is unset. 5663 ;; Variable is unset.
5747 (should-not 5664 (should-not
5748 (string-match-p 5665 (string-match-p
5749 (tramp-compat-rx (literal envvar)) 5666 (rx (literal envvar))
5750 ;; We must remove PS1, the output is truncated otherwise. 5667 ;; We must remove PS1, the output is truncated otherwise.
5751 ;; We must suppress "_=VAR...". 5668 ;; We must suppress "_=VAR...".
5752 (funcall 5669 (funcall
@@ -5791,13 +5708,10 @@ INPUT, if non-nil, is a string sent to the process."
5791 (dolist (dir '("/mock:localhost#11111:" "/mock:localhost#22222:")) 5708 (dolist (dir '("/mock:localhost#11111:" "/mock:localhost#22222:"))
5792 (tramp-cleanup-connection (tramp-dissect-file-name dir))))) 5709 (tramp-cleanup-connection (tramp-dissect-file-name dir)))))
5793 5710
5794;; Connection-local variables are enabled per default since Emacs 27.1.
5795(ert-deftest tramp-test34-connection-local-variables () 5711(ert-deftest tramp-test34-connection-local-variables ()
5796 "Check that connection-local variables are enabled." 5712 "Check that connection-local variables are enabled."
5797 :tags '(:expensive-test) 5713 :tags '(:expensive-test)
5798 (skip-unless (tramp--test-enabled)) 5714 (skip-unless (tramp--test-enabled))
5799 ;; Since Emacs 27.1.
5800 (skip-unless (macrop 'with-connection-local-variables))
5801 5715
5802 (let* ((default-directory ert-remote-temporary-file-directory) 5716 (let* ((default-directory ert-remote-temporary-file-directory)
5803 (tmp-name1 (tramp--test-make-temp-name)) 5717 (tmp-name1 (tramp--test-make-temp-name))
@@ -5861,19 +5775,12 @@ INPUT, if non-nil, is a string sent to the process."
5861 :tags '(:expensive-test :tramp-asynchronous-processes) 5775 :tags '(:expensive-test :tramp-asynchronous-processes)
5862 (skip-unless (tramp--test-enabled)) 5776 (skip-unless (tramp--test-enabled))
5863 (skip-unless (tramp--test-supports-processes-p)) 5777 (skip-unless (tramp--test-supports-processes-p))
5864 ;; Prior Emacs 27, `shell-file-name' was hard coded as "/bin/sh" for
5865 ;; remote processes in Emacs. That doesn't work for tramp-adb.el.
5866 (when (tramp--test-adb-p)
5867 (skip-unless (tramp--test-emacs27-p)))
5868 5778
5869 (let ((default-directory ert-remote-temporary-file-directory) 5779 (let ((default-directory ert-remote-temporary-file-directory)
5870 explicit-shell-file-name kill-buffer-query-functions 5780 explicit-shell-file-name kill-buffer-query-functions
5871 connection-local-profile-alist connection-local-criteria-alist) 5781 connection-local-profile-alist connection-local-criteria-alist)
5872 (unwind-protect 5782 (unwind-protect
5873 (progn 5783 (progn
5874 ;; `shell-mode' would ruin our test, because it deletes all
5875 ;; buffer local variables. Not needed in Emacs 27.1.
5876 (put 'explicit-shell-file-name 'permanent-local t)
5877 (connection-local-set-profile-variables 5784 (connection-local-set-profile-variables
5878 'remote-sh 5785 'remote-sh
5879 `((explicit-shell-file-name . ,(tramp--test-shell-file-name)) 5786 `((explicit-shell-file-name . ,(tramp--test-shell-file-name))
@@ -5904,29 +5811,24 @@ INPUT, if non-nil, is a string sent to the process."
5904 (put 'explicit-shell-file-name 'permanent-local nil) 5811 (put 'explicit-shell-file-name 'permanent-local nil)
5905 (kill-buffer "*shell*")))) 5812 (kill-buffer "*shell*"))))
5906 5813
5907;; `exec-path' was introduced in Emacs 27.1. `executable-find' has
5908;; changed the number of parameters, so we use `apply' for older
5909;; Emacsen.
5910(ert-deftest tramp-test35-exec-path () 5814(ert-deftest tramp-test35-exec-path ()
5911 "Check `exec-path' and `executable-find'." 5815 "Check `exec-path' and `executable-find'."
5912 (skip-unless (tramp--test-enabled)) 5816 (skip-unless (tramp--test-enabled))
5913 (skip-unless (tramp--test-supports-processes-p)) 5817 (skip-unless (tramp--test-supports-processes-p))
5914 (skip-unless (tramp--test-supports-set-file-modes-p)) 5818 (skip-unless (tramp--test-supports-set-file-modes-p))
5915 ;; Since Emacs 27.1.
5916 (skip-unless (fboundp 'exec-path))
5917 5819
5918 (let ((tmp-name (tramp--test-make-temp-name)) 5820 (let ((tmp-name (tramp--test-make-temp-name))
5919 (default-directory ert-remote-temporary-file-directory)) 5821 (default-directory ert-remote-temporary-file-directory))
5920 (unwind-protect 5822 (unwind-protect
5921 (progn 5823 (progn
5922 (should (consp (with-no-warnings (exec-path)))) 5824 (should (consp (exec-path)))
5923 ;; Last element is the `exec-directory'. 5825 ;; Last element is the `exec-directory'.
5924 (should 5826 (should
5925 (string-equal 5827 (string-equal
5926 (car (last (with-no-warnings (exec-path)))) 5828 (car (last (exec-path)))
5927 (file-remote-p default-directory 'localname))) 5829 (file-remote-p default-directory 'localname)))
5928 ;; The shell "sh" shall always exist. 5830 ;; The shell "sh" shall always exist.
5929 (should (apply #'executable-find '("sh" remote))) 5831 (should (executable-find "sh" 'remote))
5930 ;; Since the last element in `exec-path' is the current 5832 ;; Since the last element in `exec-path' is the current
5931 ;; directory, an executable file in that directory will be 5833 ;; directory, an executable file in that directory will be
5932 ;; found. 5834 ;; found.
@@ -5937,32 +5839,25 @@ INPUT, if non-nil, is a string sent to the process."
5937 (should (file-executable-p tmp-name)) 5839 (should (file-executable-p tmp-name))
5938 (should 5840 (should
5939 (string-equal 5841 (string-equal
5940 (apply 5842 (executable-find (file-name-nondirectory tmp-name) 'remote)
5941 #'executable-find `(,(file-name-nondirectory tmp-name) remote))
5942 (file-remote-p tmp-name 'localname))) 5843 (file-remote-p tmp-name 'localname)))
5943 (should-not 5844 (should-not
5944 (apply 5845 (executable-find
5945 #'executable-find 5846 (concat (file-name-nondirectory tmp-name) "foo") 'remote)))
5946 `(,(concat (file-name-nondirectory tmp-name) "foo") remote))))
5947 5847
5948 ;; Cleanup. 5848 ;; Cleanup.
5949 (ignore-errors (delete-file tmp-name))))) 5849 (ignore-errors (delete-file tmp-name)))))
5950 5850
5951;; This test is inspired by Bug#33781. 5851;; This test is inspired by Bug#33781.
5952;; `exec-path' was introduced in Emacs 27.1. `executable-find' has
5953;; changed the number of parameters, so we use `apply' for older
5954;; Emacsen.
5955(ert-deftest tramp-test35-remote-path () 5852(ert-deftest tramp-test35-remote-path ()
5956 "Check loooong `tramp-remote-path'." 5853 "Check loooong `tramp-remote-path'."
5957 (skip-unless (tramp--test-enabled)) 5854 (skip-unless (tramp--test-enabled))
5958 (skip-unless (tramp--test-sh-p)) 5855 (skip-unless (tramp--test-sh-p))
5959 (skip-unless (not (tramp--test-crypt-p))) 5856 (skip-unless (not (tramp--test-crypt-p)))
5960 ;; Since Emacs 27.1.
5961 (skip-unless (fboundp 'exec-path))
5962 5857
5963 (let* ((tmp-name (tramp--test-make-temp-name)) 5858 (let* ((tmp-name (tramp--test-make-temp-name))
5964 (default-directory ert-remote-temporary-file-directory) 5859 (default-directory ert-remote-temporary-file-directory)
5965 (orig-exec-path (with-no-warnings (exec-path))) 5860 (orig-exec-path (exec-path))
5966 (tramp-remote-path tramp-remote-path) 5861 (tramp-remote-path tramp-remote-path)
5967 (orig-tramp-remote-path tramp-remote-path) 5862 (orig-tramp-remote-path tramp-remote-path)
5968 path) 5863 path)
@@ -5972,14 +5867,13 @@ INPUT, if non-nil, is a string sent to the process."
5972 (setq tramp-remote-path 5867 (setq tramp-remote-path
5973 (cons (file-remote-p tmp-name 'localname) tramp-remote-path)) 5868 (cons (file-remote-p tmp-name 'localname) tramp-remote-path))
5974 (tramp-cleanup-connection tramp-test-vec 'keep-debug 'keep-password) 5869 (tramp-cleanup-connection tramp-test-vec 'keep-debug 'keep-password)
5975 (should (equal (with-no-warnings (exec-path)) orig-exec-path)) 5870 (should (equal (exec-path) orig-exec-path))
5976 (setq tramp-remote-path orig-tramp-remote-path) 5871 (setq tramp-remote-path orig-tramp-remote-path)
5977 5872
5978 ;; Double entries are removed. 5873 ;; Double entries are removed.
5979 (setq tramp-remote-path (append '("/" "/") tramp-remote-path)) 5874 (setq tramp-remote-path (append '("/" "/") tramp-remote-path))
5980 (tramp-cleanup-connection tramp-test-vec 'keep-debug 'keep-password) 5875 (tramp-cleanup-connection tramp-test-vec 'keep-debug 'keep-password)
5981 (should 5876 (should (equal (exec-path) (cons "/" orig-exec-path)))
5982 (equal (with-no-warnings (exec-path)) (cons "/" orig-exec-path)))
5983 (setq tramp-remote-path orig-tramp-remote-path) 5877 (setq tramp-remote-path orig-tramp-remote-path)
5984 5878
5985 ;; We make a super long `tramp-remote-path'. 5879 ;; We make a super long `tramp-remote-path'.
@@ -5997,7 +5891,7 @@ INPUT, if non-nil, is a string sent to the process."
5997 `(,(file-remote-p dir 'localname)) 5891 `(,(file-remote-p dir 'localname))
5998 (last orig-exec-path))))) 5892 (last orig-exec-path)))))
5999 (tramp-cleanup-connection tramp-test-vec 'keep-debug 'keep-password) 5893 (tramp-cleanup-connection tramp-test-vec 'keep-debug 'keep-password)
6000 (should (equal (with-no-warnings (exec-path)) orig-exec-path)) 5894 (should (equal (exec-path) orig-exec-path))
6001 ;; Ignore trailing newline. 5895 ;; Ignore trailing newline.
6002 (setq path (substring (shell-command-to-string "echo $PATH") nil -1)) 5896 (setq path (substring (shell-command-to-string "echo $PATH") nil -1))
6003 ;; The shell doesn't handle such long strings. 5897 ;; The shell doesn't handle such long strings.
@@ -6009,7 +5903,7 @@ INPUT, if non-nil, is a string sent to the process."
6009 (string-equal 5903 (string-equal
6010 path (mapconcat #'identity (butlast orig-exec-path) ":")))) 5904 path (mapconcat #'identity (butlast orig-exec-path) ":"))))
6011 ;; The shell "sh" shall always exist. 5905 ;; The shell "sh" shall always exist.
6012 (should (apply #'executable-find '("sh" remote)))) 5906 (should (executable-find "sh" 'remote)))
6013 5907
6014 ;; Cleanup. 5908 ;; Cleanup.
6015 (tramp-cleanup-connection tramp-test-vec 'keep-debug 'keep-password) 5909 (tramp-cleanup-connection tramp-test-vec 'keep-debug 'keep-password)
@@ -6129,7 +6023,7 @@ INPUT, if non-nil, is a string sent to the process."
6129 (string-equal 6023 (string-equal
6130 (make-auto-save-file-name) 6024 (make-auto-save-file-name)
6131 (funcall 6025 (funcall
6132 (if quoted #'tramp-compat-file-name-quote #'identity) 6026 (if quoted #'file-name-quote #'identity)
6133 (expand-file-name 6027 (expand-file-name
6134 (format "#%s#" (file-name-nondirectory tmp-name1)) 6028 (format "#%s#" (file-name-nondirectory tmp-name1))
6135 ert-remote-temporary-file-directory)))))) 6029 ert-remote-temporary-file-directory))))))
@@ -6154,7 +6048,7 @@ INPUT, if non-nil, is a string sent to the process."
6154 ("|" . "__") 6048 ("|" . "__")
6155 ("[" . "_l") 6049 ("[" . "_l")
6156 ("]" . "_r")) 6050 ("]" . "_r"))
6157 (tramp-compat-file-name-unquote tmp-name1))) 6051 (file-name-unquote tmp-name1)))
6158 tmp-name2))) 6052 tmp-name2)))
6159 (should (file-directory-p tmp-name2))))) 6053 (should (file-directory-p tmp-name2)))))
6160 6054
@@ -6178,7 +6072,7 @@ INPUT, if non-nil, is a string sent to the process."
6178 ("|" . "__") 6072 ("|" . "__")
6179 ("[" . "_l") 6073 ("[" . "_l")
6180 ("]" . "_r")) 6074 ("]" . "_r"))
6181 (tramp-compat-file-name-unquote tmp-name1))) 6075 (file-name-unquote tmp-name1)))
6182 tmp-name2))) 6076 tmp-name2)))
6183 (should (file-directory-p tmp-name2))))) 6077 (should (file-directory-p tmp-name2)))))
6184 6078
@@ -6234,7 +6128,7 @@ INPUT, if non-nil, is a string sent to the process."
6234 (find-backup-file-name tmp-name1) 6128 (find-backup-file-name tmp-name1)
6235 (list 6129 (list
6236 (funcall 6130 (funcall
6237 (if quoted #'tramp-compat-file-name-quote #'identity) 6131 (if quoted #'file-name-quote #'identity)
6238 (expand-file-name 6132 (expand-file-name
6239 (format "%s~" (file-name-nondirectory tmp-name1)) 6133 (format "%s~" (file-name-nondirectory tmp-name1))
6240 ert-remote-temporary-file-directory))))))) 6134 ert-remote-temporary-file-directory)))))))
@@ -6248,7 +6142,7 @@ INPUT, if non-nil, is a string sent to the process."
6248 (find-backup-file-name tmp-name1) 6142 (find-backup-file-name tmp-name1)
6249 (list 6143 (list
6250 (funcall 6144 (funcall
6251 (if quoted #'tramp-compat-file-name-quote #'identity) 6145 (if quoted #'file-name-quote #'identity)
6252 (expand-file-name 6146 (expand-file-name
6253 (format 6147 (format
6254 "%s~" 6148 "%s~"
@@ -6277,7 +6171,7 @@ INPUT, if non-nil, is a string sent to the process."
6277 (find-backup-file-name tmp-name1) 6171 (find-backup-file-name tmp-name1)
6278 (list 6172 (list
6279 (funcall 6173 (funcall
6280 (if quoted #'tramp-compat-file-name-quote #'identity) 6174 (if quoted #'file-name-quote #'identity)
6281 (expand-file-name 6175 (expand-file-name
6282 (format 6176 (format
6283 "%s~" 6177 "%s~"
@@ -6308,7 +6202,7 @@ INPUT, if non-nil, is a string sent to the process."
6308 (find-backup-file-name tmp-name1) 6202 (find-backup-file-name tmp-name1)
6309 (list 6203 (list
6310 (funcall 6204 (funcall
6311 (if quoted #'tramp-compat-file-name-quote #'identity) 6205 (if quoted #'file-name-quote #'identity)
6312 (expand-file-name 6206 (expand-file-name
6313 (format 6207 (format
6314 "%s~" 6208 "%s~"
@@ -6566,7 +6460,6 @@ INPUT, if non-nil, is a string sent to the process."
6566 (tramp-cleanup-connection 6460 (tramp-cleanup-connection
6567 tramp-test-vec 'keep-debug 'keep-password))))))) 6461 tramp-test-vec 'keep-debug 'keep-password)))))))
6568 6462
6569;; The functions were introduced in Emacs 26.1.
6570(ert-deftest tramp-test40-make-nearby-temp-file () 6463(ert-deftest tramp-test40-make-nearby-temp-file ()
6571 "Check `make-nearby-temp-file' and `temporary-file-directory'." 6464 "Check `make-nearby-temp-file' and `temporary-file-directory'."
6572 (skip-unless (tramp--test-enabled)) 6465 (skip-unless (tramp--test-enabled))
@@ -6598,12 +6491,6 @@ INPUT, if non-nil, is a string sent to the process."
6598 (delete-directory tmp-file) 6491 (delete-directory tmp-file)
6599 (should-not (file-exists-p tmp-file)))) 6492 (should-not (file-exists-p tmp-file))))
6600 6493
6601(defun tramp--test-emacs27-p ()
6602 "Check for Emacs version >= 27.1.
6603Some semantics has been changed for there, without new functions
6604or variables, so we check the Emacs version directly."
6605 (>= emacs-major-version 27))
6606
6607(defun tramp--test-emacs28-p () 6494(defun tramp--test-emacs28-p ()
6608 "Check for Emacs version >= 28.1. 6495 "Check for Emacs version >= 28.1.
6609Some semantics has been changed for there, without new functions 6496Some semantics has been changed for there, without new functions
@@ -6638,7 +6525,7 @@ This is used in tests which we don't want to tag
6638 :body nil :tags '(:tramp-asynchronous-processes)))) 6525 :body nil :tags '(:tramp-asynchronous-processes))))
6639 ;; tramp-adb.el cannot apply multi-byte commands. 6526 ;; tramp-adb.el cannot apply multi-byte commands.
6640 (not (and (tramp--test-adb-p) 6527 (not (and (tramp--test-adb-p)
6641 (string-match-p (tramp-compat-rx multibyte) default-directory))))) 6528 (string-match-p (rx multibyte) default-directory)))))
6642 6529
6643(defun tramp--test-crypt-p () 6530(defun tramp--test-crypt-p ()
6644 "Check, whether the remote directory is encrypted." 6531 "Check, whether the remote directory is encrypted."
@@ -6802,10 +6689,7 @@ This requires restrictions of file name syntax."
6802 6689
6803(defun tramp--test-check-files (&rest files) 6690(defun tramp--test-check-files (&rest files)
6804 "Run a simple but comprehensive test over every file in FILES." 6691 "Run a simple but comprehensive test over every file in FILES."
6805 ;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579. 6692 (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil)))
6806 (dolist (quoted
6807 (if (and (tramp--test-expensive-test-p) (tramp--test-emacs27-p))
6808 '(nil t) '(nil)))
6809 ;; We must use `file-truename' for the temporary directory, 6693 ;; We must use `file-truename' for the temporary directory,
6810 ;; because it could be located on a symlinked directory. This 6694 ;; because it could be located on a symlinked directory. This
6811 ;; would let the test fail. 6695 ;; would let the test fail.
@@ -6855,7 +6739,7 @@ This requires restrictions of file name syntax."
6855 (should 6739 (should
6856 (string-equal 6740 (string-equal
6857 (funcall 6741 (funcall
6858 (if quoted #'tramp-compat-file-name-quote #'identity) 6742 (if quoted #'file-name-quote #'identity)
6859 (file-attribute-type (file-attributes file3))) 6743 (file-attribute-type (file-attributes file3)))
6860 (file-remote-p (file-truename file1) 'localname))) 6744 (file-remote-p (file-truename file1) 'localname)))
6861 ;; Check file contents. 6745 ;; Check file contents.
@@ -6946,14 +6830,14 @@ This requires restrictions of file name syntax."
6946 (should 6830 (should
6947 (string-equal 6831 (string-equal
6948 (caar (directory-files-and-attributes 6832 (caar (directory-files-and-attributes
6949 file1 nil (tramp-compat-rx (literal elt1)))) 6833 file1 nil (rx (literal elt1))))
6950 elt1)) 6834 elt1))
6951 (should 6835 (should
6952 (string-equal 6836 (string-equal
6953 (funcall 6837 (funcall
6954 (if quoted #'tramp-compat-file-name-quote #'identity) 6838 (if quoted #'file-name-quote #'identity)
6955 (cadr (car (directory-files-and-attributes 6839 (cadr (car (directory-files-and-attributes
6956 file1 nil (tramp-compat-rx (literal elt1)))))) 6840 file1 nil (rx (literal elt1))))))
6957 (file-remote-p (file-truename file2) 'localname))) 6841 (file-remote-p (file-truename file2) 'localname)))
6958 (delete-file file3) 6842 (delete-file file3)
6959 (should-not (file-exists-p file3)))) 6843 (should-not (file-exists-p file3))))
@@ -6962,15 +6846,7 @@ This requires restrictions of file name syntax."
6962 ;; `default-directory' with special characters. See 6846 ;; `default-directory' with special characters. See
6963 ;; Bug#53846. 6847 ;; Bug#53846.
6964 (when (and (tramp--test-expensive-test-p) 6848 (when (and (tramp--test-expensive-test-p)
6965 (tramp--test-supports-processes-p) 6849 (tramp--test-supports-processes-p))
6966 ;; Prior Emacs 27, `shell-file-name' was
6967 ;; hard coded as "/bin/sh" for remote
6968 ;; processes in Emacs. That doesn't work
6969 ;; for tramp-adb.el. tramp-sshfs.el times
6970 ;; out for older Emacsen, reason unknown.
6971 (or (and (not (tramp--test-adb-p))
6972 (not (tramp--test-sshfs-p)))
6973 (tramp--test-emacs27-p)))
6974 (let ((default-directory file1)) 6850 (let ((default-directory file1))
6975 (dolist (this-shell-command 6851 (dolist (this-shell-command
6976 (append 6852 (append
@@ -7008,7 +6884,7 @@ This requires restrictions of file name syntax."
7008 (goto-char (point-min)) 6884 (goto-char (point-min))
7009 (should 6885 (should
7010 (re-search-forward 6886 (re-search-forward
7011 (tramp-compat-rx 6887 (rx
7012 bol (literal envvar) 6888 bol (literal envvar)
7013 "=" (literal (getenv envvar)) eol)))))))) 6889 "=" (literal (getenv envvar)) eol))))))))
7014 6890
@@ -7154,13 +7030,8 @@ This requires restrictions of file name syntax."
7154(ert-deftest tramp-test43-file-system-info () 7030(ert-deftest tramp-test43-file-system-info ()
7155 "Check that `file-system-info' returns proper values." 7031 "Check that `file-system-info' returns proper values."
7156 (skip-unless (tramp--test-enabled)) 7032 (skip-unless (tramp--test-enabled))
7157 ;; Since Emacs 27.1.
7158 (skip-unless (fboundp 'file-system-info))
7159 7033
7160 ;; `file-system-info' exists since Emacs 27.1. We don't want to see 7034 (when-let ((fsi (file-system-info ert-remote-temporary-file-directory)))
7161 ;; compiler warnings for older Emacsen.
7162 (when-let ((fsi (with-no-warnings
7163 (file-system-info ert-remote-temporary-file-directory))))
7164 (should (consp fsi)) 7035 (should (consp fsi))
7165 (should (= (length fsi) 3)) 7036 (should (= (length fsi) 3))
7166 (dotimes (i (length fsi)) 7037 (dotimes (i (length fsi))
@@ -7216,10 +7087,6 @@ process sentinels. They shall not disturb each other."
7216 '(:unstable))) 7087 '(:unstable)))
7217 (skip-unless (tramp--test-enabled)) 7088 (skip-unless (tramp--test-enabled))
7218 (skip-unless (tramp--test-supports-processes-p)) 7089 (skip-unless (tramp--test-supports-processes-p))
7219 ;; Prior Emacs 27, `shell-file-name' was hard coded as "/bin/sh" for
7220 ;; remote processes in Emacs. That doesn't work for tramp-adb.el.
7221 (when (tramp--test-adb-p)
7222 (skip-unless (tramp--test-emacs27-p)))
7223 (skip-unless (not (tramp--test-docker-p))) 7090 (skip-unless (not (tramp--test-docker-p)))
7224 (skip-unless (not (tramp--test-telnet-p))) 7091 (skip-unless (not (tramp--test-telnet-p)))
7225 (skip-unless (not (tramp--test-sshfs-p))) 7092 (skip-unless (not (tramp--test-sshfs-p)))
@@ -7552,7 +7419,7 @@ process sentinels. They shall not disturb each other."
7552 (dolist (tm '(t nil)) 7419 (dolist (tm '(t nil))
7553 (should 7420 (should
7554 (string-match-p 7421 (string-match-p
7555 (tramp-compat-rx 7422 (rx
7556 "Tramp loaded: nil" (+ (any "\n\r")) 7423 "Tramp loaded: nil" (+ (any "\n\r"))
7557 "Tramp loaded: nil" (+ (any "\n\r")) 7424 "Tramp loaded: nil" (+ (any "\n\r"))
7558 "Tramp loaded: " (literal (symbol-name tm)) (+ (any "\n\r"))) 7425 "Tramp loaded: " (literal (symbol-name tm)) (+ (any "\n\r")))
@@ -7600,7 +7467,7 @@ process sentinels. They shall not disturb each other."
7600 (tramp-cleanup-all-connections))")) 7467 (tramp-cleanup-all-connections))"))
7601 (should 7468 (should
7602 (string-match-p 7469 (string-match-p
7603 (tramp-compat-rx 7470 (rx
7604 "Loading " 7471 "Loading "
7605 (literal 7472 (literal
7606 (expand-file-name 7473 (expand-file-name