aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2025-09-02 12:09:17 +0200
committerMichael Albinus2025-09-02 12:09:17 +0200
commit6ad8745833c2cc722cc73fd86ac63cd4741d2b2b (patch)
tree7e83cfce9f7f6136c2e5d24fc31a84e4dab84bbe
parentcc1a1a984a4989d2561bdd4ecb1a7e0d3ceb5f5d (diff)
downloademacs-6ad8745833c2cc722cc73fd86ac63cd4741d2b2b.tar.gz
emacs-6ad8745833c2cc722cc73fd86ac63cd4741d2b2b.zip
Extend tramp-test26-interactive-file-name-completion
* lisp/net/tramp.el (tramp-get-completion-methods): Use `tramp-compat-seq-keep'. * test/lisp/net/tramp-tests.el (completions-max-height): Declare. (tramp-test26-interactive-file-name-completion): Extend test.
-rw-r--r--lisp/net/tramp.el2
-rw-r--r--test/lisp/net/tramp-tests.el142
2 files changed, 89 insertions, 55 deletions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index c7450bc015d..9bf1b4ae6c3 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3261,7 +3261,7 @@ remote host and localname (filename on remote host)."
3261(defun tramp-get-completion-methods (partial-method &optional multi-hop) 3261(defun tramp-get-completion-methods (partial-method &optional multi-hop)
3262 "Return all method completions for PARTIAL-METHOD. 3262 "Return all method completions for PARTIAL-METHOD.
3263If MULTI-HOP is non-nil, return only multi-hop capable methods." 3263If MULTI-HOP is non-nil, return only multi-hop capable methods."
3264 (mapcar 3264 (tramp-compat-seq-keep
3265 (lambda (method) 3265 (lambda (method)
3266 (and method (string-prefix-p (or partial-method "") method) 3266 (and method (string-prefix-p (or partial-method "") method)
3267 (or (not multi-hop) 3267 (or (not multi-hop)
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 892e4ef519c..8c230f43cf3 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -91,6 +91,9 @@
91(defvar tramp-remote-process-environment) 91(defvar tramp-remote-process-environment)
92(defvar tramp-use-connection-share) 92(defvar tramp-use-connection-share)
93 93
94;; Declared in Emacs 29.1.
95(defvar completions-max-height)
96
94;; Declared in Emacs 30.1. 97;; Declared in Emacs 30.1.
95(defvar project-mode-line) 98(defvar project-mode-line)
96(defvar remote-file-name-access-timeout) 99(defvar remote-file-name-access-timeout)
@@ -5002,30 +5005,33 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
5002 5005
5003(tramp--test-deftest-with-ls tramp-test26-file-name-completion) 5006(tramp--test-deftest-with-ls tramp-test26-file-name-completion)
5004 5007
5005;; This test is inspired by Bug#51386, Bug#52758, Bug#53513, Bug#54042 5008;; This test is inspired by Bug#51386, Bug#52758, Bug#53513,
5006;; and Bug#60505. 5009;; Bug#54042, Bug#60505 and Bug#79236.
5007(ert-deftest tramp-test26-interactive-file-name-completion () 5010(ert-deftest tramp-test26-interactive-file-name-completion ()
5008 "Check interactive completion with different `completion-styles'." 5011 "Check interactive completion with different `completion-styles'."
5012 :tags '(:expensive-test)
5009 (skip-unless (tramp--test-enabled)) 5013 (skip-unless (tramp--test-enabled))
5010 5014
5011 ;; (when (get-buffer trace-buffer) (kill-buffer trace-buffer))
5012 ;; (dolist (elt (append
5013 ;; (mapcar
5014 ;; #'intern (all-completions "tramp-" obarray #'functionp))
5015 ;; tramp-trace-functions))
5016 ;; (unless (get elt 'tramp-suppress-trace)
5017 ;; (trace-function-background elt)))
5018 ;; (trace-function-background #'completion-file-name-table)
5019 ;; (trace-function-background #'read-file-name)
5020
5021 ;; Method, user and host name in completion mode. 5015 ;; Method, user and host name in completion mode.
5022 (let ((method (file-remote-p ert-remote-temporary-file-directory 'method)) 5016 (let* (;; Set this to `t' if you want to run all tests.
5023 (user (file-remote-p ert-remote-temporary-file-directory 'user)) 5017 (expensive nil) ;(tramp--test-expensive-test-p))
5024 (host (file-remote-p ert-remote-temporary-file-directory 'host)) 5018 ;; Set this to `t' if you want to see the traces.
5025 (hop (file-remote-p ert-remote-temporary-file-directory 'hop)) 5019 (tramp-trace nil)
5026 (orig-syntax tramp-syntax) 5020 (method (file-remote-p ert-remote-temporary-file-directory 'method))
5027 (non-essential t) 5021 (user (file-remote-p ert-remote-temporary-file-directory 'user))
5028 (inhibit-message (not (ignore-errors (edebug-mode))))) 5022 (host (file-remote-p ert-remote-temporary-file-directory 'host))
5023 (hop (and expensive
5024 (file-remote-p ert-remote-temporary-file-directory 'hop)))
5025 ;; All multi-hop capable methods.
5026 (method-list
5027 (and hop (sort (mapcar
5028 (lambda (x)
5029 (substring x (length tramp-prefix-format)))
5030 (tramp-get-completion-methods "" t)))))
5031 (orig-syntax tramp-syntax)
5032 (non-essential t)
5033 (inhibit-message
5034 (and (not tramp-trace) (not (ignore-errors (edebug-mode))))))
5029 ;; `file-remote-p' returns as host the string "host#port", which 5035 ;; `file-remote-p' returns as host the string "host#port", which
5030 ;; isn't useful. 5036 ;; isn't useful.
5031 (when (and (stringp host) 5037 (when (and (stringp host)
@@ -5034,6 +5040,15 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
5034 host)) 5040 host))
5035 (setq host (replace-match "" nil nil host))) 5041 (setq host (replace-match "" nil nil host)))
5036 5042
5043 (when tramp-trace
5044 (when (get-buffer trace-buffer) (kill-buffer trace-buffer))
5045 (dolist
5046 (elt (mapcar #'intern (all-completions "tramp-" obarray #'functionp)))
5047 (unless (get elt 'tramp-suppress-trace)
5048 (trace-function-background elt)))
5049 (trace-function-background #'completion-file-name-table)
5050 (trace-function-background #'read-file-name))
5051
5037 (unwind-protect 5052 (unwind-protect
5038 (dolist (syntax (if (tramp--test-expensive-test-p) 5053 (dolist (syntax (if (tramp--test-expensive-test-p)
5039 (tramp-syntax-values) `(,orig-syntax))) 5054 (tramp-syntax-values) `(,orig-syntax)))
@@ -5045,21 +5060,21 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
5045 5060
5046 (dolist 5061 (dolist
5047 (style 5062 (style
5048 (if (tramp--test-expensive-test-p) 5063 (if expensive
5049 ;; FIXME: It doesn't work for `initials' and 5064 ;; `initials' uses "/" as separator, it doesn't apply here.
5050 ;; `shorthand' completion styles. Should it? 5065 ;; `shorthand' is about symbols, it doesn't apply here.
5051 ;; `orderless' passes the tests, but it is an ELPA package.
5052 ;; What about `company' backends, `consult', `cider', `helm'?
5053 `(emacs21 emacs22 basic partial-completion substring 5066 `(emacs21 emacs22 basic partial-completion substring
5054 ;; FIXME: `flex' is not compatible with IPv6 hosts. 5067 ;; FIXME: `flex' is not compatible with IPv6 hosts.
5055 ,@(unless (string-match-p tramp-ipv6-regexp host) '(flex))) 5068 ,@(unless (string-match-p tramp-ipv6-regexp host) '(flex))
5069 ;; `orderless' is an ELPA package.
5070 ;; What about `company' backends, `consult',
5071 ;; `cider', `helm'?
5072 orderless)
5056 '(basic))) 5073 '(basic)))
5057 5074
5058 (when (assoc style completion-styles-alist) 5075 (when (assoc style completion-styles-alist)
5059 (let* (;; Force the real minibuffer in batch mode. 5076 (let* (;; Force the real minibuffer in batch mode.
5060 (executing-kbd-macro noninteractive) 5077 (executing-kbd-macro noninteractive)
5061 ;; FIXME: Is this TRT for test?
5062 (minibuffer-completing-file-name t)
5063 (confirm-nonexistent-file-or-buffer nil) 5078 (confirm-nonexistent-file-or-buffer nil)
5064 (completion-styles `(,style)) 5079 (completion-styles `(,style))
5065 completion-category-defaults 5080 completion-category-defaults
@@ -5072,6 +5087,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
5072 `(any 5087 `(any
5073 ,(string-replace 5088 ,(string-replace
5074 ":" "" completion-pcm-word-delimiters)))) 5089 ":" "" completion-pcm-word-delimiters))))
5090 ;; Don't truncate in *Completions* buffer.
5091 (completions-max-height most-positive-fixnum)
5075 ;; This is needed for the `simplified' syntax. 5092 ;; This is needed for the `simplified' syntax.
5076 (tramp-default-method method) 5093 (tramp-default-method method)
5077 (method-string 5094 (method-string
@@ -5097,7 +5114,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
5097 ;; Needed for host name completion. 5114 ;; Needed for host name completion.
5098 (default-user 5115 (default-user
5099 (file-remote-p 5116 (file-remote-p
5100 (concat tramp-prefix-format hop method-string host-string) 5117 (concat
5118 tramp-prefix-format hop method-string host-string)
5101 'user)) 5119 'user))
5102 (default-user-string 5120 (default-user-string
5103 (unless (tramp-string-empty-or-nil-p default-user) 5121 (unless (tramp-string-empty-or-nil-p default-user)
@@ -5107,8 +5125,18 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
5107 (dolist 5125 (dolist
5108 (test-and-result 5126 (test-and-result
5109 ;; These are triples of strings (TEST-STRING 5127 ;; These are triples of strings (TEST-STRING
5110 ;; RESULT-CHECK COMPLETION-CHECK). 5128 ;; RESULT-CHECK COMPLETION-CHECK). If
5129 ;; COMPLETION-CHECK is a list, it is the complete
5130 ;; result the contents of *Completions* shall be
5131 ;; checked with.
5111 (append 5132 (append
5133 ;; Complete hop.
5134 (unless (tramp-string-empty-or-nil-p hop)
5135 `((,(concat tramp-prefix-format hop)
5136 ,(concat tramp-prefix-format hop)
5137 ,(if (string-empty-p tramp-method-regexp)
5138 (or default-user-string host-string)
5139 method-list))))
5112 ;; Complete method name. 5140 ;; Complete method name.
5113 (unless (string-empty-p tramp-method-regexp) 5141 (unless (string-empty-p tramp-method-regexp)
5114 `((,(concat 5142 `((,(concat
@@ -5127,7 +5155,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
5127 tramp-prefix-format hop method-string user-string) 5155 tramp-prefix-format hop method-string user-string)
5128 ,user-string))) 5156 ,user-string)))
5129 ;; Complete host name. 5157 ;; Complete host name.
5130 (unless (tramp-string-empty-or-nil-p host) 5158 (unless (tramp-string-empty-or-nil-p host-string)
5131 `((,(concat 5159 `((,(concat
5132 tramp-prefix-format hop method-string 5160 tramp-prefix-format hop method-string
5133 ipv6-prefix 5161 ipv6-prefix
@@ -5138,8 +5166,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
5138 default-user-string host-string) 5166 default-user-string host-string)
5139 ,host-string))) 5167 ,host-string)))
5140 ;; Complete user and host name. 5168 ;; Complete user and host name.
5141 (unless (or (tramp-string-empty-or-nil-p user) 5169 (unless (or (tramp-string-empty-or-nil-p user-string)
5142 (tramp-string-empty-or-nil-p host)) 5170 (tramp-string-empty-or-nil-p host-string))
5143 `((,(concat 5171 `((,(concat
5144 tramp-prefix-format hop method-string user-string 5172 tramp-prefix-format hop method-string user-string
5145 ipv6-prefix 5173 ipv6-prefix
@@ -5152,8 +5180,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
5152 5180
5153 (dolist 5181 (dolist
5154 (predicate 5182 (predicate
5155 (if (and (tramp--test-expensive-test-p) 5183 (if (and expensive (tramp--test-emacs31-p))
5156 (tramp--test-emacs31-p))
5157 ;; `nil' will be expanded to `file-exists-p'. 5184 ;; `nil' will be expanded to `file-exists-p'.
5158 ;; `read-directory-name' uses `file-directory-p'. 5185 ;; `read-directory-name' uses `file-directory-p'.
5159 ;; `file-directory-p' works since Emacs 31. 5186 ;; `file-directory-p' works since Emacs 31.
@@ -5161,8 +5188,9 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
5161 '(file-exists-p file-directory-p) '(nil))) 5188 '(file-exists-p file-directory-p) '(nil)))
5162 5189
5163 (ignore-errors (kill-buffer "*Completions*")) 5190 (ignore-errors (kill-buffer "*Completions*"))
5164 ;; (when (get-buffer trace-buffer) 5191 (when tramp-trace
5165 ;; (kill-buffer trace-buffer)) 5192 (when (get-buffer trace-buffer)
5193 (kill-buffer trace-buffer)))
5166 (discard-input) 5194 (discard-input)
5167 (setq test (car test-and-result) 5195 (setq test (car test-and-result)
5168 unread-command-events 5196 unread-command-events
@@ -5186,11 +5214,12 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
5186 eos)) 5214 eos))
5187 result)) 5215 result))
5188 (progn 5216 (progn
5189 ;; (tramp--test-message 5217 (when tramp-trace
5190 ;; (concat 5218 (tramp--test-message
5191 ;; "syntax: %s style: %s predicate: %s " 5219 (concat
5192 ;; "test: %s result: %s") 5220 "syntax: %s style: %s predicate: %s "
5193 ;; syntax style predicate test result) 5221 "test: %s result: %s")
5222 syntax style predicate test result))
5194 (should 5223 (should
5195 (string-prefix-p (cadr test-and-result) result))) 5224 (string-prefix-p (cadr test-and-result) result)))
5196 5225
@@ -5212,16 +5241,22 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
5212 (point) (point-max)) 5241 (point) (point-max))
5213 (rx (any "\r\n\t ")) 'omit))) 5242 (rx (any "\r\n\t ")) 'omit)))
5214 5243
5215 ;; (tramp--test-message 5244 (when tramp-trace
5216 ;; (concat 5245 (tramp--test-message
5217 ;; "syntax: %s style: %s predicate: %s test: %s " 5246 (concat
5218 ;; "result: %s completions: %S") 5247 "syntax: %s style: %s predicate: %s test: %s "
5219 ;; syntax style predicate test result completions) 5248 "result: %s completions: %S")
5220 (should 5249 syntax style predicate test result completions))
5221 (member (caddr test-and-result) completions))))))))) 5250 (if (stringp (caddr test-and-result))
5251 (should
5252 (member (caddr test-and-result) completions))
5253 (should
5254 (equal
5255 (caddr test-and-result) (sort completions)))))))))))
5222 5256
5223 ;; Cleanup. 5257 ;; Cleanup.
5224 ;; (untrace-all) 5258 (when tramp-trace
5259 (untrace-all))
5225 (tramp-change-syntax orig-syntax) 5260 (tramp-change-syntax orig-syntax)
5226 (tramp-cleanup-connection tramp-test-vec 'keep-debug 'keep-password)))) 5261 (tramp-cleanup-connection tramp-test-vec 'keep-debug 'keep-password))))
5227 5262
@@ -8879,15 +8914,12 @@ If INTERACTIVE is non-nil, the tests are run interactively."
8879;; * tramp-set-file-uid-gid 8914;; * tramp-set-file-uid-gid
8880 8915
8881;; * Work on skipped tests. Make a comment, when it is impossible. 8916;; * Work on skipped tests. Make a comment, when it is impossible.
8882;; * Use `skip-when' starting with Emacs 30.1.
8883;; * Revisit expensive tests, once problems in `tramp-error' are solved. 8917;; * Revisit expensive tests, once problems in `tramp-error' are solved.
8884;; * Fix `tramp-test06-directory-file-name' for "ftp". 8918;; * Fix `tramp-test06-directory-file-name' for "ftp".
8885;; * In `tramp-test26-file-name-completion', check also user, domain, 8919;; * In `tramp-test26-file-name-completion', check also user, domain,
8886;; port and hop. 8920;; port and hop.
8887;; * In `tramp-test26-interactive-file-name-completion', check `flex', 8921;; * In `tramp-test26-interactive-file-name-completion', should
8888;; `initials' and `shorthand' completion styles. Should 8922;; `completion-pcm--delim-wild-regex' be bound? Check also domain and port.
8889;; `minibuffer-completing-file-name' and `completion-pcm--delim-wild-regex'
8890;; be bound? Check also domain, port and hop.
8891;; * Check, why a process filter t doesn't work in 8923;; * Check, why a process filter t doesn't work in
8892;; `tramp-test29-start-file-process' and 8924;; `tramp-test29-start-file-process' and
8893;; `tramp-test30-make-process'. 8925;; `tramp-test30-make-process'.
@@ -8899,6 +8931,8 @@ If INTERACTIVE is non-nil, the tests are run interactively."
8899;; * Check, why direct async processes do not work for 8931;; * Check, why direct async processes do not work for
8900;; `tramp-test45-asynchronous-requests'. 8932;; `tramp-test45-asynchronous-requests'.
8901 8933
8934;; Use `skip-when' starting with Emacs 30.1.
8935
8902;; Starting with Emacs 29, use `ert-with-temp-file' and 8936;; Starting with Emacs 29, use `ert-with-temp-file' and
8903;; `ert-with-temp-directory'. 8937;; `ert-with-temp-directory'.
8904 8938