@@ -43,6 +43,19 @@ Remove the temp directory at the end of evaluation."
43
43
(error
44
44
(message " :with-temp-dir-error :cannot-remove-temp-dir %S " err))))))
45
45
46
+ (defun nrepl-client-connected?-ref-make! ()
47
+ " Return a reference to indicate when the client is connected to nREPL server.
48
+ This is done by adding a hook to `cider-connected-hook` and is only active
49
+ in the scope of the current buffer."
50
+ (let (connected?)
51
+ (add-hook 'cider-connected-hook
52
+ (lambda ()
53
+ (setq connected? t ))
54
+ nil
55
+ ; ; only set in the current buffer scope.
56
+ t )))
57
+
58
+
46
59
(describe " jack in"
47
60
; ; See "bb" case for basic commentary
48
61
; ;
@@ -63,8 +76,15 @@ Remove the temp directory at the end of evaluation."
63
76
64
77
(unwind-protect
65
78
; ; jack in and get repl buffer
66
- (let* ((nrepl-proc (cider-jack-in-clj '()))
79
+ (let* ((client-connected?* (nrepl-client-connected?- ref-make!))
80
+ (nrepl-proc (cider-jack-in-clj '()))
67
81
(nrepl-buf (process-buffer nrepl-proc)))
82
+
83
+ ; ; wait until the client has successfully connected to the
84
+ ; ; nREPL server.
85
+ (nrepl-tests-sleep-until 5 client-connected?* )
86
+ (expect client-connected?* )
87
+
68
88
; ; give it some time to setup the clj REPL
69
89
(nrepl-tests-sleep-until 5 (cider-repls 'clj nil ))
70
90
@@ -113,8 +133,11 @@ Remove the temp directory at the end of evaluation."
113
133
(with-temp-buffer
114
134
(setq-local default-directory project-dir)
115
135
(unwind-protect
116
- (let* ((nrepl-proc (cider-jack-in-clj `()))
136
+ (let* ((client-connected?* (nrepl-client-connected?- ref-make!))
137
+ (nrepl-proc (cider-jack-in-clj `()))
117
138
(nrepl-buf (process-buffer nrepl-proc)))
139
+ (nrepl-tests-sleep-until 5 client-connected?* )
140
+ (expect client-connected?* )
118
141
119
142
; ; high duration since on windows it takes a long time to startup
120
143
(nrepl-tests-sleep-until 90 (cider-repls 'clj nil ))
@@ -150,8 +173,11 @@ Remove the temp directory at the end of evaluation."
150
173
(with-temp-buffer
151
174
(setq-local default-directory project-dir)
152
175
(unwind-protect
153
- (let* ((nrepl-proc (cider-jack-in-clj `()))
176
+ (let* ((client-connected?* (nrepl-client-connected?- ref-make!))
177
+ (nrepl-proc (cider-jack-in-clj `()))
154
178
(nrepl-buf (process-buffer nrepl-proc)))
179
+ (nrepl-tests-sleep-until 5 client-connected?* )
180
+ (expect client-connected?* )
155
181
(nrepl-tests-sleep-until 90 (cider-repls 'clj nil ))
156
182
(let ((repl-buffer (cider-current-repl))
157
183
(eval-err '())
@@ -197,8 +223,11 @@ Remove the temp directory at the end of evaluation."
197
223
(with-temp-buffer
198
224
(setq-local default-directory project-dir)
199
225
(unwind-protect
200
- (let* ((nrepl-proc (cider-jack-in-cljs '(:cljs-repl-type shadow )))
226
+ (let* ((client-connected?* (nrepl-client-connected?- ref-make!))
227
+ (nrepl-proc (cider-jack-in-cljs '(:cljs-repl-type shadow )))
201
228
(nrepl-buf (process-buffer nrepl-proc)))
229
+ (nrepl-tests-sleep-until 5 client-connected?* )
230
+ (expect client-connected?* )
202
231
(nrepl-tests-sleep-until 120 (cider-repls 'cljs nil ))
203
232
(expect (cider-repls 'cljs nil ) :not :to-be nil )
204
233
(let ((repl-buffer (cider-current-repl))
0 commit comments