emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master f8a9edc: Fix some oddities, uncovered by Tramp tests


From: Michael Albinus
Subject: master f8a9edc: Fix some oddities, uncovered by Tramp tests
Date: Wed, 13 May 2020 08:11:26 -0400 (EDT)

branch: master
commit f8a9edce7339273f9c56d27cc6999a22907638e7
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>

    Fix some oddities, uncovered by Tramp tests
    
    * lisp/net/tramp-gvfs.el (tramp-gvfs-enabled): Prevent crash for
    older Emacsen.
    
    * lisp/net/tramp.el (tramp-process-running-p): Simplify.
    
    * test/lisp/net/tramp-tests.el (tramp-test28-process-file): Adapt test.
    (tramp-test33-environment-variables): Unset "INSIDE_EMACS" initially.
---
 lisp/net/tramp-gvfs.el       |  5 ++++-
 lisp/net/tramp.el            | 15 ++++++++-------
 test/lisp/net/tramp-tests.el | 16 +++++++++++++---
 3 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index f19e510..704d65c 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -125,7 +125,10 @@
         (autoload 'zeroconf-init "zeroconf")
         (tramp-compat-funcall 'dbus-get-unique-name :system)
         (tramp-compat-funcall 'dbus-get-unique-name :session)
-        (or (tramp-process-running-p "gvfs-fuse-daemon")
+        (or ;; Until Emacs 25, `process-attributes' could crash Emacs
+            ;; for some processes.  Better we don't check.
+            (<= emacs-major-version 25)
+            (tramp-process-running-p "gvfs-fuse-daemon")
             (tramp-process-running-p "gvfsd-fuse"))))
   "Non-nil when GVFS is available.")
 
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index c8fdc5d..70fb46b 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3783,7 +3783,8 @@ support symbolic links."
 (defun tramp-handle-start-file-process (name buffer program &rest args)
   "Like `start-file-process' for Tramp files.
 BUFFER might be a list, in this case STDERR is separated."
-  ;; `make-process' knows the `:file-handler' argument since Emacs 27.1 only.
+  ;; `make-process' knows the `:file-handler' argument since Emacs
+  ;; 27.1 only.  Therefore, we invoke it via `tramp-file-name-handler'.
   (tramp-file-name-handler
    'make-process
    :name name
@@ -4857,13 +4858,13 @@ verbosity of 6."
   "Return t if system process PROCESS-NAME is running for `user-login-name'."
   (when (stringp process-name)
     (catch 'result
-      (dolist (pid (tramp-compat-funcall 'list-system-processes))
-       (let ((attributes (process-attributes pid)))
+      (dolist (pid (list-system-processes))
+       (when-let ((attributes (process-attributes pid))
+                  (comm (cdr (assoc 'comm attributes))))
          (and (string-equal (cdr (assoc 'user attributes)) (user-login-name))
-               (when-let ((comm (cdr (assoc 'comm attributes))))
-                 ;; The returned command name could be truncated to 15
-                 ;; characters.  Therefore, we cannot check for `string-equal'.
-                (string-prefix-p comm process-name))
+               ;; The returned command name could be truncated to 15
+               ;; characters.  Therefore, we cannot check for `string-equal'.
+              (string-prefix-p comm process-name)
               (throw 'result t)))))))
 
 (defun tramp-read-passwd (proc &optional prompt)
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 8c3cb8e..de85f83 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -4208,10 +4208,19 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
            (should (zerop (process-file "true")))
            (should-not (zerop (process-file "false")))
            (should-not (zerop (process-file "binary-does-not-exist")))
-           (should (= (if (getenv "EMACS_HYDRA_CI") 127 42)
-                      (process-file "sh" nil nil nil "-c" "exit 42")))
+           (should
+            (= 42
+               (process-file
+                (if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh")
+                nil nil nil "-c" "exit 42")))
            ;; Return string in case the process is interrupted.
-           (should (stringp (process-file "sh" nil nil nil "-c" "kill -2 $$")))
+           (should
+            (string-equal
+             "Signal 2"
+             (process-file
+              (if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh")
+              nil nil nil "-c" "kill -2 $$")))
+
            (with-temp-buffer
              (write-region "foo" nil tmp-name)
              (should (file-exists-p tmp-name))
@@ -4874,6 +4883,7 @@ INPUT, if non-nil, is a string sent to the process."
          kill-buffer-query-functions)
 
       ;; Check INSIDE_EMACS.
+      (setenv "INSIDE_EMACS")
       (should
        (string-equal
        (format "%s,tramp:%s" emacs-version tramp-version)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]