aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2019-04-17 11:42:06 +0200
committerMichael Albinus2019-04-17 11:42:06 +0200
commit7e07bb2d2911f1a1dd3696227187501d7b7278a9 (patch)
treef7d4c0574b38a6c8aa597335e330792c0df10b37
parentacec59c9f9c6d552c54ad448f4be898d8ee36f31 (diff)
downloademacs-7e07bb2d2911f1a1dd3696227187501d7b7278a9.tar.gz
emacs-7e07bb2d2911f1a1dd3696227187501d7b7278a9.zip
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'.
-rw-r--r--test/lisp/net/tramp-tests.el42
1 files changed, 32 insertions, 10 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index cc3200be948..64eb1ddefd8 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -4079,6 +4079,16 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4079 ;; Cleanup. 4079 ;; Cleanup.
4080 (ignore-errors (delete-process proc))))) 4080 (ignore-errors (delete-process proc)))))
4081 4081
4082(defun tramp--test-shell-command-to-string-asynchronously (command)
4083 "Like `shell-command-to-string', but for asynchronous processes."
4084 (with-temp-buffer
4085 (async-shell-command command (current-buffer))
4086 (with-timeout
4087 ((if (getenv "EMACS_EMBA_CI") 30 10) (tramp--test-timeout-handler))
4088 (while (accept-process-output
4089 (get-buffer-process (current-buffer)) nil nil t)))
4090 (buffer-substring-no-properties (point-min) (point-max))))
4091
4082(ert-deftest tramp-test32-shell-command () 4092(ert-deftest tramp-test32-shell-command ()
4083 "Check `shell-command'." 4093 "Check `shell-command'."
4084 :tags '(:expensive-test) 4094 :tags '(:expensive-test)
@@ -4094,6 +4104,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4094 ;; Suppress nasty messages. 4104 ;; Suppress nasty messages.
4095 (inhibit-message t) 4105 (inhibit-message t)
4096 kill-buffer-query-functions) 4106 kill-buffer-query-functions)
4107
4108 ;; Test ordinary `shell-command'.
4097 (unwind-protect 4109 (unwind-protect
4098 (with-temp-buffer 4110 (with-temp-buffer
4099 (write-region "foo" nil tmp-name) 4111 (write-region "foo" nil tmp-name)
@@ -4114,6 +4126,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4114 ;; Cleanup. 4126 ;; Cleanup.
4115 (ignore-errors (delete-file tmp-name))) 4127 (ignore-errors (delete-file tmp-name)))
4116 4128
4129 ;; Test ordinary `async-shell-command'.
4117 (unwind-protect 4130 (unwind-protect
4118 (with-temp-buffer 4131 (with-temp-buffer
4119 (write-region "foo" nil tmp-name) 4132 (write-region "foo" nil tmp-name)
@@ -4142,6 +4155,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4142 ;; Cleanup. 4155 ;; Cleanup.
4143 (ignore-errors (delete-file tmp-name))) 4156 (ignore-errors (delete-file tmp-name)))
4144 4157
4158 ;; Test sending string to `async-shell-command'.
4145 (unwind-protect 4159 (unwind-protect
4146 (with-temp-buffer 4160 (with-temp-buffer
4147 (write-region "foo" nil tmp-name) 4161 (write-region "foo" nil tmp-name)
@@ -4169,17 +4183,25 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4169 (buffer-string)))) 4183 (buffer-string))))
4170 4184
4171 ;; Cleanup. 4185 ;; Cleanup.
4172 (ignore-errors (delete-file tmp-name)))))) 4186 (ignore-errors (delete-file tmp-name)))
4173 4187
4174(defun tramp--test-shell-command-to-string-asynchronously (command) 4188 ;; Test `shell-command-width' of `async-shell-command'.
4175 "Like `shell-command-to-string', but for asynchronous processes." 4189 (when (tramp--test-sh-p)
4176 (with-temp-buffer 4190 (let (shell-command-width)
4177 (async-shell-command command (current-buffer)) 4191 (should
4178 (with-timeout 4192 (string-equal
4179 ((if (getenv "EMACS_EMBA_CI") 30 10) (tramp--test-timeout-handler)) 4193 ;; `frame-width' does not return a proper value.
4180 (while (accept-process-output 4194 ;; `process-lines' uses `call-process', it doesn't care
4181 (get-buffer-process (current-buffer)) nil nil t))) 4195 ;; about `shell-command-width'.
4182 (buffer-substring-no-properties (point-min) (point-max)))) 4196 (format "%s\n" (car (process-lines "tput" "cols")))
4197 (tramp--test-shell-command-to-string-asynchronously
4198 "tput cols")))
4199 (setq shell-command-width 1024)
4200 (should
4201 (string-equal
4202 "1024\n"
4203 (tramp--test-shell-command-to-string-asynchronously
4204 "tput cols"))))))))
4183 4205
4184;; This test is inspired by Bug#23952. 4206;; This test is inspired by Bug#23952.
4185(ert-deftest tramp-test33-environment-variables () 4207(ert-deftest tramp-test33-environment-variables ()