aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2020-01-06 12:24:16 +0100
committerMichael Albinus2020-01-06 12:24:16 +0100
commit4f2b41503b06f65f8c2789dfcd32d39e5172554d (patch)
tree5f1c637bcf9f9a9e621a5dc719a82bbabb50df4d
parent823ce3aaf928092f3cf1a46f627337edd04f9989 (diff)
downloademacs-4f2b41503b06f65f8c2789dfcd32d39e5172554d.tar.gz
emacs-4f2b41503b06f65f8c2789dfcd32d39e5172554d.zip
; Adapt tramp-tests.el
* test/lisp/net/tramp-tests.el (tramp-test30-make-process): (tramp-test32-shell-command): Extend for asynchronous stderr.
-rw-r--r--test/lisp/net/tramp-tests.el92
1 files changed, 72 insertions, 20 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 47d51767c5c..2e4188ab76c 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -4248,7 +4248,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4248 4248
4249 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil))) 4249 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
4250 (let ((default-directory tramp-test-temporary-file-directory) 4250 (let ((default-directory tramp-test-temporary-file-directory)
4251 (tmp-name (tramp--test-make-temp-name nil quoted)) 4251 (tmp-name1 (tramp--test-make-temp-name nil quoted))
4252 (tmp-name2 (tramp--test-make-temp-name 'local quoted))
4252 kill-buffer-query-functions proc) 4253 kill-buffer-query-functions proc)
4253 (with-no-warnings (should-not (make-process))) 4254 (with-no-warnings (should-not (make-process)))
4254 4255
@@ -4278,13 +4279,13 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4278 ;; Simple process using a file. 4279 ;; Simple process using a file.
4279 (unwind-protect 4280 (unwind-protect
4280 (with-temp-buffer 4281 (with-temp-buffer
4281 (write-region "foo" nil tmp-name) 4282 (write-region "foo" nil tmp-name1)
4282 (should (file-exists-p tmp-name)) 4283 (should (file-exists-p tmp-name1))
4283 (setq proc 4284 (setq proc
4284 (with-no-warnings 4285 (with-no-warnings
4285 (make-process 4286 (make-process
4286 :name "test2" :buffer (current-buffer) 4287 :name "test2" :buffer (current-buffer)
4287 :command `("cat" ,(file-name-nondirectory tmp-name)) 4288 :command `("cat" ,(file-name-nondirectory tmp-name1))
4288 :file-handler t))) 4289 :file-handler t)))
4289 (should (processp proc)) 4290 (should (processp proc))
4290 ;; Read output. 4291 ;; Read output.
@@ -4296,7 +4297,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4296 ;; Cleanup. 4297 ;; Cleanup.
4297 (ignore-errors 4298 (ignore-errors
4298 (delete-process proc) 4299 (delete-process proc)
4299 (delete-file tmp-name))) 4300 (delete-file tmp-name1)))
4300 4301
4301 ;; Process filter. 4302 ;; Process filter.
4302 (unwind-protect 4303 (unwind-protect
@@ -4351,7 +4352,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4351 ;; Cleanup. 4352 ;; Cleanup.
4352 (ignore-errors (delete-process proc))) 4353 (ignore-errors (delete-process proc)))
4353 4354
4354 ;; Process with stderr. tramp-adb.el doesn't support it (yet). 4355 ;; Process with stderr buffer. tramp-adb.el doesn't support it (yet).
4355 (unless (tramp--test-adb-p) 4356 (unless (tramp--test-adb-p)
4356 (let ((stderr (generate-new-buffer "*stderr*"))) 4357 (let ((stderr (generate-new-buffer "*stderr*")))
4357 (unwind-protect 4358 (unwind-protect
@@ -4365,16 +4366,42 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4365 :file-handler t))) 4366 :file-handler t)))
4366 (should (processp proc)) 4367 (should (processp proc))
4367 ;; Read stderr. 4368 ;; Read stderr.
4369 (with-timeout (10 (tramp--test-timeout-handler))
4370 (while (accept-process-output proc 0 nil t)))
4371 (delete-process proc)
4368 (with-current-buffer stderr 4372 (with-current-buffer stderr
4369 (with-timeout (10 (tramp--test-timeout-handler))
4370 (while (= (point-min) (point-max))
4371 (while (accept-process-output proc 0 nil t))))
4372 (should 4373 (should
4373 (string-match "^cat:.* Is a directory" (buffer-string))))) 4374 (string-match "cat:.* Is a directory" (buffer-string)))))
4375
4376 ;; Cleanup.
4377 (ignore-errors (delete-process proc)))
4378 (ignore-errors (kill-buffer stderr))))
4379
4380 ;; Process with stderr file. tramp-adb.el doesn't support it (yet).
4381 (unless (tramp--test-adb-p)
4382 (dolist (tmpfile `(,tmp-name1 ,tmp-name2))
4383 (unwind-protect
4384 (with-temp-buffer
4385 (setq proc
4386 (with-no-warnings
4387 (make-process
4388 :name "test6" :buffer (current-buffer)
4389 :command '("cat" "/")
4390 :stderr tmpfile
4391 :file-handler t)))
4392 (should (processp proc))
4393 ;; Read stderr.
4394 (with-timeout (10 (tramp--test-timeout-handler))
4395 (while (accept-process-output proc nil nil t)))
4396 (delete-process proc)
4397 (with-temp-buffer
4398 (insert-file-contents tmpfile)
4399 (should
4400 (string-match "cat:.* Is a directory" (buffer-string)))))
4374 4401
4375 ;; Cleanup. 4402 ;; Cleanup.
4376 (ignore-errors (delete-process proc)) 4403 (ignore-errors (delete-process proc))
4377 (ignore-errors (kill-buffer stderr)))))))) 4404 (ignore-errors (delete-file tmpfile))))))))
4378 4405
4379(ert-deftest tramp-test31-interrupt-process () 4406(ert-deftest tramp-test31-interrupt-process ()
4380 "Check `interrupt-process'." 4407 "Check `interrupt-process'."
@@ -4460,12 +4487,11 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4460 (let ((stderr (generate-new-buffer "*stderr*"))) 4487 (let ((stderr (generate-new-buffer "*stderr*")))
4461 (unwind-protect 4488 (unwind-protect
4462 (with-temp-buffer 4489 (with-temp-buffer
4463 (shell-command "error" (current-buffer) stderr) 4490 (shell-command "cat /" (current-buffer) stderr)
4464 (should (= (point-min) (point-max))) 4491 (should (= (point-min) (point-max)))
4465 (should 4492 (with-current-buffer stderr
4466 (string-match 4493 (should
4467 "error:.+not found" 4494 (string-match "cat:.* Is a directory" (buffer-string)))))
4468 (with-current-buffer stderr (buffer-string)))))
4469 4495
4470 ;; Cleanup. 4496 ;; Cleanup.
4471 (ignore-errors (kill-buffer stderr)))) 4497 (ignore-errors (kill-buffer stderr))))
@@ -4495,6 +4521,26 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4495 ;; Cleanup. 4521 ;; Cleanup.
4496 (ignore-errors (delete-file tmp-name))) 4522 (ignore-errors (delete-file tmp-name)))
4497 4523
4524 ;; Test `async-shell-command' with error buffer. tramp-adb.el
4525 ;; doesn't support it (yet).
4526 (unless (tramp--test-adb-p)
4527 (let ((stderr (generate-new-buffer "*stderr*")) proc)
4528 (unwind-protect
4529 (with-temp-buffer
4530 (async-shell-command "cat /; sleep 1" (current-buffer) stderr)
4531 (setq proc (get-buffer-process (current-buffer)))
4532 ;; Read stderr.
4533 (when (processp proc)
4534 (with-timeout (10 (tramp--test-timeout-handler))
4535 (while (accept-process-output proc nil nil t)))
4536 (delete-process proc))
4537 (with-current-buffer stderr
4538 (should
4539 (string-match "cat:.* Is a directory" (buffer-string)))))
4540
4541 ;; Cleanup.
4542 (ignore-errors (kill-buffer stderr)))))
4543
4498 ;; Test sending string to `async-shell-command'. 4544 ;; Test sending string to `async-shell-command'.
4499 (unwind-protect 4545 (unwind-protect
4500 (with-temp-buffer 4546 (with-temp-buffer
@@ -4513,11 +4559,15 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4513 (while 4559 (while
4514 (re-search-forward tramp-display-escape-sequence-regexp nil t) 4560 (re-search-forward tramp-display-escape-sequence-regexp nil t)
4515 (replace-match "" nil nil)) 4561 (replace-match "" nil nil))
4516 ;; We cannot use `string-equal', because tramp-adb.el
4517 ;; echoes also the sent string.
4518 (should 4562 (should
4519 (string-match 4563 (string-equal
4520 (format "\\`%s" (regexp-quote (file-name-nondirectory tmp-name))) 4564 ;; tramp-adb.el echoes, so we must add the string.
4565 (if (tramp--test-adb-p)
4566 (format
4567 "%s\n%s\n"
4568 (file-name-nondirectory tmp-name)
4569 (file-name-nondirectory tmp-name))
4570 (format "%s\n" (file-name-nondirectory tmp-name)))
4521 (buffer-string)))) 4571 (buffer-string))))
4522 4572
4523 ;; Cleanup. 4573 ;; Cleanup.
@@ -6193,6 +6243,8 @@ If INTERACTIVE is non-nil, the tests are run interactively."
6193;; do not work properly for `nextcloud'. 6243;; do not work properly for `nextcloud'.
6194;; * Fix `tramp-test29-start-file-process' and 6244;; * Fix `tramp-test29-start-file-process' and
6195;; `tramp-test30-make-process' on MS Windows (`process-send-eof'?). 6245;; `tramp-test30-make-process' on MS Windows (`process-send-eof'?).
6246;; * Implement stderr for `adb' in `tramp-test30-make-process' and
6247;; `tramp-test32-shell-command'.
6196;; * Implement `tramp-test31-interrupt-process' for `adb'. 6248;; * Implement `tramp-test31-interrupt-process' for `adb'.
6197;; * Fix Bug#16928 in `tramp-test43-asynchronous-requests'. A remote 6249;; * Fix Bug#16928 in `tramp-test43-asynchronous-requests'. A remote
6198;; file name operation cannot run in the timer. Remove `:unstable' tag? 6250;; file name operation cannot run in the timer. Remove `:unstable' tag?