diff options
| author | Michael Albinus | 2020-01-27 10:11:32 +0100 |
|---|---|---|
| committer | Michael Albinus | 2020-01-27 10:11:32 +0100 |
| commit | e1c93a02dd13039f7a9f4ccefddaa3e761a27a2e (patch) | |
| tree | d61cbea1be54bb1491663a1f69f28df1a1fd96f3 /test/lisp | |
| parent | 502059433ce0e9699eb73d21656ce6e9e127d63b (diff) | |
| download | emacs-e1c93a02dd13039f7a9f4ccefddaa3e761a27a2e.tar.gz emacs-e1c93a02dd13039f7a9f4ccefddaa3e761a27a2e.zip | |
Fix problems in Tramp's async-shell-command
* lisp/net/tramp-adb.el (tramp-adb-handle-make-process):
* lisp/net/tramp-cache.el (top):
* lisp/net/tramp-sh.el (tramp-sh-handle-make-process):
Use `insert-file-contents-literally'.
* lisp/net/tramp.el (tramp-parse-file):
Use `insert-file-contents-literally'.
(tramp-handle-shell-command): Reorganize error-buffer handling.
(tramp-handle-start-file-process): Use `consp' instead of `listp'.
* test/lisp/net/tramp-tests.el (tramp-test31-interrupt-process):
Bind `delete-exited-processes'.
(tramp--test-async-shell-command): Bind `delete-exited-processes'.
Add additional `accept-process-output'. Move cleanup of output
buffer ...
(tramp-test32-shell-command): ... here. Test error buffer also
for `async-shell-command'.
Diffstat (limited to 'test/lisp')
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 129652839c4..7ffd22e77be 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -4410,6 +4410,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4410 | ;; order to establish the connection prior running an asynchronous | 4410 | ;; order to establish the connection prior running an asynchronous |
| 4411 | ;; process. | 4411 | ;; process. |
| 4412 | (let ((default-directory (file-truename tramp-test-temporary-file-directory)) | 4412 | (let ((default-directory (file-truename tramp-test-temporary-file-directory)) |
| 4413 | (delete-exited-processes t) | ||
| 4413 | kill-buffer-query-functions proc) | 4414 | kill-buffer-query-functions proc) |
| 4414 | (unwind-protect | 4415 | (unwind-protect |
| 4415 | (with-temp-buffer | 4416 | (with-temp-buffer |
| @@ -4436,18 +4437,14 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4436 | (command output-buffer &optional error-buffer input) | 4437 | (command output-buffer &optional error-buffer input) |
| 4437 | "Like `async-shell-command', reading the output. | 4438 | "Like `async-shell-command', reading the output. |
| 4438 | INPUT, if non-nil, is a string sent to the process." | 4439 | INPUT, if non-nil, is a string sent to the process." |
| 4439 | (let ((proc (async-shell-command command output-buffer error-buffer))) | 4440 | (let ((proc (async-shell-command command output-buffer error-buffer)) |
| 4441 | (delete-exited-processes t)) | ||
| 4440 | (when (stringp input) | 4442 | (when (stringp input) |
| 4441 | (process-send-string proc input)) | 4443 | (process-send-string proc input)) |
| 4442 | (with-timeout | 4444 | (with-timeout |
| 4443 | ((if (getenv "EMACS_EMBA_CI") 30 10) (tramp--test-timeout-handler)) | 4445 | ((if (getenv "EMACS_EMBA_CI") 30 10) (tramp--test-timeout-handler)) |
| 4444 | (while (accept-process-output proc nil nil t)) | 4446 | (while (or (accept-process-output proc nil nil t) (process-live-p proc)))) |
| 4445 | (should-not (process-live-p proc))) | 4447 | (accept-process-output proc nil nil t))) |
| 4446 | ;; `ls' could produce colorized output. | ||
| 4447 | (with-current-buffer output-buffer | ||
| 4448 | (goto-char (point-min)) | ||
| 4449 | (while (re-search-forward tramp-display-escape-sequence-regexp nil t) | ||
| 4450 | (replace-match "" nil nil))))) | ||
| 4451 | 4448 | ||
| 4452 | (defun tramp--test-shell-command-to-string-asynchronously (command) | 4449 | (defun tramp--test-shell-command-to-string-asynchronously (command) |
| 4453 | "Like `shell-command-to-string', but for asynchronous processes." | 4450 | "Like `shell-command-to-string', but for asynchronous processes." |
| @@ -4486,26 +4483,33 @@ INPUT, if non-nil, is a string sent to the process." | |||
| 4486 | this-shell-command | 4483 | this-shell-command |
| 4487 | (format "ls %s" (file-name-nondirectory tmp-name)) | 4484 | (format "ls %s" (file-name-nondirectory tmp-name)) |
| 4488 | (current-buffer)) | 4485 | (current-buffer)) |
| 4486 | ;; `ls' could produce colorized output. | ||
| 4487 | (goto-char (point-min)) | ||
| 4488 | (while | ||
| 4489 | (re-search-forward tramp-display-escape-sequence-regexp nil t) | ||
| 4490 | (replace-match "" nil nil)) | ||
| 4489 | (should | 4491 | (should |
| 4490 | (string-equal | 4492 | (string-equal |
| 4491 | (format "%s\n" (file-name-nondirectory tmp-name)) | 4493 | (format "%s\n" (file-name-nondirectory tmp-name)) |
| 4492 | (buffer-string)))) | 4494 | (buffer-string)))) |
| 4493 | 4495 | ||
| 4494 | ;; Cleanup. | 4496 | ;; Cleanup. |
| 4495 | (ignore-errors (delete-file tmp-name)))) | 4497 | (ignore-errors (delete-file tmp-name))) |
| 4496 | 4498 | ||
| 4497 | ;; Test `shell-command' with error buffer. | 4499 | ;; Test `{async-}shell-command' with error buffer. |
| 4498 | (let ((stderr (generate-new-buffer "*stderr*"))) | 4500 | (let ((stderr (generate-new-buffer "*stderr*"))) |
| 4499 | (unwind-protect | 4501 | (unwind-protect |
| 4500 | (with-temp-buffer | 4502 | (with-temp-buffer |
| 4501 | (shell-command "echo foo; echo bar >&2" (current-buffer) stderr) | 4503 | (funcall |
| 4502 | (should (string-equal "foo\n" (buffer-string))) | 4504 | this-shell-command |
| 4503 | ;; Check stderr. | 4505 | "echo foo >&2; echo bar" (current-buffer) stderr) |
| 4504 | (with-current-buffer stderr | 4506 | (should (string-equal "bar\n" (buffer-string))) |
| 4505 | (should (string-equal "bar\n" (buffer-string))))) | 4507 | ;; Check stderr. |
| 4508 | (with-current-buffer stderr | ||
| 4509 | (should (string-equal "foo\n" (buffer-string))))) | ||
| 4506 | 4510 | ||
| 4507 | ;; Cleanup. | 4511 | ;; Cleanup. |
| 4508 | (ignore-errors (kill-buffer stderr)))) | 4512 | (ignore-errors (kill-buffer stderr))))) |
| 4509 | 4513 | ||
| 4510 | ;; Test sending string to `async-shell-command'. | 4514 | ;; Test sending string to `async-shell-command'. |
| 4511 | (unwind-protect | 4515 | (unwind-protect |
| @@ -4514,6 +4518,7 @@ INPUT, if non-nil, is a string sent to the process." | |||
| 4514 | (should (file-exists-p tmp-name)) | 4518 | (should (file-exists-p tmp-name)) |
| 4515 | (tramp--test-async-shell-command | 4519 | (tramp--test-async-shell-command |
| 4516 | "read line; ls $line" (current-buffer) nil | 4520 | "read line; ls $line" (current-buffer) nil |
| 4521 | ;; String to be sent. | ||
| 4517 | (format "%s\n" (file-name-nondirectory tmp-name))) | 4522 | (format "%s\n" (file-name-nondirectory tmp-name))) |
| 4518 | (should | 4523 | (should |
| 4519 | (string-equal | 4524 | (string-equal |