[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/cider 30ad2e93c2 3/4: Check that client is connected to nR
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/cider 30ad2e93c2 3/4: Check that client is connected to nREPL server |
Date: |
Thu, 8 Dec 2022 10:58:40 -0500 (EST) |
branch: elpa/cider
commit 30ad2e93c28fb9972bd22dbc056b42fdcbe46974
Author: ikappaki <ikappaki@users.noreply.github.com>
Commit: Bozhidar Batsov <bozhidar@batsov.dev>
Check that client is connected to nREPL server
---
test/integration/integration-tests.el | 37 +++++++++++++++++++++++++++++++----
test/nrepl-client-tests.el | 13 +++++-------
test/utils/nrepl-tests-utils.el | 16 ---------------
3 files changed, 38 insertions(+), 28 deletions(-)
diff --git a/test/integration/integration-tests.el
b/test/integration/integration-tests.el
index 854cb9a2e0..94a9fc40e0 100644
--- a/test/integration/integration-tests.el
+++ b/test/integration/integration-tests.el
@@ -43,6 +43,19 @@ Remove the temp directory at the end of evaluation."
(error
(message ":with-temp-dir-error :cannot-remove-temp-dir %S" err))))))
+(defun nrepl-client-connected?-ref-make! ()
+ "Return a reference to indicate when the client is connected to nREPL server.
+This is done by adding a hook to `cider-connected-hook` and is only active
+in the scope of the current buffer."
+ (let (connected?)
+ (add-hook 'cider-connected-hook
+ (lambda ()
+ (setq connected? t))
+ nil
+ ;; only set in the current buffer scope.
+ t)))
+
+
(describe "jack in"
;; See "bb" case for basic commentary
;;
@@ -63,8 +76,15 @@ Remove the temp directory at the end of evaluation."
(unwind-protect
;; jack in and get repl buffer
- (let* ((nrepl-proc (cider-jack-in-clj '()))
+ (let* ((client-connected?* (nrepl-client-connected?-ref-make!))
+ (nrepl-proc (cider-jack-in-clj '()))
(nrepl-buf (process-buffer nrepl-proc)))
+
+ ;; wait until the client has successfully connected to the
+ ;; nREPL server.
+ (nrepl-tests-sleep-until 5 client-connected?*)
+ (expect client-connected?*)
+
;; give it some time to setup the clj REPL
(nrepl-tests-sleep-until 5 (cider-repls 'clj nil))
@@ -113,8 +133,11 @@ Remove the temp directory at the end of evaluation."
(with-temp-buffer
(setq-local default-directory project-dir)
(unwind-protect
- (let* ((nrepl-proc (cider-jack-in-clj `()))
+ (let* ((client-connected?* (nrepl-client-connected?-ref-make!))
+ (nrepl-proc (cider-jack-in-clj `()))
(nrepl-buf (process-buffer nrepl-proc)))
+ (nrepl-tests-sleep-until 5 client-connected?*)
+ (expect client-connected?*)
;; high duration since on windows it takes a long time to
startup
(nrepl-tests-sleep-until 90 (cider-repls 'clj nil))
@@ -150,8 +173,11 @@ Remove the temp directory at the end of evaluation."
(with-temp-buffer
(setq-local default-directory project-dir)
(unwind-protect
- (let* ((nrepl-proc (cider-jack-in-clj `()))
+ (let* ((client-connected?* (nrepl-client-connected?-ref-make!))
+ (nrepl-proc (cider-jack-in-clj `()))
(nrepl-buf (process-buffer nrepl-proc)))
+ (nrepl-tests-sleep-until 5 client-connected?*)
+ (expect client-connected?*)
(nrepl-tests-sleep-until 90 (cider-repls 'clj nil))
(let ((repl-buffer (cider-current-repl))
(eval-err '())
@@ -197,8 +223,11 @@ Remove the temp directory at the end of evaluation."
(with-temp-buffer
(setq-local default-directory project-dir)
(unwind-protect
- (let* ((nrepl-proc (cider-jack-in-cljs '(:cljs-repl-type
shadow)))
+ (let* ((client-connected?*
(nrepl-client-connected?-ref-make!))
+ (nrepl-proc (cider-jack-in-cljs '(:cljs-repl-type
shadow)))
(nrepl-buf (process-buffer nrepl-proc)))
+ (nrepl-tests-sleep-until 5 client-connected?*)
+ (expect client-connected?*)
(nrepl-tests-sleep-until 120 (cider-repls 'cljs nil))
(expect (cider-repls 'cljs nil) :not :to-be nil)
(let ((repl-buffer (cider-current-repl))
diff --git a/test/nrepl-client-tests.el b/test/nrepl-client-tests.el
index b8da9bcccc..4f57a24cc0 100644
--- a/test/nrepl-client-tests.el
+++ b/test/nrepl-client-tests.el
@@ -159,8 +159,7 @@
;; server has reported its endpoint
(nrepl-tests-sleep-until 2 server-endpoint)
(expect server-endpoint :not :to-be nil)
- (expect (plist-get (process-plist server-process)
:cider--nrepl-server-ready)
- :to-equal t)
+
(condition-case error-details
;; start client process
(let* ((client-buffer (get-buffer-create
":nrepl-lifecycle/client"))
@@ -183,12 +182,10 @@
(delete-process process-client)
;; server process has been signalled
- (nrepl-tests-sleep-until 4 (member (process-status
server-process)
- '(exit signal)))
- (expect (let ((status (process-status server-process)))
- (if (eq system-type 'windows-nt)
- (eq status 'exit)
- (eq status 'signal)))))
+ (nrepl-tests-sleep-until 4 (eq (process-status server-process)
+ 'signal))
+ (expect (process-status server-process)
+ :to-equal 'signal))
(error
;; there may be some useful information in the nrepl buffer on error
(when-let ((nrepl-error-buffer (get-buffer "*nrepl-error*")))
diff --git a/test/utils/nrepl-tests-utils.el b/test/utils/nrepl-tests-utils.el
index 0552b51d43..e7a4a17164 100644
--- a/test/utils/nrepl-tests-utils.el
+++ b/test/utils/nrepl-tests-utils.el
@@ -25,8 +25,6 @@
;;; Code:
-(require 'nrepl-client)
-
(defmacro nrepl-tests-log/init! (enable? name log-filename &optional clean?)
"Create a NAME/log! elisp function to log messages to LOG-FILENAME,
taking the same arguments as `message'. Messages are appended to
@@ -99,19 +97,5 @@ calling process."
;; invoke mock server
" -l test/nrepl-server-mock.el -f nrepl-server-mock-start"))
-(defun nrepl-start-mock-server-process ()
- "Start and return the mock nrepl server process."
- (let* ((up? nil)
- (server-process (nrepl-start-server-process
- default-directory
- (nrepl-server-mock-invocation-string)
- (lambda (server-buffer)
- (setq up? t)))))
- ;; server has reported its endpoint
- (nrepl-tests-sleep-until 2 up?)
- server-process))
(provide 'nrepl-tests-utils)
-
-;;; nrepl-tests-utils.el ends here
-