emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/detached 9f67f604af: Updates to public interface


From: ELPA Syncer
Subject: [elpa] externals/detached 9f67f604af: Updates to public interface
Date: Sun, 13 Nov 2022 08:57:31 -0500 (EST)

branch: externals/detached
commit 9f67f604af1c26547c219448b55ae19292b8fa5d
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>

    Updates to public interface
---
 detached.el           | 13 +++++++++----
 test/detached-test.el | 21 +++++++++++++++++++++
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/detached.el b/detached.el
index c6e996f812..6e946c1d53 100644
--- a/detached.el
+++ b/detached.el
@@ -1012,6 +1012,11 @@ This function uses the `notifications' library."
   (eq 'initialized
       (gethash (detached--session-id session) detached--hashed-sessions)))
 
+(defun detached-session-watched-p (session)
+  "Return t if SESSION is being watched."
+  (detached--watched-session-directory-p
+   (detached--session-directory session)))
+
 ;;;;; Other
 
 (cl-defgeneric detached--get-session (_mode)
@@ -1281,10 +1286,10 @@ Optionally make the path LOCAL to host."
 
 (defun detached--maybe-watch-session (session)
   "Maybe watch SESSION."
-  (let ((session-directory (detached--session-directory session)))
-    (and (detached-session-active-p session)
-         (not (detached--watched-session-directory-p session-directory))
-         (detached--watch-session-directory session-directory))))
+  (and (detached-session-active-p session)
+       (not (detached-session-watched-p session))
+       (detached--watch-session-directory
+        (detached--session-directory session))))
 
 (defun detached--create-session-directory ()
   "Create session directory if it doesn't exist."
diff --git a/test/detached-test.el b/test/detached-test.el
index b936be9c0d..cfd37e4569 100644
--- a/test/detached-test.el
+++ b/test/detached-test.el
@@ -66,6 +66,27 @@
 
 ;;;; Tests
 
+;;;;; Session interface
+
+(ert-deftest detached-test-session-status ()
+  (let ((failed-session (detached--session-create :status `(failure . 128))))
+    (should (detached-session-failed-p failed-session))
+    (should (= 128 (detached-session-exit-code failed-session)))))
+
+(ert-deftest detached-test-session-host ()
+  ;; Remotehost session
+  (let ((remote-session (detached--session-create :host `("foo" . 
remotehost))))
+    (should (detached-session-remotehost-p remote-session))
+    (should (not (detached-session-localhost-p remote-session)))
+    (should (string= "foo" (detached-session-host-name remote-session))))
+  ;; Localhost session
+  (let ((local-session (detached--session-create :host `("bar" . localhost))))
+    (should (not (detached-session-remotehost-p local-session)))
+    (should (detached-session-localhost-p local-session))
+    (should (string= "bar" (detached-session-host-name local-session)))))
+
+;;;;; Other
+
 (ert-deftest detached-test-dtach-command ()
   (detached-test--with-temp-database
    (cl-letf* ((detached-dtach-program "dtach")



reply via email to

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