aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMichael Albinus2024-07-22 09:56:52 +0200
committerMichael Albinus2024-07-22 09:56:52 +0200
commitf050b9c5033ef92ac299d3da30774bc228fd0e08 (patch)
tree8449e1a470b45666af5672b20f1fb5b6f863e7b6 /test
parent46b192c04b162519a5e88bbf0f465a7c5e1171a9 (diff)
downloademacs-f050b9c5033ef92ac299d3da30774bc228fd0e08.tar.gz
emacs-f050b9c5033ef92ac299d3da30774bc228fd0e08.zip
Fix Tramp IPv6 handling in tests
* lisp/net/tramp-gvfs.el (tramp-gvfs-maybe-open-connection): * lisp/net/tramp-sh.el (tramp-maybe-open-connection): Improve message. * lisp/net/tramp-integration.el (shortdoc): Add further examples of `file-remote-p'. * lisp/net/tramp.el (tramp-handle-file-remote-p): Extend docstring. * test/lisp/net/tramp-tests.el (tramp-test02-file-name-dissect) (tramp-test02-file-name-dissect-simplified) (tramp-test02-file-name-dissect-separate): Extend tests. (tramp-test06-directory-file-name) (tramp-test26-file-name-completion) (tramp-test26-interactive-file-name-completion): Better handling of IPv6 hosts.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/net/tramp-tests.el82
1 files changed, 55 insertions, 27 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 786700c727e..e958cd354bc 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -848,19 +848,20 @@ is greater than 10.
848 (should (string-equal (file-remote-p "/method:[::1]:" 'localname) "")) 848 (should (string-equal (file-remote-p "/method:[::1]:" 'localname) ""))
849 (should (string-equal (file-remote-p "/method:[::1]:" 'hop) nil)) 849 (should (string-equal (file-remote-p "/method:[::1]:" 'hop) nil))
850 850
851 ;; No expansion. 851 ;; No expansion. Hop.
852 (should (string-equal 852 (should (string-equal
853 (file-remote-p "/method:user@[::1]:") 853 (file-remote-p "/method:user@[::1]#1234:")
854 (format "/%s:%s@%s:" "method" "user" "[::1]"))) 854 (format "/%s:%s@%s#%s:" "method" "user" "[::1]" "1234")))
855 (should (string-equal 855 (should (string-equal
856 (file-remote-p "/method:user@[::1]:" 'method) "method")) 856 (file-remote-p "/method:user@[::1]#1234:" 'method) "method"))
857 (should 857 (should (string-equal (file-remote-p "/method:user@[::1]#1234:" 'user)
858 (string-equal (file-remote-p "/method:user@[::1]:" 'user) "user")) 858 "user"))
859 (should 859 (should (string-equal
860 (string-equal (file-remote-p "/method:user@[::1]:" 'host) "::1")) 860 (file-remote-p "/method:user@[::1]#1234:" 'host) "::1#1234"))
861 (should (string-equal 861 (should (string-equal
862 (file-remote-p "/method:user@[::1]:" 'localname) "")) 862 (file-remote-p "/method:user@[::1]#1234:" 'localname) ""))
863 (should (string-equal (file-remote-p "/method:user@[::1]:" 'hop) nil)) 863 (should (string-equal
864 (file-remote-p "/method:user@[::1]#1234:" 'hop) nil))
864 865
865 ;; Local file name part. 866 ;; Local file name part.
866 (should (string-equal (file-remote-p "/-:host:/:" 'localname) "/:")) 867 (should (string-equal (file-remote-p "/-:host:/:" 'localname) "/:"))
@@ -1244,6 +1245,20 @@ is greater than 10.
1244 (should (string-equal (file-remote-p "/user@[::1]:" 'localname) "")) 1245 (should (string-equal (file-remote-p "/user@[::1]:" 'localname) ""))
1245 (should (string-equal (file-remote-p "/user@[::1]:" 'hop) nil)) 1246 (should (string-equal (file-remote-p "/user@[::1]:" 'hop) nil))
1246 1247
1248 ;; No expansion. Hop.
1249 (should (string-equal
1250 (file-remote-p "/user@[::1]#1234:")
1251 (format "/%s@%s#%s:" "user" "[::1]" "1234")))
1252 (should (string-equal
1253 (file-remote-p "/user@[::1]#1234:" 'method) "default-method"))
1254 (should
1255 (string-equal (file-remote-p "/user@[::1]#1234:" 'user) "user"))
1256 (should
1257 (string-equal (file-remote-p "/user@[::1]#1234:" 'host) "::1#1234"))
1258 (should
1259 (string-equal (file-remote-p "/user@[::1]#1234:" 'localname) ""))
1260 (should (string-equal (file-remote-p "/user@[::1]#1234:" 'hop) nil))
1261
1247 ;; Local file name part. 1262 ;; Local file name part.
1248 (should (string-equal (file-remote-p "/host:/:" 'localname) "/:")) 1263 (should (string-equal (file-remote-p "/host:/:" 'localname) "/:"))
1249 (should (string-equal (file-remote-p "/host::" 'localname) ":")) 1264 (should (string-equal (file-remote-p "/host::" 'localname) ":"))
@@ -1886,19 +1901,20 @@ is greater than 10.
1886 (should (string-equal (file-remote-p "/[method/::1]" 'localname) "")) 1901 (should (string-equal (file-remote-p "/[method/::1]" 'localname) ""))
1887 (should (string-equal (file-remote-p "/[method/::1]" 'hop) nil)) 1902 (should (string-equal (file-remote-p "/[method/::1]" 'hop) nil))
1888 1903
1889 ;; No expansion. 1904 ;; No expansion. Hop.
1905 (should (string-equal
1906 (file-remote-p "/[method/user@::1#1234]")
1907 (format "/[%s/%s@%s#%s]" "method" "user" "::1" "1234")))
1890 (should (string-equal 1908 (should (string-equal
1891 (file-remote-p "/[method/user@::1]") 1909 (file-remote-p "/[method/user@::1#1234]" 'method) "method"))
1892 (format "/[%s/%s@%s]" "method" "user" "::1")))
1893 (should (string-equal 1910 (should (string-equal
1894 (file-remote-p "/[method/user@::1]" 'method) "method")) 1911 (file-remote-p "/[method/user@::1#1234]" 'user) "user"))
1895 (should (string-equal 1912 (should (string-equal
1896 (file-remote-p "/[method/user@::1]" 'user) "user")) 1913 (file-remote-p "/[method/user@::1#1234]" 'host) "::1#1234"))
1897 (should (string-equal 1914 (should (string-equal
1898 (file-remote-p "/[method/user@::1]" 'host) "::1")) 1915 (file-remote-p "/[method/user@::1#1234]" 'localname) ""))
1899 (should (string-equal 1916 (should (string-equal
1900 (file-remote-p "/[method/user@::1]" 'localname) "")) 1917 (file-remote-p "/[method/user@::1#1234]" 'hop) nil))
1901 (should (string-equal (file-remote-p "/[method/user@::1]" 'hop) nil))
1902 1918
1903 ;; Local file name part. 1919 ;; Local file name part.
1904 (should (string-equal (file-remote-p "/[/host]/:" 'localname) "/:")) 1920 (should (string-equal (file-remote-p "/[/host]/:" 'localname) "/:"))
@@ -2425,16 +2441,22 @@ This checks also `file-name-as-directory', `file-name-directory',
2425 ;; which ruins the tests. 2441 ;; which ruins the tests.
2426 (let ((tramp-default-method 2442 (let ((tramp-default-method
2427 (file-remote-p ert-remote-temporary-file-directory 'method)) 2443 (file-remote-p ert-remote-temporary-file-directory 'method))
2428 (host (file-remote-p ert-remote-temporary-file-directory 'host))) 2444 (host-port
2445 (file-remote-p ert-remote-temporary-file-directory 'host)))
2429 (dolist 2446 (dolist
2430 (file 2447 (file
2431 `(,(format "/%s::" tramp-default-method) 2448 `(,(format "/%s::" tramp-default-method)
2432 ,(format 2449 ,(format
2433 "/-:%s:" 2450 "/-:%s:"
2434 (if (string-match-p tramp-ipv6-regexp host) 2451 ;; `(file-remote-p ... 'host)' eliminates IPv6
2435 (concat 2452 ;; delimiters. Add them.
2436 tramp-prefix-ipv6-format host tramp-postfix-ipv6-format) 2453 (if (string-match tramp-ipv6-regexp host-port)
2437 host)))) 2454 (replace-match
2455 (format
2456 "%s\\&%s"
2457 tramp-prefix-ipv6-format tramp-postfix-ipv6-format)
2458 nil nil host-port)
2459 host-port))))
2438 (should (string-equal (directory-file-name file) file)) 2460 (should (string-equal (directory-file-name file) file))
2439 (should 2461 (should
2440 (string-equal 2462 (string-equal
@@ -4796,8 +4818,11 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4796 (host (file-remote-p ert-remote-temporary-file-directory 'host)) 4818 (host (file-remote-p ert-remote-temporary-file-directory 'host))
4797 (orig-syntax tramp-syntax) 4819 (orig-syntax tramp-syntax)
4798 (minibuffer-completing-file-name t)) 4820 (minibuffer-completing-file-name t))
4799 (when (and (stringp host) (string-match tramp-host-with-port-regexp host)) 4821 (when (and (stringp host)
4800 (setq host (match-string 1 host))) 4822 (string-match
4823 (rx (regexp tramp-prefix-port-regexp) (regexp tramp-port-regexp))
4824 host))
4825 (setq host (replace-match "" nil nil host)))
4801 4826
4802 (unwind-protect 4827 (unwind-protect
4803 (dolist (syntax (if (tramp--test-expensive-test-p) 4828 (dolist (syntax (if (tramp--test-expensive-test-p)
@@ -4930,8 +4955,11 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4930 (orig-syntax tramp-syntax) 4955 (orig-syntax tramp-syntax)
4931 (non-essential t) 4956 (non-essential t)
4932 (inhibit-message t)) 4957 (inhibit-message t))
4933 (when (and (stringp host) (string-match tramp-host-with-port-regexp host)) 4958 (when (and (stringp host)
4934 (setq host (match-string 1 host))) 4959 (string-match
4960 (rx (regexp tramp-prefix-port-regexp) (regexp tramp-port-regexp))
4961 host))
4962 (setq host (replace-match "" nil nil host)))
4935 4963
4936 ;; (trace-function #'tramp-completion-file-name-handler) 4964 ;; (trace-function #'tramp-completion-file-name-handler)
4937 ;; (trace-function #'completion-file-name-table) 4965 ;; (trace-function #'completion-file-name-table)