Commit 7e07bb2d authored by Michael Albinus's avatar Michael Albinus

Test `shell-command-width' in Tramp

* test/lisp/net/tramp-tests.el
(tramp--test-shell-command-to-string-asynchronously): Move up.
(tramp-test32-shell-command): Test `shell-command-width'.
parent acec59c9
Pipeline #1321 failed with stage
in 53 minutes and 21 seconds
...@@ -4079,6 +4079,16 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." ...@@ -4079,6 +4079,16 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
;; Cleanup. ;; Cleanup.
(ignore-errors (delete-process proc))))) (ignore-errors (delete-process proc)))))
(defun tramp--test-shell-command-to-string-asynchronously (command)
"Like `shell-command-to-string', but for asynchronous processes."
(with-temp-buffer
(async-shell-command command (current-buffer))
(with-timeout
((if (getenv "EMACS_EMBA_CI") 30 10) (tramp--test-timeout-handler))
(while (accept-process-output
(get-buffer-process (current-buffer)) nil nil t)))
(buffer-substring-no-properties (point-min) (point-max))))
(ert-deftest tramp-test32-shell-command () (ert-deftest tramp-test32-shell-command ()
"Check `shell-command'." "Check `shell-command'."
:tags '(:expensive-test) :tags '(:expensive-test)
...@@ -4094,6 +4104,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." ...@@ -4094,6 +4104,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
;; Suppress nasty messages. ;; Suppress nasty messages.
(inhibit-message t) (inhibit-message t)
kill-buffer-query-functions) kill-buffer-query-functions)
;; Test ordinary `shell-command'.
(unwind-protect (unwind-protect
(with-temp-buffer (with-temp-buffer
(write-region "foo" nil tmp-name) (write-region "foo" nil tmp-name)
...@@ -4114,6 +4126,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." ...@@ -4114,6 +4126,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
;; Cleanup. ;; Cleanup.
(ignore-errors (delete-file tmp-name))) (ignore-errors (delete-file tmp-name)))
;; Test ordinary `async-shell-command'.
(unwind-protect (unwind-protect
(with-temp-buffer (with-temp-buffer
(write-region "foo" nil tmp-name) (write-region "foo" nil tmp-name)
...@@ -4142,6 +4155,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." ...@@ -4142,6 +4155,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
;; Cleanup. ;; Cleanup.
(ignore-errors (delete-file tmp-name))) (ignore-errors (delete-file tmp-name)))
;; Test sending string to `async-shell-command'.
(unwind-protect (unwind-protect
(with-temp-buffer (with-temp-buffer
(write-region "foo" nil tmp-name) (write-region "foo" nil tmp-name)
...@@ -4169,17 +4183,25 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." ...@@ -4169,17 +4183,25 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
(buffer-string)))) (buffer-string))))
;; Cleanup. ;; Cleanup.
(ignore-errors (delete-file tmp-name)))))) (ignore-errors (delete-file tmp-name)))
(defun tramp--test-shell-command-to-string-asynchronously (command) ;; Test `shell-command-width' of `async-shell-command'.
"Like `shell-command-to-string', but for asynchronous processes." (when (tramp--test-sh-p)
(with-temp-buffer (let (shell-command-width)
(async-shell-command command (current-buffer)) (should
(with-timeout (string-equal
((if (getenv "EMACS_EMBA_CI") 30 10) (tramp--test-timeout-handler)) ;; `frame-width' does not return a proper value.
(while (accept-process-output ;; `process-lines' uses `call-process', it doesn't care
(get-buffer-process (current-buffer)) nil nil t))) ;; about `shell-command-width'.
(buffer-substring-no-properties (point-min) (point-max)))) (format "%s\n" (car (process-lines "tput" "cols")))
(tramp--test-shell-command-to-string-asynchronously
"tput cols")))
(setq shell-command-width 1024)
(should
(string-equal
"1024\n"
(tramp--test-shell-command-to-string-asynchronously
"tput cols"))))))))
;; This test is inspired by Bug#23952. ;; This test is inspired by Bug#23952.
(ert-deftest tramp-test33-environment-variables () (ert-deftest tramp-test33-environment-variables ()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment