aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMichael Albinus2019-04-03 21:36:40 +0200
committerMichael Albinus2019-04-03 21:36:40 +0200
commit8147d3c27cbf29e18dbdd6bad21cd17bc880a8d3 (patch)
tree382338c2ceefa4545d0388ab625a508cddea58ad /test
parentce9490cb314694b95847ac647b35f1319ba80fde (diff)
downloademacs-8147d3c27cbf29e18dbdd6bad21cd17bc880a8d3.tar.gz
emacs-8147d3c27cbf29e18dbdd6bad21cd17bc880a8d3.zip
Work on asynchronous processes for tramp-adb.el
* lisp/net/tramp-adb.el (tramp-adb-handle-make-process): Simplify. Remove echoed first line. (tramp-adb-send-command): Add NEVEROPEN and NOOUTPUT. * lisp/net/tramp-sh.el (tramp-process-sentinel): Remove. (tramp-sh-handle-make-process): Simplify. * lisp/net/tramp.el (tramp-process-sentinel): New defun, taken from tramp-sh.el. Delete trailing shell prompt. * test/lisp/net/tramp-tests.el (tramp-test29-start-file-process) (tramp-test30-make-process): Run also for tramp-adb. (tramp-test32-shell-command): Remove tramp-adb restrictions. (tramp-test34-explicit-shell-file-name): Rework. Remove :unstable tag.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/net/tramp-tests.el110
1 files changed, 61 insertions, 49 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 1c7198ce560..1ee11f0d38a 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -3849,12 +3849,14 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3849 "Check `start-file-process'." 3849 "Check `start-file-process'."
3850 :tags '(:expensive-test) 3850 :tags '(:expensive-test)
3851 (skip-unless (tramp--test-enabled)) 3851 (skip-unless (tramp--test-enabled))
3852 (skip-unless (tramp--test-sh-p)) 3852 (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p)))
3853 3853
3854 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil))) 3854 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
3855 (let ((default-directory tramp-test-temporary-file-directory) 3855 (let ((default-directory tramp-test-temporary-file-directory)
3856 (tmp-name (tramp--test-make-temp-name nil quoted)) 3856 (tmp-name (tramp--test-make-temp-name nil quoted))
3857 kill-buffer-query-functions proc) 3857 kill-buffer-query-functions proc)
3858
3859 ;; Simple process.
3858 (unwind-protect 3860 (unwind-protect
3859 (with-temp-buffer 3861 (with-temp-buffer
3860 (setq proc (start-file-process "test1" (current-buffer) "cat")) 3862 (setq proc (start-file-process "test1" (current-buffer) "cat"))
@@ -3866,11 +3868,14 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3866 (with-timeout (10 (tramp--test-timeout-handler)) 3868 (with-timeout (10 (tramp--test-timeout-handler))
3867 (while (< (- (point-max) (point-min)) (length "foo")) 3869 (while (< (- (point-max) (point-min)) (length "foo"))
3868 (while (accept-process-output proc 0 nil t)))) 3870 (while (accept-process-output proc 0 nil t))))
3869 (should (string-equal (buffer-string) "foo"))) 3871 ;; We cannot use `string-equal', because tramp-adb.el
3872 ;; echoes also the sent string.
3873 (should (string-match "\\`foo" (buffer-string))))
3870 3874
3871 ;; Cleanup. 3875 ;; Cleanup.
3872 (ignore-errors (delete-process proc))) 3876 (ignore-errors (delete-process proc)))
3873 3877
3878 ;; Simple process using a file.
3874 (unwind-protect 3879 (unwind-protect
3875 (with-temp-buffer 3880 (with-temp-buffer
3876 (write-region "foo" nil tmp-name) 3881 (write-region "foo" nil tmp-name)
@@ -3891,6 +3896,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3891 (delete-process proc) 3896 (delete-process proc)
3892 (delete-file tmp-name))) 3897 (delete-file tmp-name)))
3893 3898
3899 ;; Process filter.
3894 (unwind-protect 3900 (unwind-protect
3895 (with-temp-buffer 3901 (with-temp-buffer
3896 (setq proc (start-file-process "test3" (current-buffer) "cat")) 3902 (setq proc (start-file-process "test3" (current-buffer) "cat"))
@@ -3905,7 +3911,9 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3905 (with-timeout (10 (tramp--test-timeout-handler)) 3911 (with-timeout (10 (tramp--test-timeout-handler))
3906 (while (< (- (point-max) (point-min)) (length "foo")) 3912 (while (< (- (point-max) (point-min)) (length "foo"))
3907 (while (accept-process-output proc 0 nil t)))) 3913 (while (accept-process-output proc 0 nil t))))
3908 (should (string-equal (buffer-string) "foo"))) 3914 ;; We cannot use `string-equal', because tramp-adb.el
3915 ;; echoes also the sent string.
3916 (should (string-match "\\`foo" (buffer-string))))
3909 3917
3910 ;; Cleanup. 3918 ;; Cleanup.
3911 (ignore-errors (delete-process proc)))))) 3919 (ignore-errors (delete-process proc))))))
@@ -3914,7 +3922,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3914 "Check `make-process'." 3922 "Check `make-process'."
3915 :tags '(:expensive-test) 3923 :tags '(:expensive-test)
3916 (skip-unless (tramp--test-enabled)) 3924 (skip-unless (tramp--test-enabled))
3917 (skip-unless (tramp--test-sh-p)) 3925 (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p)))
3918 (skip-unless (tramp--test-emacs27-p)) 3926 (skip-unless (tramp--test-emacs27-p))
3919 3927
3920 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil))) 3928 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
@@ -3938,7 +3946,9 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3938 (with-timeout (10 (tramp--test-timeout-handler)) 3946 (with-timeout (10 (tramp--test-timeout-handler))
3939 (while (< (- (point-max) (point-min)) (length "foo")) 3947 (while (< (- (point-max) (point-min)) (length "foo"))
3940 (while (accept-process-output proc 0 nil t)))) 3948 (while (accept-process-output proc 0 nil t))))
3941 (should (string-equal (buffer-string) "foo"))) 3949 ;; We cannot use `string-equal', because tramp-adb.el
3950 ;; echoes also the sent string.
3951 (should (string-match "\\`foo" (buffer-string))))
3942 3952
3943 ;; Cleanup. 3953 ;; Cleanup.
3944 (ignore-errors (delete-process proc))) 3954 (ignore-errors (delete-process proc)))
@@ -3981,9 +3991,11 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3981 (process-send-eof proc) 3991 (process-send-eof proc)
3982 ;; Read output. 3992 ;; Read output.
3983 (with-timeout (10 (tramp--test-timeout-handler)) 3993 (with-timeout (10 (tramp--test-timeout-handler))
3984 (while (< (- (point-max) (point-min)) (length "foo")) 3994 (while (not (string-match "foo" (buffer-string)))
3985 (while (accept-process-output proc 0 nil t)))) 3995 (while (accept-process-output proc 0 nil t))))
3986 (should (string-equal (buffer-string) "foo"))) 3996 ;; We cannot use `string-equal', because tramp-adb.el
3997 ;; echoes also the sent string.
3998 (should (string-match "\\`foo" (buffer-string))))
3987 3999
3988 ;; Cleanup. 4000 ;; Cleanup.
3989 (ignore-errors (delete-process proc))) 4001 (ignore-errors (delete-process proc)))
@@ -4006,33 +4018,37 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4006 ;; Read output. 4018 ;; Read output.
4007 (with-timeout (10 (tramp--test-timeout-handler)) 4019 (with-timeout (10 (tramp--test-timeout-handler))
4008 (while (accept-process-output proc 0 nil t))) 4020 (while (accept-process-output proc 0 nil t)))
4009 (should (string-equal (buffer-string) "killed\n"))) 4021 ;; We cannot use `string-equal', because tramp-adb.el
4022 ;; echoes also the sent string.
4023 (should (string-match "killed\n\\'" (buffer-string))))
4010 4024
4011 ;; Cleanup. 4025 ;; Cleanup.
4012 (ignore-errors (delete-process proc))) 4026 (ignore-errors (delete-process proc)))
4013 4027
4014 ;; Process with stderr. 4028 ;; Process with stderr. tramp-adb.el doesn't support it (yet).
4015 (let ((stderr (generate-new-buffer (generate-new-buffer-name "stderr")))) 4029 (unless (tramp--test-adb-p)
4016 (unwind-protect 4030 (let ((stderr
4017 (with-temp-buffer 4031 (generate-new-buffer (generate-new-buffer-name "stderr"))))
4018 (setq proc 4032 (unwind-protect
4019 (make-process 4033 (with-temp-buffer
4020 :name "test5" :buffer (current-buffer) 4034 (setq proc
4021 :command '("cat" "/") 4035 (make-process
4022 :stderr stderr 4036 :name "test5" :buffer (current-buffer)
4023 :file-handler t)) 4037 :command '("cat" "/")
4024 (should (processp proc)) 4038 :stderr stderr
4025 ;; Read stderr. 4039 :file-handler t))
4026 (with-current-buffer stderr 4040 (should (processp proc))
4027 (with-timeout (10 (tramp--test-timeout-handler)) 4041 ;; Read stderr.
4028 (while (= (point-min) (point-max)) 4042 (with-current-buffer stderr
4029 (while (accept-process-output proc 0 nil t)))) 4043 (with-timeout (10 (tramp--test-timeout-handler))
4030 (should 4044 (while (= (point-min) (point-max))
4031 (string-equal (buffer-string) "cat: /: Is a directory\n")))) 4045 (while (accept-process-output proc 0 nil t))))
4046 (should
4047 (string-equal (buffer-string) "cat: /: Is a directory\n"))))
4032 4048
4033 ;; Cleanup. 4049 ;; Cleanup.
4034 (ignore-errors (delete-process proc)) 4050 (ignore-errors (delete-process proc))
4035 (ignore-errors (kill-buffer stderr))))))) 4051 (ignore-errors (kill-buffer stderr))))))))
4036 4052
4037(ert-deftest tramp-test31-interrupt-process () 4053(ert-deftest tramp-test31-interrupt-process ()
4038 "Check `interrupt-process'." 4054 "Check `interrupt-process'."
@@ -4096,8 +4112,6 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4096 ;; Cleanup. 4112 ;; Cleanup.
4097 (ignore-errors (delete-file tmp-name))) 4113 (ignore-errors (delete-file tmp-name)))
4098 4114
4099 ;; tramp-adb.el is not fit yet for asynchronous processes.
4100 (unless (tramp--test-adb-p)
4101 (unwind-protect 4115 (unwind-protect
4102 (with-temp-buffer 4116 (with-temp-buffer
4103 (write-region "foo" nil tmp-name) 4117 (write-region "foo" nil tmp-name)
@@ -4124,10 +4138,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4124 (buffer-string)))) 4138 (buffer-string))))
4125 4139
4126 ;; Cleanup. 4140 ;; Cleanup.
4127 (ignore-errors (delete-file tmp-name)))) 4141 (ignore-errors (delete-file tmp-name)))
4128 4142
4129 ;; tramp-adb.el is not fit yet for asynchronous processes.
4130 (unless (tramp--test-adb-p)
4131 (unwind-protect 4143 (unwind-protect
4132 (with-temp-buffer 4144 (with-temp-buffer
4133 (write-region "foo" nil tmp-name) 4145 (write-region "foo" nil tmp-name)
@@ -4155,7 +4167,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4155 (buffer-string)))) 4167 (buffer-string))))
4156 4168
4157 ;; Cleanup. 4169 ;; Cleanup.
4158 (ignore-errors (delete-file tmp-name))))))) 4170 (ignore-errors (delete-file tmp-name))))))
4159 4171
4160(defun tramp--test-shell-command-to-string-asynchronously (command) 4172(defun tramp--test-shell-command-to-string-asynchronously (command)
4161 "Like `shell-command-to-string', but for asynchronous processes." 4173 "Like `shell-command-to-string', but for asynchronous processes."
@@ -4350,9 +4362,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4350;; The functions were introduced in Emacs 26.1. 4362;; The functions were introduced in Emacs 26.1.
4351(ert-deftest tramp-test34-explicit-shell-file-name () 4363(ert-deftest tramp-test34-explicit-shell-file-name ()
4352 "Check that connection-local `explicit-shell-file-name' is set." 4364 "Check that connection-local `explicit-shell-file-name' is set."
4353 ;; The handling of connection-local variables has changed. Test 4365 :tags '(:expensive-test)
4354 ;; must be reworked.
4355 :tags '(:expensive-test :unstable)
4356 (skip-unless (tramp--test-enabled)) 4366 (skip-unless (tramp--test-enabled))
4357 (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p))) 4367 (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p)))
4358 ;; Since Emacs 26.1. 4368 ;; Since Emacs 26.1.
@@ -4368,15 +4378,16 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4368 (unwind-protect 4378 (unwind-protect
4369 (progn 4379 (progn
4370 ;; `shell-mode' would ruin our test, because it deletes all 4380 ;; `shell-mode' would ruin our test, because it deletes all
4371 ;; buffer local variables. 4381 ;; buffer local variables. Not needed in Emacs 27.1.
4372 (put 'explicit-shell-file-name 'permanent-local t) 4382 (put 'explicit-shell-file-name 'permanent-local t)
4373 ;; Declare connection-local variable `explicit-shell-file-name'. 4383 ;; Declare connection-local variables `explicit-shell-file-name'
4384 ;; and `explicit-sh-args'.
4374 (with-no-warnings 4385 (with-no-warnings
4375 (connection-local-set-profile-variables 4386 (connection-local-set-profile-variables
4376 'remote-sh 4387 'remote-sh
4377 `((explicit-shell-file-name 4388 `((explicit-shell-file-name
4378 . ,(if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh")) 4389 . ,(if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh"))
4379 (explicit-sh-args . ("-i")))) 4390 (explicit-sh-args . ("-c" "echo foo"))))
4380 (connection-local-set-profiles 4391 (connection-local-set-profiles
4381 `(:application tramp 4392 `(:application tramp
4382 :protocol ,(file-remote-p default-directory 'method) 4393 :protocol ,(file-remote-p default-directory 'method)
@@ -4386,14 +4397,18 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4386 (put 'explicit-shell-file-name 'safe-local-variable #'identity) 4397 (put 'explicit-shell-file-name 'safe-local-variable #'identity)
4387 (put 'explicit-sh-args 'safe-local-variable #'identity) 4398 (put 'explicit-sh-args 'safe-local-variable #'identity)
4388 4399
4389 ;; Run interactive shell. Since the default directory is 4400 ;; Run `shell' interactively. Since the default directory
4390 ;; remote, `explicit-shell-file-name' shall be set in order 4401 ;; is remote, `explicit-shell-file-name' shall be set in
4391 ;; to avoid a question. 4402 ;; order to avoid a question. `explicit-sh-args' echoes the
4403 ;; test data.
4392 (with-current-buffer (get-buffer-create "*shell*") 4404 (with-current-buffer (get-buffer-create "*shell*")
4393 (ignore-errors (kill-process (current-buffer))) 4405 (ignore-errors (kill-process (current-buffer)))
4394 (should-not explicit-shell-file-name) 4406 (should-not explicit-shell-file-name)
4395 (call-interactively #'shell) 4407 (call-interactively #'shell)
4396 (should explicit-shell-file-name))) 4408 (with-timeout (10)
4409 (while (accept-process-output
4410 (get-buffer-process (current-buffer)) nil nil t)))
4411 (should (string-match "^foo$" (buffer-string)))))
4397 4412
4398 ;; Cleanup. 4413 ;; Cleanup.
4399 (put 'explicit-shell-file-name 'permanent-local nil) 4414 (put 'explicit-shell-file-name 'permanent-local nil)
@@ -5714,11 +5729,8 @@ Since it unloads Tramp, it shall be the last test to run."
5714;; do not work properly for `nextcloud'. 5729;; do not work properly for `nextcloud'.
5715;; * Fix `tramp-test29-start-file-process' and 5730;; * Fix `tramp-test29-start-file-process' and
5716;; `tramp-test30-make-process' on MS Windows (`process-send-eof'?). 5731;; `tramp-test30-make-process' on MS Windows (`process-send-eof'?).
5717;; * Fix `tramp-test29-start-file-process',
5718;; `tramp-test30-make-process' and `tramp-test32-shell-command' for
5719;; `adb' (see comment in `tramp-adb-send-command').
5720;; * Rework `tramp-test34-explicit-shell-file-name'.
5721;; * Fix Bug#16928 in `tramp-test43-asynchronous-requests'. 5732;; * Fix Bug#16928 in `tramp-test43-asynchronous-requests'.
5733;; * Fix `tramp-test44-threads'.
5722 5734
5723(provide 'tramp-tests) 5735(provide 'tramp-tests)
5724;;; tramp-tests.el ends here 5736;;; tramp-tests.el ends here