aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2019-04-03 21:36:40 +0200
committerMichael Albinus2019-04-03 21:36:40 +0200
commit8147d3c27cbf29e18dbdd6bad21cd17bc880a8d3 (patch)
tree382338c2ceefa4545d0388ab625a508cddea58ad
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.
-rw-r--r--lisp/net/tramp-adb.el64
-rw-r--r--lisp/net/tramp-sh.el16
-rw-r--r--lisp/net/tramp.el13
-rw-r--r--test/lisp/net/tramp-tests.el110
4 files changed, 110 insertions, 93 deletions
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 68960426b68..db9acbfc631 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -968,7 +968,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
968 (program (car command)) 968 (program (car command))
969 (args (cdr command)) 969 (args (cdr command))
970 (command 970 (command
971 (format "cd %s; %s" 971 (format "cd %s && exec %s"
972 (tramp-shell-quote-argument localname) 972 (tramp-shell-quote-argument localname)
973 (mapconcat #'tramp-shell-quote-argument 973 (mapconcat #'tramp-shell-quote-argument
974 (cons program args) " "))) 974 (cons program args) " ")))
@@ -1000,24 +1000,16 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
1000 ;; otherwise we might be interrupted by 1000 ;; otherwise we might be interrupted by
1001 ;; `verify-visited-file-modtime'. 1001 ;; `verify-visited-file-modtime'.
1002 (let ((buffer-undo-list t) 1002 (let ((buffer-undo-list t)
1003 (inhibit-read-only t) 1003 (inhibit-read-only t))
1004 (mark (point)))
1005 (clear-visited-file-modtime) 1004 (clear-visited-file-modtime)
1006 (narrow-to-region (point-max) (point-max)) 1005 (narrow-to-region (point-max) (point-max))
1007 ;; We call `tramp-adb-maybe-open-connection', in 1006 ;; We call `tramp-adb-maybe-open-connection', in
1008 ;; order to cleanup the prompt afterwards. 1007 ;; order to cleanup the prompt afterwards.
1009 (tramp-adb-maybe-open-connection v) 1008 (tramp-adb-maybe-open-connection v)
1010 (widen) 1009 (delete-region (point-min) (point-max))
1011 (delete-region mark (point-max))
1012 (narrow-to-region (point-max) (point-max))
1013 ;; Send the command. 1010 ;; Send the command.
1014 (let* ((p (tramp-get-connection-process v)) 1011 (let* ((p (tramp-get-connection-process v)))
1015 (prompt 1012 (tramp-adb-send-command v command nil t) ; nooutput
1016 (tramp-get-connection-property p "prompt" nil)))
1017 (tramp-set-connection-property
1018 p "prompt" (regexp-quote command))
1019 (tramp-adb-send-command v command)
1020 (tramp-set-connection-property p "prompt" prompt)
1021 ;; Stop process if indicated. 1013 ;; Stop process if indicated.
1022 (when stop 1014 (when stop
1023 (stop-process p)) 1015 (stop-process p))
@@ -1032,6 +1024,14 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
1032 (ignore-errors 1024 (ignore-errors
1033 (set-process-query-on-exit-flag p (null noquery)) 1025 (set-process-query-on-exit-flag p (null noquery))
1034 (set-marker (process-mark p) (point))) 1026 (set-marker (process-mark p) (point)))
1027 ;; Read initial output. Remove the first line,
1028 ;; which is the command echo.
1029 (while
1030 (progn
1031 (goto-char (point-min))
1032 (not (re-search-forward "[\n]" nil t)))
1033 (tramp-accept-process-output p 0))
1034 (delete-region (point-min) (point))
1035 ;; Return process. 1035 ;; Return process.
1036 p)))) 1036 p))))
1037 1037
@@ -1119,26 +1119,27 @@ This happens for Android >= 4.0."
1119 1119
1120;; Connection functions 1120;; Connection functions
1121 1121
1122(defun tramp-adb-send-command (vec command) 1122(defun tramp-adb-send-command (vec command &optional neveropen nooutput)
1123 "Send the COMMAND to connection VEC." 1123 "Send the COMMAND to connection VEC."
1124 (tramp-adb-maybe-open-connection vec) 1124 (unless neveropen (tramp-adb-maybe-open-connection vec))
1125 (tramp-message vec 6 "%s" command) 1125 (tramp-message vec 6 "%s" command)
1126 (tramp-send-string vec command) 1126 (tramp-send-string vec command)
1127 ;; FIXME: Race condition. 1127 (unless nooutput
1128 (tramp-adb-wait-for-output (tramp-get-connection-process vec)) 1128 ;; FIXME: Race condition.
1129 (with-current-buffer (tramp-get-connection-buffer vec) 1129 (tramp-adb-wait-for-output (tramp-get-connection-process vec))
1130 (save-excursion 1130 (with-current-buffer (tramp-get-connection-buffer vec)
1131 (goto-char (point-min)) 1131 (save-excursion
1132 ;; We can't use stty to disable echo of command. stty is said 1132 (goto-char (point-min))
1133 ;; to be added to toybox 0.7.6. busybox shall have it, but this 1133 ;; We can't use stty to disable echo of command. stty is said
1134 ;; isn't used any longer for Android. 1134 ;; to be added to toybox 0.7.6. busybox shall have it, but this
1135 (delete-matching-lines (regexp-quote command)) 1135 ;; isn't used any longer for Android.
1136 ;; When the local machine is W32, there are still trailing ^M. 1136 (delete-matching-lines (regexp-quote command))
1137 ;; There must be a better solution by setting the correct coding 1137 ;; When the local machine is W32, there are still trailing ^M.
1138 ;; system, but this requires changes in core Tramp. 1138 ;; There must be a better solution by setting the correct coding
1139 (goto-char (point-min)) 1139 ;; system, but this requires changes in core Tramp.
1140 (while (re-search-forward "\r+$" nil t) 1140 (goto-char (point-min))
1141 (replace-match "" nil nil))))) 1141 (while (re-search-forward "\r+$" nil t)
1142 (replace-match "" nil nil))))))
1142 1143
1143(defun tramp-adb-send-command-and-check (vec command) 1144(defun tramp-adb-send-command-and-check (vec command)
1144 "Run COMMAND and check its exit status. 1145 "Run COMMAND and check its exit status.
@@ -1245,6 +1246,9 @@ connection if a previous connection has died for some reason."
1245 (tramp-adb-wait-for-output p 30) 1246 (tramp-adb-wait-for-output p 30)
1246 (unless (process-live-p p) 1247 (unless (process-live-p p)
1247 (tramp-error vec 'file-error "Terminated!")) 1248 (tramp-error vec 'file-error "Terminated!"))
1249
1250 ;; Set sentinel and query flag. Initialize variables.
1251 (set-process-sentinel p #'tramp-process-sentinel)
1248 (process-put p 'vector vec) 1252 (process-put p 'vector vec)
1249 (process-put p 'adjust-window-size-function #'ignore) 1253 (process-put p 'adjust-window-size-function #'ignore)
1250 (set-process-query-on-exit-flag p nil) 1254 (set-process-query-on-exit-flag p nil)
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index edd9af489e2..7d903c5769c 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -2769,15 +2769,6 @@ the result will be a local, non-Tramp, file name."
2769 2769
2770;;; Remote commands: 2770;;; Remote commands:
2771 2771
2772(defun tramp-process-sentinel (proc event)
2773 "Flush file caches."
2774 (unless (process-live-p proc)
2775 (let ((vec (process-get proc 'vector)))
2776 (when vec
2777 (tramp-message vec 5 "Sentinel called: `%S' `%s'" proc event)
2778 (tramp-flush-connection-properties proc)
2779 (tramp-flush-directory-properties vec "")))))
2780
2781;; We use BUFFER also as connection buffer during setup. Because of 2772;; We use BUFFER also as connection buffer during setup. Because of
2782;; this, its original contents must be saved, and restored once 2773;; this, its original contents must be saved, and restored once
2783;; connection has been setup. 2774;; connection has been setup.
@@ -2912,8 +2903,7 @@ the result will be a local, non-Tramp, file name."
2912 ;; otherwise we might be interrupted by 2903 ;; otherwise we might be interrupted by
2913 ;; `verify-visited-file-modtime'. 2904 ;; `verify-visited-file-modtime'.
2914 (let ((buffer-undo-list t) 2905 (let ((buffer-undo-list t)
2915 (inhibit-read-only t) 2906 (inhibit-read-only t))
2916 (mark (point-max)))
2917 (clear-visited-file-modtime) 2907 (clear-visited-file-modtime)
2918 (narrow-to-region (point-max) (point-max)) 2908 (narrow-to-region (point-max) (point-max))
2919 ;; We call `tramp-maybe-open-connection', in 2909 ;; We call `tramp-maybe-open-connection', in
@@ -2926,9 +2916,7 @@ the result will be a local, non-Tramp, file name."
2926 (let ((pid (tramp-send-command-and-read v "echo $$"))) 2916 (let ((pid (tramp-send-command-and-read v "echo $$")))
2927 (process-put p 'remote-pid pid) 2917 (process-put p 'remote-pid pid)
2928 (tramp-set-connection-property p "remote-pid" pid)) 2918 (tramp-set-connection-property p "remote-pid" pid))
2929 (widen) 2919 (delete-region (point-min) (point-max))
2930 (delete-region mark (point-max))
2931 (narrow-to-region (point-max) (point-max))
2932 ;; Now do it. 2920 ;; Now do it.
2933 (if command 2921 (if command
2934 ;; Send the command. 2922 ;; Send the command.
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 7206d8eb8a6..0fc2d33d222 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -4212,6 +4212,19 @@ the remote host use line-endings as defined in the variable
4212 ;; Reenable the timers. 4212 ;; Reenable the timers.
4213 (with-timeout-unsuspend stimers)))) 4213 (with-timeout-unsuspend stimers))))
4214 4214
4215(defun tramp-process-sentinel (proc event)
4216 "Flush file caches and remove shell prompt."
4217 (unless (process-live-p proc)
4218 (let ((vec (process-get proc 'vector))
4219 (prompt (tramp-get-connection-property proc "prompt" nil)))
4220 (when vec
4221 (tramp-message vec 5 "Sentinel called: `%S' `%s'" proc event)
4222 (tramp-flush-connection-properties proc)
4223 (tramp-flush-directory-properties vec ""))
4224 (goto-char (point-max))
4225 (when (and prompt (re-search-backward (regexp-quote prompt) nil t))
4226 (delete-region (point) (point-max))))))
4227
4215(defun tramp-get-inode (vec) 4228(defun tramp-get-inode (vec)
4216 "Returns the virtual inode number. 4229 "Returns the virtual inode number.
4217If it doesn't exist, generate a new one." 4230If it doesn't exist, generate a new one."
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