diff options
| author | Michael Albinus | 2018-12-20 11:07:15 +0100 |
|---|---|---|
| committer | Michael Albinus | 2018-12-20 11:07:15 +0100 |
| commit | 88d3713beb8310eb1ab45dde8aa767f14489affe (patch) | |
| tree | 1226549f5e63d7d95b2ebf677519c64e5cc12d02 /test | |
| parent | 7ca9bb7849c47f061f1e887fe1c2de9960654648 (diff) | |
| download | emacs-88d3713beb8310eb1ab45dde8aa767f14489affe.tar.gz emacs-88d3713beb8310eb1ab45dde8aa767f14489affe.zip | |
Fix Bug#33781
* lisp/net/tramp-sh.el (tramp-set-remote-path): Use a temporary
file for setting $PATH, if it exceeds PATH_MAX on the remote system.
(tramp-send-command-and-read): Ignore errors if NOERROR. (Bug#33781)
* test/lisp/net/tramp-tests.el (tramp-test34-remote-path): New test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index f3ad8edf839..a485b8d8a70 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -4187,6 +4187,72 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4187 | ;; Cleanup. | 4187 | ;; Cleanup. |
| 4188 | (ignore-errors (delete-file tmp-name))))) | 4188 | (ignore-errors (delete-file tmp-name))))) |
| 4189 | 4189 | ||
| 4190 | ;; This test is inspired by Bug#33781. | ||
| 4191 | ;; `exec-path' was introduced in Emacs 27.1. `executable-find' has | ||
| 4192 | ;; changed the number of parameters, so we use `apply' for older | ||
| 4193 | ;; Emacsen. | ||
| 4194 | (ert-deftest tramp-test34-remote-path () | ||
| 4195 | "Check loooong `tramp-remote-path'." | ||
| 4196 | (skip-unless (tramp--test-enabled)) | ||
| 4197 | (skip-unless (tramp--test-sh-p)) | ||
| 4198 | ;; Since Emacs 27.1. | ||
| 4199 | (skip-unless (fboundp 'exec-path)) | ||
| 4200 | |||
| 4201 | (let* ((tmp-name (tramp--test-make-temp-name)) | ||
| 4202 | (default-directory tramp-test-temporary-file-directory) | ||
| 4203 | (orig-exec-path (exec-path)) | ||
| 4204 | (tramp-remote-path tramp-remote-path) | ||
| 4205 | (orig-tramp-remote-path tramp-remote-path)) | ||
| 4206 | (unwind-protect | ||
| 4207 | (progn | ||
| 4208 | ;; Non existing directories are removed. | ||
| 4209 | (setq tramp-remote-path | ||
| 4210 | (cons (file-remote-p tmp-name 'localname) tramp-remote-path)) | ||
| 4211 | (tramp-cleanup-connection | ||
| 4212 | (tramp-dissect-file-name tramp-test-temporary-file-directory) | ||
| 4213 | 'keep-debug 'keep-password) | ||
| 4214 | (should (equal (with-no-warnings (exec-path)) orig-exec-path)) | ||
| 4215 | (setq tramp-remote-path orig-tramp-remote-path) | ||
| 4216 | |||
| 4217 | ;; Double entries are removed. | ||
| 4218 | (setq tramp-remote-path (append '("/" "/") tramp-remote-path)) | ||
| 4219 | (tramp-cleanup-connection | ||
| 4220 | (tramp-dissect-file-name tramp-test-temporary-file-directory) | ||
| 4221 | 'keep-debug 'keep-password) | ||
| 4222 | (should | ||
| 4223 | (equal (with-no-warnings (exec-path)) (cons "/" orig-exec-path))) | ||
| 4224 | (setq tramp-remote-path orig-tramp-remote-path) | ||
| 4225 | |||
| 4226 | ;; We make a super long `tramp-remote-path'. | ||
| 4227 | (make-directory tmp-name) | ||
| 4228 | (should (file-directory-p tmp-name)) | ||
| 4229 | (while (< (length (mapconcat 'identity orig-exec-path ":")) 5000) | ||
| 4230 | (let ((dir (make-temp-file (file-name-as-directory tmp-name) 'dir))) | ||
| 4231 | (should (file-directory-p dir)) | ||
| 4232 | (setq tramp-remote-path | ||
| 4233 | (cons (file-remote-p dir 'localname) tramp-remote-path) | ||
| 4234 | orig-exec-path | ||
| 4235 | (cons (file-remote-p dir 'localname) orig-exec-path)))) | ||
| 4236 | (tramp-cleanup-connection | ||
| 4237 | (tramp-dissect-file-name tramp-test-temporary-file-directory) | ||
| 4238 | 'keep-debug 'keep-password) | ||
| 4239 | (should (equal (with-no-warnings (exec-path)) orig-exec-path)) | ||
| 4240 | (should | ||
| 4241 | (string-equal | ||
| 4242 | ;; Ignore trailing newline. | ||
| 4243 | (substring (shell-command-to-string "echo $PATH") nil -1) | ||
| 4244 | ;; The last element of `exec-path' is `exec-directory'. | ||
| 4245 | (mapconcat 'identity (butlast orig-exec-path) ":"))) | ||
| 4246 | ;; The shell "sh" shall always exist. | ||
| 4247 | (should (apply 'executable-find '("sh" remote)))) | ||
| 4248 | |||
| 4249 | ;; Cleanup. | ||
| 4250 | (tramp-cleanup-connection | ||
| 4251 | (tramp-dissect-file-name tramp-test-temporary-file-directory) | ||
| 4252 | 'keep-debug 'keep-password) | ||
| 4253 | (setq tramp-remote-path orig-tramp-remote-path) | ||
| 4254 | (ignore-errors (delete-directory tmp-name 'recursive))))) | ||
| 4255 | |||
| 4190 | (ert-deftest tramp-test35-vc-registered () | 4256 | (ert-deftest tramp-test35-vc-registered () |
| 4191 | "Check `vc-registered'." | 4257 | "Check `vc-registered'." |
| 4192 | :tags '(:expensive-test) | 4258 | :tags '(:expensive-test) |