(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
(let ((default-directory tramp-test-temporary-file-directory)
- (tmp-name (tramp--test-make-temp-name nil quoted))
+ (tmp-name1 (tramp--test-make-temp-name nil quoted))
+ (tmp-name2 (tramp--test-make-temp-name 'local quoted))
kill-buffer-query-functions proc)
(with-no-warnings (should-not (make-process)))
;; Simple process using a file.
(unwind-protect
(with-temp-buffer
- (write-region "foo" nil tmp-name)
- (should (file-exists-p tmp-name))
+ (write-region "foo" nil tmp-name1)
+ (should (file-exists-p tmp-name1))
(setq proc
(with-no-warnings
(make-process
:name "test2" :buffer (current-buffer)
- :command `("cat" ,(file-name-nondirectory tmp-name))
+ :command `("cat" ,(file-name-nondirectory tmp-name1))
:file-handler t)))
(should (processp proc))
;; Read output.
;; Cleanup.
(ignore-errors
(delete-process proc)
- (delete-file tmp-name)))
+ (delete-file tmp-name1)))
;; Process filter.
(unwind-protect
;; Cleanup.
(ignore-errors (delete-process proc)))
- ;; Process with stderr. tramp-adb.el doesn't support it (yet).
+ ;; Process with stderr buffer. tramp-adb.el doesn't support it (yet).
(unless (tramp--test-adb-p)
(let ((stderr (generate-new-buffer "*stderr*")))
(unwind-protect
:file-handler t)))
(should (processp proc))
;; Read stderr.
+ (with-timeout (10 (tramp--test-timeout-handler))
+ (while (accept-process-output proc 0 nil t)))
+ (delete-process proc)
(with-current-buffer stderr
- (with-timeout (10 (tramp--test-timeout-handler))
- (while (= (point-min) (point-max))
- (while (accept-process-output proc 0 nil t))))
(should
- (string-match "^cat:.* Is a directory" (buffer-string)))))
+ (string-match "cat:.* Is a directory" (buffer-string)))))
+
+ ;; Cleanup.
+ (ignore-errors (delete-process proc)))
+ (ignore-errors (kill-buffer stderr))))
+
+ ;; Process with stderr file. tramp-adb.el doesn't support it (yet).
+ (unless (tramp--test-adb-p)
+ (dolist (tmpfile `(,tmp-name1 ,tmp-name2))
+ (unwind-protect
+ (with-temp-buffer
+ (setq proc
+ (with-no-warnings
+ (make-process
+ :name "test6" :buffer (current-buffer)
+ :command '("cat" "/")
+ :stderr tmpfile
+ :file-handler t)))
+ (should (processp proc))
+ ;; Read stderr.
+ (with-timeout (10 (tramp--test-timeout-handler))
+ (while (accept-process-output proc nil nil t)))
+ (delete-process proc)
+ (with-temp-buffer
+ (insert-file-contents tmpfile)
+ (should
+ (string-match "cat:.* Is a directory" (buffer-string)))))
;; Cleanup.
(ignore-errors (delete-process proc))
- (ignore-errors (kill-buffer stderr))))))))
+ (ignore-errors (delete-file tmpfile))))))))
(ert-deftest tramp-test31-interrupt-process ()
"Check `interrupt-process'."
(let ((stderr (generate-new-buffer "*stderr*")))
(unwind-protect
(with-temp-buffer
- (shell-command "error" (current-buffer) stderr)
+ (shell-command "cat /" (current-buffer) stderr)
(should (= (point-min) (point-max)))
- (should
- (string-match
- "error:.+not found"
- (with-current-buffer stderr (buffer-string)))))
+ (with-current-buffer stderr
+ (should
+ (string-match "cat:.* Is a directory" (buffer-string)))))
;; Cleanup.
(ignore-errors (kill-buffer stderr))))
;; Cleanup.
(ignore-errors (delete-file tmp-name)))
+ ;; Test `async-shell-command' with error buffer. tramp-adb.el
+ ;; doesn't support it (yet).
+ (unless (tramp--test-adb-p)
+ (let ((stderr (generate-new-buffer "*stderr*")) proc)
+ (unwind-protect
+ (with-temp-buffer
+ (async-shell-command "cat /; sleep 1" (current-buffer) stderr)
+ (setq proc (get-buffer-process (current-buffer)))
+ ;; Read stderr.
+ (when (processp proc)
+ (with-timeout (10 (tramp--test-timeout-handler))
+ (while (accept-process-output proc nil nil t)))
+ (delete-process proc))
+ (with-current-buffer stderr
+ (should
+ (string-match "cat:.* Is a directory" (buffer-string)))))
+
+ ;; Cleanup.
+ (ignore-errors (kill-buffer stderr)))))
+
;; Test sending string to `async-shell-command'.
(unwind-protect
(with-temp-buffer
(while
(re-search-forward tramp-display-escape-sequence-regexp nil t)
(replace-match "" nil nil))
- ;; We cannot use `string-equal', because tramp-adb.el
- ;; echoes also the sent string.
(should
- (string-match
- (format "\\`%s" (regexp-quote (file-name-nondirectory tmp-name)))
+ (string-equal
+ ;; tramp-adb.el echoes, so we must add the string.
+ (if (tramp--test-adb-p)
+ (format
+ "%s\n%s\n"
+ (file-name-nondirectory tmp-name)
+ (file-name-nondirectory tmp-name))
+ (format "%s\n" (file-name-nondirectory tmp-name)))
(buffer-string))))
;; Cleanup.
;; do not work properly for `nextcloud'.
;; * Fix `tramp-test29-start-file-process' and
;; `tramp-test30-make-process' on MS Windows (`process-send-eof'?).
+;; * Implement stderr for `adb' in `tramp-test30-make-process' and
+;; `tramp-test32-shell-command'.
;; * Implement `tramp-test31-interrupt-process' for `adb'.
;; * Fix Bug#16928 in `tramp-test43-asynchronous-requests'. A remote
;; file name operation cannot run in the timer. Remove `:unstable' tag?