diff options
| author | Michael Albinus | 2018-10-20 13:38:31 +0200 |
|---|---|---|
| committer | Michael Albinus | 2018-10-20 13:38:31 +0200 |
| commit | 67d3b40e0cba5f34b1c7aacc4e1ccea6300eae76 (patch) | |
| tree | 992635f6f00e83aea36a3e2de1ceff1a29c03da8 /test | |
| parent | efb214622a0f4e077c09e721d134552dfe76ef70 (diff) | |
| download | emacs-67d3b40e0cba5f34b1c7aacc4e1ccea6300eae76.tar.gz emacs-67d3b40e0cba5f34b1c7aacc4e1ccea6300eae76.zip | |
Expand host names in Tramp's ad-hoc multi-hop file names
* doc/misc/tramp.texi (Quick Start Guide): Improve wording.
(Change file name syntax): Say, that `tramp-file-name-regexp' is
not constant.
(Ad-hoc multi-hops): Explain host name expansion.
* etc/NEWS: Mention that host names in Tramp ad-hoc multi-hop file
names must match the previous hop for methods like "su" or "sudo".
Fix typos.
* lisp/net/tramp.el (tramp-find-method, tramp-find-user):
Adapt docstring.
(tramp-find-host): Mark default value.
(tramp-dissect-file-name): Expand host name for hops.
(tramp-dissect-hop-name, tramp-make-tramp-hop-name): New defuns.
(tramp-clear-passwd): Simplify.
* test/lisp/net/tramp-tests.el (tramp-test02-file-name-dissect)
(tramp-test02-file-name-dissect-simplified)
(tramp-test02-file-name-dissect-separate)
(tramp-test26-file-name-completion): Extend tests.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 131 |
1 files changed, 108 insertions, 23 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 6a08cbb5ab2..ceda70947c8 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -763,8 +763,8 @@ handled properly. BODY shall not contain a timeout." | |||
| 763 | "|-:user2@host2" | 763 | "|-:user2@host2" |
| 764 | "|-:user3@host3:/path/to/file")) | 764 | "|-:user3@host3:/path/to/file")) |
| 765 | (format "/%s:%s@%s|%s:%s@%s|%s:%s@%s:" | 765 | (format "/%s:%s@%s|%s:%s@%s|%s:%s@%s:" |
| 766 | "-" "user1" "host1" | 766 | "method1" "user1" "host1" |
| 767 | "-" "user2" "host2" | 767 | "method2" "user2" "host2" |
| 768 | "method3" "user3" "host3"))) | 768 | "method3" "user3" "host3"))) |
| 769 | 769 | ||
| 770 | ;; Expand `tramp-default-user-alist'. | 770 | ;; Expand `tramp-default-user-alist'. |
| @@ -778,9 +778,9 @@ handled properly. BODY shall not contain a timeout." | |||
| 778 | "/method1:host1" | 778 | "/method1:host1" |
| 779 | "|method2:host2" | 779 | "|method2:host2" |
| 780 | "|method3:host3:/path/to/file")) | 780 | "|method3:host3:/path/to/file")) |
| 781 | (format "/%s:%s|%s:%s|%s:%s@%s:" | 781 | (format "/%s:%s@%s|%s:%s@%s|%s:%s@%s:" |
| 782 | "method1" "host1" | 782 | "method1" "user1" "host1" |
| 783 | "method2" "host2" | 783 | "method2" "user2" "host2" |
| 784 | "method3" "user3" "host3"))) | 784 | "method3" "user3" "host3"))) |
| 785 | 785 | ||
| 786 | ;; Expand `tramp-default-host-alist'. | 786 | ;; Expand `tramp-default-host-alist'. |
| @@ -794,9 +794,36 @@ handled properly. BODY shall not contain a timeout." | |||
| 794 | "/method1:user1@" | 794 | "/method1:user1@" |
| 795 | "|method2:user2@" | 795 | "|method2:user2@" |
| 796 | "|method3:user3@:/path/to/file")) | 796 | "|method3:user3@:/path/to/file")) |
| 797 | (format "/%s:%s@|%s:%s@|%s:%s@%s:" | 797 | (format "/%s:%s@%s|%s:%s@%s|%s:%s@%s:" |
| 798 | "method1" "user1" | 798 | "method1" "user1" "host1" |
| 799 | "method2" "user2" | 799 | "method2" "user2" "host2" |
| 800 | "method3" "user3" "host3"))) | ||
| 801 | |||
| 802 | ;; Ad-hoc user name and host name expansion. | ||
| 803 | (setq tramp-default-method-alist nil | ||
| 804 | tramp-default-user-alist nil | ||
| 805 | tramp-default-host-alist nil) | ||
| 806 | (should | ||
| 807 | (string-equal | ||
| 808 | (file-remote-p | ||
| 809 | (concat | ||
| 810 | "/method1:user1@host1" | ||
| 811 | "|method2:user2@" | ||
| 812 | "|method3:user3@:/path/to/file")) | ||
| 813 | (format "/%s:%s@%s|%s:%s@%s|%s:%s@%s:" | ||
| 814 | "method1" "user1" "host1" | ||
| 815 | "method2" "user2" "host1" | ||
| 816 | "method3" "user3" "host1"))) | ||
| 817 | (should | ||
| 818 | (string-equal | ||
| 819 | (file-remote-p | ||
| 820 | (concat | ||
| 821 | "/method1:%u@%h" | ||
| 822 | "|method2:%u@%h" | ||
| 823 | "|method3:user3@host3:/path/to/file")) | ||
| 824 | (format "/%s:%s@%s|%s:%s@%s|%s:%s@%s:" | ||
| 825 | "method1" "user3" "host3" | ||
| 826 | "method2" "user3" "host3" | ||
| 800 | "method3" "user3" "host3"))))) | 827 | "method3" "user3" "host3"))))) |
| 801 | 828 | ||
| 802 | (ert-deftest tramp-test02-file-name-dissect-simplified () | 829 | (ert-deftest tramp-test02-file-name-dissect-simplified () |
| @@ -1067,9 +1094,9 @@ handled properly. BODY shall not contain a timeout." | |||
| 1067 | "/host1" | 1094 | "/host1" |
| 1068 | "|host2" | 1095 | "|host2" |
| 1069 | "|host3:/path/to/file")) | 1096 | "|host3:/path/to/file")) |
| 1070 | (format "/%s|%s|%s@%s:" | 1097 | (format "/%s@%s|%s@%s|%s@%s:" |
| 1071 | "host1" | 1098 | "user1" "host1" |
| 1072 | "host2" | 1099 | "user2" "host2" |
| 1073 | "user3" "host3"))) | 1100 | "user3" "host3"))) |
| 1074 | 1101 | ||
| 1075 | ;; Expand `tramp-default-host-alist'. | 1102 | ;; Expand `tramp-default-host-alist'. |
| @@ -1083,9 +1110,35 @@ handled properly. BODY shall not contain a timeout." | |||
| 1083 | "/user1@" | 1110 | "/user1@" |
| 1084 | "|user2@" | 1111 | "|user2@" |
| 1085 | "|user3@:/path/to/file")) | 1112 | "|user3@:/path/to/file")) |
| 1086 | (format "/%s@|%s@|%s@%s:" | 1113 | (format "/%s@%s|%s@%s|%s@%s:" |
| 1087 | "user1" | 1114 | "user1" "host1" |
| 1088 | "user2" | 1115 | "user2" "host2" |
| 1116 | "user3" "host3"))) | ||
| 1117 | |||
| 1118 | ;; Ad-hoc user name and host name expansion. | ||
| 1119 | (setq tramp-default-user-alist nil | ||
| 1120 | tramp-default-host-alist nil) | ||
| 1121 | (should | ||
| 1122 | (string-equal | ||
| 1123 | (file-remote-p | ||
| 1124 | (concat | ||
| 1125 | "/user1@host1" | ||
| 1126 | "|user2@" | ||
| 1127 | "|user3@:/path/to/file")) | ||
| 1128 | (format "/%s@%s|%s@%s|%s@%s:" | ||
| 1129 | "user1" "host1" | ||
| 1130 | "user2" "host1" | ||
| 1131 | "user3" "host1"))) | ||
| 1132 | (should | ||
| 1133 | (string-equal | ||
| 1134 | (file-remote-p | ||
| 1135 | (concat | ||
| 1136 | "/%u@%h" | ||
| 1137 | "|%u@%h" | ||
| 1138 | "|user3@host3:/path/to/file")) | ||
| 1139 | (format "/%s@%s|%s@%s|%s@%s:" | ||
| 1140 | "user3" "host3" | ||
| 1141 | "user3" "host3" | ||
| 1089 | "user3" "host3")))) | 1142 | "user3" "host3")))) |
| 1090 | 1143 | ||
| 1091 | ;; Exit. | 1144 | ;; Exit. |
| @@ -1670,9 +1723,9 @@ handled properly. BODY shall not contain a timeout." | |||
| 1670 | "/[/user1@host1" | 1723 | "/[/user1@host1" |
| 1671 | "|/user2@host2" | 1724 | "|/user2@host2" |
| 1672 | "|/user3@host3]/path/to/file")) | 1725 | "|/user3@host3]/path/to/file")) |
| 1673 | (format "/[/%s@%s|/%s@%s|%s/%s@%s]" | 1726 | (format "/[%s/%s@%s|%s/%s@%s|%s/%s@%s]" |
| 1674 | "user1" "host1" | 1727 | "method1" "user1" "host1" |
| 1675 | "user2" "host2" | 1728 | "method2" "user2" "host2" |
| 1676 | "method3" "user3" "host3"))) | 1729 | "method3" "user3" "host3"))) |
| 1677 | 1730 | ||
| 1678 | ;; Expand `tramp-default-user-alist'. | 1731 | ;; Expand `tramp-default-user-alist'. |
| @@ -1686,9 +1739,9 @@ handled properly. BODY shall not contain a timeout." | |||
| 1686 | "/[method1/host1" | 1739 | "/[method1/host1" |
| 1687 | "|method2/host2" | 1740 | "|method2/host2" |
| 1688 | "|method3/host3]/path/to/file")) | 1741 | "|method3/host3]/path/to/file")) |
| 1689 | (format "/[%s/%s|%s/%s|%s/%s@%s]" | 1742 | (format "/[%s/%s@%s|%s/%s@%s|%s/%s@%s]" |
| 1690 | "method1" "host1" | 1743 | "method1" "user1" "host1" |
| 1691 | "method2" "host2" | 1744 | "method2" "user2" "host2" |
| 1692 | "method3" "user3" "host3"))) | 1745 | "method3" "user3" "host3"))) |
| 1693 | 1746 | ||
| 1694 | ;; Expand `tramp-default-host-alist'. | 1747 | ;; Expand `tramp-default-host-alist'. |
| @@ -1702,9 +1755,36 @@ handled properly. BODY shall not contain a timeout." | |||
| 1702 | "/[method1/user1@" | 1755 | "/[method1/user1@" |
| 1703 | "|method2/user2@" | 1756 | "|method2/user2@" |
| 1704 | "|method3/user3@]/path/to/file")) | 1757 | "|method3/user3@]/path/to/file")) |
| 1705 | (format "/[%s/%s@|%s/%s@|%s/%s@%s]" | 1758 | (format "/[%s/%s@%s|%s/%s@%s|%s/%s@%s]" |
| 1706 | "method1" "user1" | 1759 | "method1" "user1" "host1" |
| 1707 | "method2" "user2" | 1760 | "method2" "user2" "host2" |
| 1761 | "method3" "user3" "host3"))) | ||
| 1762 | |||
| 1763 | ;; Ad-hoc user name and host name expansion. | ||
| 1764 | (setq tramp-default-method-alist nil | ||
| 1765 | tramp-default-user-alist nil | ||
| 1766 | tramp-default-host-alist nil) | ||
| 1767 | (should | ||
| 1768 | (string-equal | ||
| 1769 | (file-remote-p | ||
| 1770 | (concat | ||
| 1771 | "/[method1/user1@host1" | ||
| 1772 | "|method2/user2@" | ||
| 1773 | "|method3/user3@]/path/to/file")) | ||
| 1774 | (format "/[%s/%s@%s|%s/%s@%s|%s/%s@%s]" | ||
| 1775 | "method1" "user1" "host1" | ||
| 1776 | "method2" "user2" "host1" | ||
| 1777 | "method3" "user3" "host1"))) | ||
| 1778 | (should | ||
| 1779 | (string-equal | ||
| 1780 | (file-remote-p | ||
| 1781 | (concat | ||
| 1782 | "/[method1/%u@%h" | ||
| 1783 | "|method2/%u@%h" | ||
| 1784 | "|method3/user3@host3]/path/to/file")) | ||
| 1785 | (format "/[%s/%s@%s|%s/%s@%s|%s/%s@%s]" | ||
| 1786 | "method1" "user3" "host3" | ||
| 1787 | "method2" "user3" "host3" | ||
| 1708 | "method3" "user3" "host3")))) | 1788 | "method3" "user3" "host3")))) |
| 1709 | 1789 | ||
| 1710 | ;; Exit. | 1790 | ;; Exit. |
| @@ -3491,6 +3571,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 3491 | (when (not (memq system-type '(cygwin windows-nt))) | 3571 | (when (not (memq system-type '(cygwin windows-nt))) |
| 3492 | (let ((method (file-remote-p tramp-test-temporary-file-directory 'method)) | 3572 | (let ((method (file-remote-p tramp-test-temporary-file-directory 'method)) |
| 3493 | (host (file-remote-p tramp-test-temporary-file-directory 'host)) | 3573 | (host (file-remote-p tramp-test-temporary-file-directory 'host)) |
| 3574 | (vec (tramp-dissect-file-name tramp-test-temporary-file-directory)) | ||
| 3494 | (orig-syntax tramp-syntax)) | 3575 | (orig-syntax tramp-syntax)) |
| 3495 | (when (and (stringp host) (string-match tramp-host-with-port-regexp host)) | 3576 | (when (and (stringp host) (string-match tramp-host-with-port-regexp host)) |
| 3496 | (setq host (match-string 1 host))) | 3577 | (setq host (match-string 1 host))) |
| @@ -3501,6 +3582,10 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 3501 | (if (tramp--test-expensive-test) | 3582 | (if (tramp--test-expensive-test) |
| 3502 | (tramp-syntax-values) `(,orig-syntax))) | 3583 | (tramp-syntax-values) `(,orig-syntax))) |
| 3503 | (tramp-change-syntax syntax) | 3584 | (tramp-change-syntax syntax) |
| 3585 | ;; This has cleaned up all connection data, which are used | ||
| 3586 | ;; for completion. We must refill the cache. | ||
| 3587 | (tramp-set-connection-property vec "property" nil) | ||
| 3588 | |||
| 3504 | (let ;; This is needed for the `simplified' syntax. | 3589 | (let ;; This is needed for the `simplified' syntax. |
| 3505 | ((method-marker | 3590 | ((method-marker |
| 3506 | (if (zerop (length tramp-method-regexp)) | 3591 | (if (zerop (length tramp-method-regexp)) |