@@ -4248,7 +4248,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
42484248
42494249 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
42504250 (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))
42524253 kill-buffer-query-functions proc)
42534254 (with-no-warnings (should-not (make-process)))
42544255
@@ -4278,13 +4279,13 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
42784279 ;; Simple process using a file.
42794280 (unwind-protect
42804281 (with-temp-buffer
4281- (write-region "foo" nil tmp-name )
4282- (should (file-exists-p tmp-name ))
4282+ (write-region "foo" nil tmp-name1 )
4283+ (should (file-exists-p tmp-name1 ))
42834284 (setq proc
42844285 (with-no-warnings
42854286 (make-process
42864287 :name "test2" :buffer (current-buffer)
4287- :command `("cat" ,(file-name-nondirectory tmp-name ))
4288+ :command `("cat" ,(file-name-nondirectory tmp-name1 ))
42884289 :file-handler t)))
42894290 (should (processp proc))
42904291 ;; Read output.
@@ -4296,7 +4297,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
42964297 ;; Cleanup.
42974298 (ignore-errors
42984299 (delete-process proc)
4299- (delete-file tmp-name )))
4300+ (delete-file tmp-name1 )))
43004301
43014302 ;; Process filter.
43024303 (unwind-protect
@@ -4351,7 +4352,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
43514352 ;; Cleanup.
43524353 (ignore-errors (delete-process proc)))
43534354
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).
43554356 (unless (tramp--test-adb-p)
43564357 (let ((stderr (generate-new-buffer "*stderr*")))
43574358 (unwind-protect
@@ -4365,16 +4366,42 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
43654366 :file-handler t)))
43664367 (should (processp proc))
43674368 ;; Read stderr.
4369+ (with-timeout (10 (tramp--test-timeout-handler))
4370+ (while (accept-process-output proc 0 nil t)))
4371+ (delete-process proc)
43684372 (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))))
43724373 (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)))))
43744401
43754402 ;; Cleanup.
43764403 (ignore-errors (delete-process proc))
4377- (ignore-errors (kill-buffer stderr ))))))))
4404+ (ignore-errors (delete-file tmpfile ))))))))
43784405
43794406(ert-deftest tramp-test31-interrupt-process ()
43804407 "Check `interrupt-process'."
@@ -4460,12 +4487,11 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
44604487 (let ((stderr (generate-new-buffer "*stderr*")))
44614488 (unwind-protect
44624489 (with-temp-buffer
4463- (shell-command "error " (current-buffer) stderr)
4490+ (shell-command "cat / " (current-buffer) stderr)
44644491 (should (= (point-min) (point-max)))
4465- (should
4466- (string-match
4467- "error:.+not found"
4468- (with-current-buffer stderr (buffer-string)))))
4492+ (with-current-buffer stderr
4493+ (should
4494+ (string-match "cat:.* Is a directory" (buffer-string)))))
44694495
44704496 ;; Cleanup.
44714497 (ignore-errors (kill-buffer stderr))))
@@ -4495,6 +4521,26 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
44954521 ;; Cleanup.
44964522 (ignore-errors (delete-file tmp-name)))
44974523
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+
44984544 ;; Test sending string to `async-shell-command'.
44994545 (unwind-protect
45004546 (with-temp-buffer
@@ -4513,11 +4559,15 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
45134559 (while
45144560 (re-search-forward tramp-display-escape-sequence-regexp nil t)
45154561 (replace-match "" nil nil))
4516- ;; We cannot use `string-equal', because tramp-adb.el
4517- ;; echoes also the sent string.
45184562 (should
4519- (string-match
4520- (format "\\`%s" (regexp-quote (file-name-nondirectory tmp-name)))
4563+ (string-equal
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)))
45214571 (buffer-string))))
45224572
45234573 ;; Cleanup.
@@ -6193,6 +6243,8 @@ If INTERACTIVE is non-nil, the tests are run interactively."
61936243;; do not work properly for `nextcloud'.
61946244;; * Fix `tramp-test29-start-file-process' and
61956245;; `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'.
61966248;; * Implement `tramp-test31-interrupt-process' for `adb'.
61976249;; * Fix Bug#16928 in `tramp-test43-asynchronous-requests'. A remote
61986250;; file name operation cannot run in the timer. Remove `:unstable' tag?
0 commit comments