diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2023-06-21 18:25:32 +0200 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2023-06-21 18:25:32 +0200 |
commit | 72f1c12e58ec2654779506480774e627d46d3693 (patch) | |
tree | bd22815b6105859794e7d1f803309bb1bc857c1b /test/lisp/net | |
parent | 195ca6b9a37511e2681e75a35781074b16101a42 (diff) | |
download | emacs-72f1c12e58ec2654779506480774e627d46d3693.tar.gz emacs-72f1c12e58ec2654779506480774e627d46d3693.tar.bz2 emacs-72f1c12e58ec2654779506480774e627d46d3693.zip |
Add Tramp option showing ad-hoc multi-hops
* doc/misc/tramp.texi (Ad-hoc multi-hops):
Describe tramp-show-ad-hoc-proxies.
* lisp/net/tramp.el (tramp-show-ad-hoc-proxies): New defcustom.
(tramp-make-tramp-file-name): Use it.
(tramp-make-tramp-hop-name): Don't add hop twice.
* test/lisp/net/tramp-tests.el (tramp-test02-file-name-dissect)
(tramp-test02-file-name-dissect-simplified)
(tramp-test02-file-name-dissect-separate): Adapt tests.
Diffstat (limited to 'test/lisp/net')
-rw-r--r-- | test/lisp/net/tramp-tests.el | 990 |
1 files changed, 566 insertions, 424 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 0b01c13470a..a2e57e468c1 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -521,6 +521,7 @@ is greater than 10. tramp-default-method-alist tramp-default-user-alist tramp-default-host-alist + tramp-default-proxies-alist ;; Suppress method name check. (non-essential t) ;; Suppress check for multihops. @@ -847,154 +848,203 @@ is greater than 10. "/path/to/file")) ;; Multihop. - (should - (string-equal - (file-remote-p - "/method1:user1@host1|method2:user2@host2:/path/to/file") - "/method2:user2@host2:")) - (should - (string-equal - (file-remote-p - "/method1:user1@host1|method2:user2@host2:/path/to/file" 'method) - "method2")) - (should - (string-equal - (file-remote-p - "/method1:user1@host1|method2:user2@host2:/path/to/file" 'user) - "user2")) - (should - (string-equal - (file-remote-p - "/method1:user1@host1|method2:user2@host2:/path/to/file" 'host) - "host2")) - (should - (string-equal - (file-remote-p - "/method1:user1@host1|method2:user2@host2:/path/to/file" - 'localname) - "/path/to/file")) - (should - (string-equal - (file-remote-p - "/method1:user1@host1|method2:user2@host2:/path/to/file" 'hop) - (format "%s:%s@%s|" - "method1" "user1" "host1"))) + (dolist (tramp-show-ad-hoc-proxies '(nil t)) - (should - (string-equal - (file-remote-p - (concat - "/method1:user1@host1" - "|method2:user2@host2" - "|method3:user3@host3:/path/to/file")) - "/method3:user3@host3:")) - (should - (string-equal - (file-remote-p - (concat - "/method1:user1@host1" - "|method2:user2@host2" - "|method3:user3@host3:/path/to/file") - 'method) - "method3")) - (should - (string-equal - (file-remote-p - (concat - "/method1:user1@host1" - "|method2:user2@host2" - "|method3:user3@host3:/path/to/file") - 'user) - "user3")) - (should - (string-equal - (file-remote-p - (concat - "/method1:user1@host1" - "|method2:user2@host2" - "|method3:user3@host3:/path/to/file") - 'host) - "host3")) - (should - (string-equal - (file-remote-p - (concat - "/method1:user1@host1" - "|method2:user2@host2" - "|method3:user3@host3:/path/to/file") - 'localname) - "/path/to/file")) - (should - (string-equal - (file-remote-p - (concat - "/method1:user1@host1" - "|method2:user2@host2" - "|method3:user3@host3:/path/to/file") - 'hop) - (format "%s:%s@%s|%s:%s@%s|" - "method1" "user1" "host1" "method2" "user2" "host2"))) - - ;; Expand `tramp-default-method-alist'. - (add-to-list 'tramp-default-method-alist '("host1" "user1" "method1")) - (add-to-list 'tramp-default-method-alist '("host2" "user2" "method2")) - (add-to-list 'tramp-default-method-alist '("host3" "user3" "method3")) - (should - (string-equal - (file-remote-p - (concat - "/-:user1@host1" - "|-:user2@host2" - "|-:user3@host3:/path/to/file")) - "/method3:user3@host3:")) - - ;; Expand `tramp-default-user-alist'. - (add-to-list 'tramp-default-user-alist '("method1" "host1" "user1")) - (add-to-list 'tramp-default-user-alist '("method2" "host2" "user2")) - (add-to-list 'tramp-default-user-alist '("method3" "host3" "user3")) - (should - (string-equal - (file-remote-p - (concat - "/method1:host1" - "|method2:host2" - "|method3:host3:/path/to/file")) - "/method3:user3@host3:")) - - ;; Expand `tramp-default-host-alist'. - (add-to-list 'tramp-default-host-alist '("method1" "user1" "host1")) - (add-to-list 'tramp-default-host-alist '("method2" "user2" "host2")) - (add-to-list 'tramp-default-host-alist '("method3" "user3" "host3")) - (should - (string-equal - (file-remote-p - (concat - "/method1:user1@" - "|method2:user2@" - "|method3:user3@:/path/to/file")) - "/method3:user3@host3:")) - - ;; Ad-hoc user name and host name expansion. - (setq tramp-default-method-alist nil - tramp-default-user-alist nil - tramp-default-host-alist nil) - (should - (string-equal - (file-remote-p - (concat - "/method1:user1@host1" - "|method2:user2@" - "|method3:user3@:/path/to/file")) - "/method3:user3@host1:")) - (should - (string-equal - (file-remote-p - (concat - "/method1:%u@%h" - "|method2:user2@host2" - "|method3:%u@%h" - "|method4:user4%domain4@host4#1234:/path/to/file")) - "/method4:user4%domain4@host4#1234:"))) + ;; Explicit settings in `tramp-default-proxies-alist' + ;; shouldn't show hops. + (setq tramp-default-proxies-alist + '(("^host2$" "^user2$" "/method1:user1@host1:"))) + (should + (string-equal + (file-remote-p "/method2:user2@host2:/path/to/file") + "/method2:user2@host2:")) + (setq tramp-default-proxies-alist nil) + + ;; Ad-hoc settings. + (should + (string-equal + (file-remote-p + "/method1:user1@host1|method2:user2@host2:/path/to/file") + (if tramp-show-ad-hoc-proxies + "/method1:user1@host1|method2:user2@host2:" + "/method2:user2@host2:"))) + (should + (string-equal + (file-remote-p + "/method1:user1@host1|method2:user2@host2:/path/to/file" 'method) + "method2")) + (should + (string-equal + (file-remote-p + "/method1:user1@host1|method2:user2@host2:/path/to/file" 'user) + "user2")) + (should + (string-equal + (file-remote-p + "/method1:user1@host1|method2:user2@host2:/path/to/file" 'host) + "host2")) + (should + (string-equal + (file-remote-p + "/method1:user1@host1|method2:user2@host2:/path/to/file" + 'localname) + "/path/to/file")) + (should + (string-equal + (file-remote-p + "/method1:user1@host1|method2:user2@host2:/path/to/file" 'hop) + (format "%s:%s@%s|" + "method1" "user1" "host1"))) + + (should + (string-equal + (file-remote-p + (concat + "/method1:user1@host1" + "|method2:user2@host2" + "|method3:user3@host3:/path/to/file")) + (if tramp-show-ad-hoc-proxies + (concat + "/method1:user1@host1" + "|method2:user2@host2" + "|method3:user3@host3:") + "/method3:user3@host3:"))) + (should + (string-equal + (file-remote-p + (concat + "/method1:user1@host1" + "|method2:user2@host2" + "|method3:user3@host3:/path/to/file") + 'method) + "method3")) + (should + (string-equal + (file-remote-p + (concat + "/method1:user1@host1" + "|method2:user2@host2" + "|method3:user3@host3:/path/to/file") + 'user) + "user3")) + (should + (string-equal + (file-remote-p + (concat + "/method1:user1@host1" + "|method2:user2@host2" + "|method3:user3@host3:/path/to/file") + 'host) + "host3")) + (should + (string-equal + (file-remote-p + (concat + "/method1:user1@host1" + "|method2:user2@host2" + "|method3:user3@host3:/path/to/file") + 'localname) + "/path/to/file")) + (should + (string-equal + (file-remote-p + (concat + "/method1:user1@host1" + "|method2:user2@host2" + "|method3:user3@host3:/path/to/file") + 'hop) + (format "%s:%s@%s|%s:%s@%s|" + "method1" "user1" "host1" "method2" "user2" "host2"))) + + ;; Expand `tramp-default-method-alist'. + (add-to-list + 'tramp-default-method-alist '("host1" "user1" "method1")) + (add-to-list + 'tramp-default-method-alist '("host2" "user2" "method2")) + (add-to-list + 'tramp-default-method-alist '("host3" "user3" "method3")) + (should + (string-equal + (file-remote-p + (concat + "/-:user1@host1" + "|-:user2@host2" + "|-:user3@host3:/path/to/file")) + (if tramp-show-ad-hoc-proxies + (concat + "/method1:user1@host1" + "|method2:user2@host2" + "|method3:user3@host3:") + "/method3:user3@host3:"))) + + ;; Expand `tramp-default-user-alist'. + (add-to-list 'tramp-default-user-alist '("method1" "host1" "user1")) + (add-to-list 'tramp-default-user-alist '("method2" "host2" "user2")) + (add-to-list 'tramp-default-user-alist '("method3" "host3" "user3")) + (should + (string-equal + (file-remote-p + (concat + "/method1:host1" + "|method2:host2" + "|method3:host3:/path/to/file")) + (if tramp-show-ad-hoc-proxies + (concat + "/method1:user1@host1" + "|method2:user2@host2" + "|method3:user3@host3:") + "/method3:user3@host3:"))) + + ;; Expand `tramp-default-host-alist'. + (add-to-list 'tramp-default-host-alist '("method1" "user1" "host1")) + (add-to-list 'tramp-default-host-alist '("method2" "user2" "host2")) + (add-to-list 'tramp-default-host-alist '("method3" "user3" "host3")) + (should + (string-equal + (file-remote-p + (concat + "/method1:user1@" + "|method2:user2@" + "|method3:user3@:/path/to/file")) + (if tramp-show-ad-hoc-proxies + (concat + "/method1:user1@host1" + "|method2:user2@host2" + "|method3:user3@host3:") + "/method3:user3@host3:"))) + + ;; Ad-hoc user name and host name expansion. + (setq tramp-default-method-alist nil + tramp-default-user-alist nil + tramp-default-host-alist nil) + (should + (string-equal + (file-remote-p + (concat + "/method1:user1@host1" + "|method2:user2@" + "|method3:user3@:/path/to/file")) + (if tramp-show-ad-hoc-proxies + (concat + "/method1:user1@host1" + "|method2:user2@host1" + "|method3:user3@host1:") + "/method3:user3@host1:"))) + (should + (string-equal + (file-remote-p + (concat + "/method1:%u@%h" + "|method2:user2@host2" + "|method3:%u@%h" + "|method4:user4%domain4@host4#1234:/path/to/file")) + (if tramp-show-ad-hoc-proxies + (concat + "/method1:user2@host2" + "|method2:user2@host2" + "|method3:user4@host4" + "|method4:user4%domain4@host4#1234:") + "/method4:user4%domain4@host4#1234:"))))) ;; Exit. (tramp-change-syntax syntax)))) @@ -1007,6 +1057,7 @@ is greater than 10. (tramp-default-host "default-host") tramp-default-user-alist tramp-default-host-alist + tramp-default-proxies-alist ;; Suppress method name check. (non-essential t) ;; Suppress check for multihops. @@ -1178,137 +1229,178 @@ is greater than 10. "/path/to/file")) ;; Multihop. - (should - (string-equal - (file-remote-p "/user1@host1|user2@host2:/path/to/file") - "/user2@host2:")) - (should - (string-equal - (file-remote-p - "/user1@host1|user2@host2:/path/to/file" 'method) - "default-method")) - (should - (string-equal - (file-remote-p - "/user1@host1|user2@host2:/path/to/file" 'user) - "user2")) - (should - (string-equal - (file-remote-p - "/user1@host1|user2@host2:/path/to/file" 'host) - "host2")) - (should - (string-equal - (file-remote-p - "/user1@host1|user2@host2:/path/to/file" 'localname) - "/path/to/file")) - (should - (string-equal - (file-remote-p - "/user1@host1|user2@host2:/path/to/file" 'hop) - (format "%s@%s|" "user1" "host1"))) + (dolist (tramp-show-ad-hoc-proxies '(nil t)) - (should - (string-equal - (file-remote-p - (concat - "/user1@host1" - "|user2@host2" - "|user3@host3:/path/to/file")) - "/user3@host3:")) - (should - (string-equal - (file-remote-p - (concat - "/user1@host1" - "|user2@host2" - "|user3@host3:/path/to/file") - 'method) - "default-method")) - (should - (string-equal - (file-remote-p - (concat - "/user1@host1" - "|user2@host2" - "|user3@host3:/path/to/file") - 'user) - "user3")) - (should - (string-equal - (file-remote-p - (concat - "/user1@host1" - "|user2@host2" - "|user3@host3:/path/to/file") - 'host) - "host3")) - (should - (string-equal - (file-remote-p - (concat - "/user1@host1" - "|user2@host2" - "|user3@host3:/path/to/file") - 'localname) - "/path/to/file")) - (should - (string-equal - (file-remote-p - (concat - "/user1@host1" - "|user2@host2" - "|user3@host3:/path/to/file") - 'hop) - (format "%s@%s|%s@%s|" - "user1" "host1" "user2" "host2"))) - - ;; Expand `tramp-default-user-alist'. - (add-to-list 'tramp-default-user-alist '(nil "host1" "user1")) - (add-to-list 'tramp-default-user-alist '(nil "host2" "user2")) - (add-to-list 'tramp-default-user-alist '(nil "host3" "user3")) - (should - (string-equal - (file-remote-p - (concat - "/host1" - "|host2" - "|host3:/path/to/file")) - "/user3@host3:")) - - ;; Expand `tramp-default-host-alist'. - (add-to-list 'tramp-default-host-alist '(nil "user1" "host1")) - (add-to-list 'tramp-default-host-alist '(nil "user2" "host2")) - (add-to-list 'tramp-default-host-alist '(nil "user3" "host3")) - (should - (string-equal - (file-remote-p - (concat - "/user1@" - "|user2@" - "|user3@:/path/to/file")) - "/user3@host3:")) - - ;; Ad-hoc user name and host name expansion. - (setq tramp-default-user-alist nil - tramp-default-host-alist nil) - (should - (string-equal - (file-remote-p - (concat - "/user1@host1" - "|user2@" - "|user3@:/path/to/file")) - "/user3@host1:")) - (should - (string-equal - (file-remote-p - (concat - "/%u@%h" - "|user2@host2" - "|%u@%h" - "|user4%domain4@host4#1234:/path/to/file")) - "/user4%domain4@host4#1234:"))) + ;; Explicit settings in `tramp-default-proxies-alist' + ;; shouldn't show hops. + (setq tramp-default-proxies-alist + '(("^host2$" "^user2$" "/user1@host1:"))) + (should + (string-equal + (file-remote-p "/user2@host2:/path/to/file") + "/user2@host2:")) + (setq tramp-default-proxies-alist nil) + + ;; Ad-hoc settings. + (should + (string-equal + (file-remote-p "/user1@host1|user2@host2:/path/to/file") + (if tramp-show-ad-hoc-proxies + "/user1@host1|user2@host2:" + "/user2@host2:"))) + (should + (string-equal + (file-remote-p + "/user1@host1|user2@host2:/path/to/file" 'method) + "default-method")) + (should + (string-equal + (file-remote-p + "/user1@host1|user2@host2:/path/to/file" 'user) + "user2")) + (should + (string-equal + (file-remote-p + "/user1@host1|user2@host2:/path/to/file" 'host) + "host2")) + (should + (string-equal + (file-remote-p + "/user1@host1|user2@host2:/path/to/file" 'localname) + "/path/to/file")) + (should + (string-equal + (file-remote-p + "/user1@host1|user2@host2:/path/to/file" 'hop) + (format "%s@%s|" "user1" "host1"))) + + (should + (string-equal + (file-remote-p + (concat + "/user1@host1" + "|user2@host2" + "|user3@host3:/path/to/file")) + (if tramp-show-ad-hoc-proxies + (concat + "/user1@host1" + "|user2@host2" + "|user3@host3:") + "/user3@host3:"))) + (should + (string-equal + (file-remote-p + (concat + "/user1@host1" + "|user2@host2" + "|user3@host3:/path/to/file") + 'method) + "default-method")) + (should + (string-equal + (file-remote-p + (concat + "/user1@host1" + "|user2@host2" + "|user3@host3:/path/to/file") + 'user) + "user3")) + (should + (string-equal + (file-remote-p + (concat + "/user1@host1" + "|user2@host2" + "|user3@host3:/path/to/file") + 'host) + "host3")) + (should + (string-equal + (file-remote-p + (concat + "/user1@host1" + "|user2@host2" + "|user3@host3:/path/to/file") + 'localname) + "/path/to/file")) + (should + (string-equal + (file-remote-p + (concat + "/user1@host1" + "|user2@host2" + "|user3@host3:/path/to/file") + 'hop) + (format "%s@%s|%s@%s|" + "user1" "host1" "user2" "host2"))) + + ;; Expand `tramp-default-user-alist'. + (add-to-list 'tramp-default-user-alist '(nil "host1" "user1")) + (add-to-list 'tramp-default-user-alist '(nil "host2" "user2")) + (add-to-list 'tramp-default-user-alist '(nil "host3" "user3")) + (should + (string-equal + (file-remote-p + (concat + "/host1" + "|host2" + "|host3:/path/to/file")) + (if tramp-show-ad-hoc-proxies + (concat + "/user1@host1" + "|user2@host2" + "|user3@host3:") + "/user3@host3:"))) + + ;; Expand `tramp-default-host-alist'. + (add-to-list 'tramp-default-host-alist '(nil "user1" "host1")) + (add-to-list 'tramp-default-host-alist '(nil "user2" "host2")) + (add-to-list 'tramp-default-host-alist '(nil "user3" "host3")) + (should + (string-equal + (file-remote-p + (concat + "/user1@" + "|user2@" + "|user3@:/path/to/file")) + (if tramp-show-ad-hoc-proxies + (concat + "/user1@host1" + "|user2@host2" + "|user3@host3:") + "/user3@host3:"))) + + ;; Ad-hoc user name and host name expansion. + (setq tramp-default-user-alist nil + tramp-default-host-alist nil) + (should + (string-equal + (file-remote-p + (concat + "/user1@host1" + "|user2@" + "|user3@:/path/to/file")) + (if tramp-show-ad-hoc-proxies + (concat + "/user1@host1" + "|user2@host1" + "|user3@host1:") + "/user3@host1:"))) + (should + (string-equal + (file-remote-p + (concat + "/%u@%h" + "|user2@host2" + "|%u@%h" + "|user4%domain4@host4#1234:/path/to/file")) + (if tramp-show-ad-hoc-proxies + (concat + "/user2@host2" + "|user2@host2" + "|user4@host4" + "|user4%domain4@host4#1234:") + "/user4%domain4@host4#1234:"))))) ;; Exit. (tramp-change-syntax syntax)))) @@ -1322,6 +1414,7 @@ is greater than 10. tramp-default-method-alist tramp-default-user-alist tramp-default-host-alist + tramp-default-proxies-alist ;; Suppress method name check. (non-essential t) ;; Suppress check for multihops. @@ -1794,154 +1887,203 @@ is greater than 10. "/path/to/file")) ;; Multihop. - (should - (string-equal - (file-remote-p - "/[method1/user1@host1|method2/user2@host2]/path/to/file") - "/[method2/user2@host2]")) - (should - (string-equal - (file-remote-p - "/[method1/user1@host1|method2/user2@host2]/path/to/file" 'method) - "method2")) - (should - (string-equal - (file-remote-p - "/[method1/user1@host1|method2/user2@host2]/path/to/file" 'user) - "user2")) - (should - (string-equal - (file-remote-p - "/[method1/user1@host1|method2/user2@host2]/path/to/file" 'host) - "host2")) - (should - (string-equal - (file-remote-p - "/[method1/user1@host1|method2/user2@host2]/path/to/file" - 'localname) - "/path/to/file")) - (should - (string-equal - (file-remote-p - "/[method1/user1@host1|method2/user2@host2]/path/to/file" 'hop) - (format "%s/%s@%s|" - "method1" "user1" "host1"))) + (dolist (tramp-show-ad-hoc-proxies '(nil t)) - (should - (string-equal - (file-remote-p - (concat - "/[method1/user1@host1" - "|method2/user2@host2" - "|method3/user3@host3]/path/to/file")) - "/[method3/user3@host3]")) - (should - (string-equal - (file-remote-p - (concat - "/[method1/user1@host1" - "|method2/user2@host2" - "|method3/user3@host3]/path/to/file") - 'method) - "method3")) - (should - (string-equal - (file-remote-p - (concat - "/[method1/user1@host1" - "|method2/user2@host2" - "|method3/user3@host3]/path/to/file") - 'user) - "user3")) - (should - (string-equal - (file-remote-p - (concat - "/[method1/user1@host1" - "|method2/user2@host2" - "|method3/user3@host3]/path/to/file") - 'host) - "host3")) - (should - (string-equal - (file-remote-p - (concat - "/[method1/user1@host1" - "|method2/user2@host2" - "|method3/user3@host3]/path/to/file") - 'localname) - "/path/to/file")) - (should - (string-equal - (file-remote-p - (concat - "/[method1/user1@host1" - "|method2/user2@host2" - "|method3/user3@host3]/path/to/file") - 'hop) - (format "%s/%s@%s|%s/%s@%s|" - "method1" "user1" "host1" "method2" "user2" "host2"))) - - ;; Expand `tramp-default-method-alist'. - (add-to-list 'tramp-default-method-alist '("host1" "user1" "method1")) - (add-to-list 'tramp-default-method-alist '("host2" "user2" "method2")) - (add-to-list 'tramp-default-method-alist '("host3" "user3" "method3")) - (should - (string-equal - (file-remote-p - (concat - "/[/user1@host1" - "|/user2@host2" - "|/user3@host3]/path/to/file")) - "/[method3/user3@host3]")) - - ;; Expand `tramp-default-user-alist'. - (add-to-list 'tramp-default-user-alist '("method1" "host1" "user1")) - (add-to-list 'tramp-default-user-alist '("method2" "host2" "user2")) - (add-to-list 'tramp-default-user-alist '("method3" "host3" "user3")) - (should - (string-equal - (file-remote-p - (concat - "/[method1/host1" - "|method2/host2" - "|method3/host3]/path/to/file")) - "/[method3/user3@host3]")) - - ;; Expand `tramp-default-host-alist'. - (add-to-list 'tramp-default-host-alist '("method1" "user1" "host1")) - (add-to-list 'tramp-default-host-alist '("method2" "user2" "host2")) - (add-to-list 'tramp-default-host-alist '("method3" "user3" "host3")) - (should - (string-equal - (file-remote-p - (concat - "/[method1/user1@" - "|method2/user2@" - "|method3/user3@]/path/to/file")) - "/[method3/user3@host3]")) - - ;; Ad-hoc user name and host name expansion. - (setq tramp-default-method-alist nil - tramp-default-user-alist nil - tramp-default-host-alist nil) - (should - (string-equal - (file-remote-p - (concat - "/[method1/user1@host1" - "|method2/user2@" - "|method3/user3@]/path/to/file")) - "/[method3/user3@host1]")) - (should - (string-equal - (file-remote-p - (concat - "/[method1/%u@%h" - "|method2/user2@host2" - "|method3/%u@%h" - "|method4/user4%domain4@host4#1234]/path/to/file")) - "/[method4/user4%domain4@host4#1234]"))) + ;; Explicit settings in `tramp-default-proxies-alist' + ;; shouldn't show hops. + (setq tramp-default-proxies-alist + '(("^host2$" "^user2$" "/[method1/user1@host1]"))) + (should + (string-equal + (file-remote-p "/[method2/user2@host2]/path/to/file") + "/[method2/user2@host2]")) + (setq tramp-default-proxies-alist nil) + + ;; Ad-hoc settings. + (should + (string-equal + (file-remote-p + "/[method1/user1@host1|method2/user2@host2]/path/to/file") + (if tramp-show-ad-hoc-proxies + "/[method1/user1@host1|method2/user2@host2]" + "/[method2/user2@host2]"))) + (should + (string-equal + (file-remote-p + "/[method1/user1@host1|method2/user2@host2]/path/to/file" 'method) + "method2")) + (should + (string-equal + (file-remote-p + "/[method1/user1@host1|method2/user2@host2]/path/to/file" 'user) + "user2")) + (should + (string-equal + (file-remote-p + "/[method1/user1@host1|method2/user2@host2]/path/to/file" 'host) + "host2")) + (should + (string-equal + (file-remote-p + "/[method1/user1@host1|method2/user2@host2]/path/to/file" + 'localname) + "/path/to/file")) + (should + (string-equal + (file-remote-p + "/[method1/user1@host1|method2/user2@host2]/path/to/file" 'hop) + (format "%s/%s@%s|" + "method1" "user1" "host1"))) + + (should + (string-equal + (file-remote-p + (concat + "/[method1/user1@host1" + "|method2/user2@host2" + "|method3/user3@host3]/path/to/file")) + (if tramp-show-ad-hoc-proxies + (concat + "/[method1/user1@host1" + "|method2/user2@host2" + "|method3/user3@host3]") + "/[method3/user3@host3]"))) + (should + (string-equal + (file-remote-p + (concat + "/[method1/user1@host1" + "|method2/user2@host2" + "|method3/user3@host3]/path/to/file") + 'method) + "method3")) + (should + (string-equal + (file-remote-p + (concat + "/[method1/user1@host1" + "|method2/user2@host2" + "|method3/user3@host3]/path/to/file") + 'user) + "user3")) + (should + (string-equal + (file-remote-p + (concat + "/[method1/user1@host1" + "|method2/user2@host2" + "|method3/user3@host3]/path/to/file") + 'host) + "host3")) + (should + (string-equal + (file-remote-p + (concat + "/[method1/user1@host1" + "|method2/user2@host2" + "|method3/user3@host3]/path/to/file") + 'localname) + "/path/to/file")) + (should + (string-equal + (file-remote-p + (concat + "/[method1/user1@host1" + "|method2/user2@host2" + "|method3/user3@host3]/path/to/file") + 'hop) + (format "%s/%s@%s|%s/%s@%s|" + "method1" "user1" "host1" "method2" "user2" "host2"))) + + ;; Expand `tramp-default-method-alist'. + (add-to-list + 'tramp-default-method-alist '("host1" "user1" "method1")) + (add-to-list + 'tramp-default-method-alist '("host2" "user2" "method2")) + (add-to-list + 'tramp-default-method-alist '("host3" "user3" "method3")) + (should + (string-equal + (file-remote-p + (concat + "/[/user1@host1" + "|/user2@host2" + "|/user3@host3]/path/to/file")) + (if tramp-show-ad-hoc-proxies + (concat + "/[method1/user1@host1" + "|method2/user2@host2" + "|method3/user3@host3]") + "/[method3/user3@host3]"))) + + ;; Expand `tramp-default-user-alist'. + (add-to-list 'tramp-default-user-alist '("method1" "host1" "user1")) + (add-to-list 'tramp-default-user-alist '("method2" "host2" "user2")) + (add-to-list 'tramp-default-user-alist '("method3" "host3" "user3")) + (should + (string-equal + (file-remote-p + (concat + "/[method1/host1" + "|method2/host2" + "|method3/host3]/path/to/file")) + (if tramp-show-ad-hoc-proxies + (concat + "/[method1/user1@host1" + "|method2/user2@host2" + "|method3/user3@host3]") + "/[method3/user3@host3]"))) + + ;; Expand `tramp-default-host-alist'. + (add-to-list 'tramp-default-host-alist '("method1" "user1" "host1")) + (add-to-list 'tramp-default-host-alist '("method2" "user2" "host2")) + (add-to-list 'tramp-default-host-alist '("method3" "user3" "host3")) + (should + (string-equal + (file-remote-p + (concat + "/[method1/user1@" + "|method2/user2@" + "|method3/user3@]/path/to/file")) + (if tramp-show-ad-hoc-proxies + (concat + "/[method1/user1@host1" + "|method2/user2@host2" + "|method3/user3@host3]") + "/[method3/user3@host3]"))) + + ;; Ad-hoc user name and host name expansion. + (setq tramp-default-method-alist nil + tramp-default-user-alist nil + tramp-default-host-alist nil) + (should + (string-equal + (file-remote-p + (concat + "/[method1/user1@host1" + "|method2/user2@" + "|method3/user3@]/path/to/file")) + (if tramp-show-ad-hoc-proxies + (concat + "/[method1/user1@host1" + "|method2/user2@host1" + "|method3/user3@host1]") + "/[method3/user3@host1]"))) + (should + (string-equal + (file-remote-p + (concat + "/[method1/%u@%h" + "|method2/user2@host2" + "|method3/%u@%h" + "|method4/user4%domain4@host4#1234]/path/to/file")) + (if tramp-show-ad-hoc-proxies + (concat + "/[method1/user2@host2" + "|method2/user2@host2" + "|method3/user4@host4" + "|method4/user4%domain4@host4#1234]") + "/[method4/user4%domain4@host4#1234]"))))) ;; Exit. (tramp-change-syntax syntax)))) |