Skip to content

Commit 68ae7f8

Browse files
committed
Add nbb integration tests, pick up pending-cljs changes
1 parent 5d1b8ce commit 68ae7f8

File tree

4 files changed

+80
-10
lines changed

4 files changed

+80
-10
lines changed

Diff for: .github/workflows/test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ jobs:
6767
with:
6868
node-version: 16
6969
- run: npm install [email protected] -g
70+
- run: npm install [email protected] -g
7071

7172
- name: Test integration
7273
run: |

Diff for: cider.el

+10-8
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
;; Maintainer: Bozhidar Batsov <[email protected]>
1313
;; URL: http://www.github.com/clojure-emacs/cider
1414
;; Version: 1.6.0-snapshot
15-
;; Package-Requires: ((emacs "26") (clojure-mode "5.15.1") (parseedn "1.0.6") (queue "0.2") (spinner "1.7") (seq "2.22") (sesman "0.3.2"))
15+
;; Package-Requires: ((emacs "26") (clojure-mode "5.16.0") (parseedn "1.0.6") (queue "0.2") (spinner "1.7") (seq "2.22") (sesman "0.3.2"))
1616
;; Keywords: languages, clojure, cider
1717

1818
;; This program is free software: you can redistribute it and/or modify
@@ -1296,7 +1296,7 @@ server buffer, in which case a new session for that server is created."
12961296
(cider--update-cljs-type)
12971297
(cider--update-cljs-init-function)
12981298
(plist-put :session-name ses-name)
1299-
(plist-put :cider-repl-cljs-upgrade-pending t)))))
1299+
(plist-put :repl-type 'cljs)))))
13001300

13011301
;;;###autoload
13021302
(defun cider-connect-clj (&optional params)
@@ -1330,7 +1330,7 @@ parameters regardless of their supplied or default values."
13301330
(cider--update-cljs-type)
13311331
(cider--update-cljs-init-function)
13321332
(plist-put :session-name nil)
1333-
(plist-put :cider-repl-cljs-upgrade-pending t))))
1333+
(plist-put :repl-type 'cljs))))
13341334

13351335
;;;###autoload
13361336
(defun cider-connect-clj&cljs (params &optional soft-cljs-start)
@@ -1506,8 +1506,9 @@ non-nil, don't start if ClojureScript requirements are not met."
15061506
15071507
The updated params are:
15081508
1509-
:cljs-type 'cljs if it is a cljs REPL, or 'pending-cljs when the init form
1510-
is required to be sent to the REPL to switch over to cljs.
1509+
:cider-repl-cljs-upgrade-pending nil if it is a cljs REPL, or t
1510+
when the init form is required to be sent to the REPL to switch
1511+
over to cljs.
15111512
15121513
:repl-init-form The form that can switch the REPL over to cljs.
15131514
@@ -1517,9 +1518,11 @@ is required to be sent to the REPL to switch over to cljs.
15171518
(let* ((cljs-type (plist-get params :cljs-repl-type))
15181519
(repl-init-form (cider-cljs-repl-form cljs-type)))
15191520
(if (null repl-init-form)
1520-
(plist-put params :repl-type 'cljs)
1521+
(plist-put params :cider-repl-cljs-upgrade-pending nil)
1522+
15211523
(thread-first
15221524
params
1525+
(plist-put :cider-repl-cljs-upgrade-pending t)
15231526
(plist-put :repl-init-function
15241527
(lambda ()
15251528
(cider--check-cljs cljs-type)
@@ -1533,8 +1536,7 @@ is required to be sent to the REPL to switch over to cljs.
15331536
(when (and (buffer-live-p nrepl-server-buffer)
15341537
cider-offer-to-open-cljs-app-in-browser)
15351538
(cider--offer-to-open-app-in-browser nrepl-server-buffer))))
1536-
(plist-put :repl-init-form repl-init-form)
1537-
(plist-put :repl-type 'pending-cljs))))))
1539+
(plist-put :repl-init-form repl-init-form))))))
15381540

15391541
(defun cider--check-existing-session (params)
15401542
"Ask for confirmation if a session with similar PARAMS already exists.

Diff for: test/cider-tests.el

+10-2
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,8 @@
597597
;; native cljs REPL
598598
(expect (buffer-local-value 'cider-repl-type client-buffer)
599599
:to-equal 'cljs)
600+
(expect (buffer-local-value 'cider-repl-cljs-upgrade-pending client-buffer)
601+
:to-equal nil)
600602
(expect (buffer-local-value 'cider-repl-init-function client-buffer)
601603
:to-be nil)
602604
(delete-process (get-buffer-process client-buffer))))
@@ -608,7 +610,9 @@
608610
'(:cljs-repl-type shadow) server-buffer)))
609611
;; starts as clj REPL and requires a form to switch over to cljs
610612
(expect (buffer-local-value 'cider-repl-type client-buffer)
611-
:to-equal 'pending-cljs)
613+
:to-equal 'cljs)
614+
(expect (buffer-local-value 'cider-repl-cljs-upgrade-pending client-buffer)
615+
:to-equal t)
612616
(expect (buffer-local-value 'cider-repl-init-function client-buffer)
613617
:not :to-be nil)
614618
(delete-process (get-buffer-process client-buffer))))
@@ -621,6 +625,8 @@
621625
server-buffer)))
622626
(expect (buffer-local-value 'cider-repl-type client-buffer)
623627
:to-equal 'cljs)
628+
(expect (buffer-local-value 'cider-repl-cljs-upgrade-pending client-buffer)
629+
:to-equal nil)
624630
(delete-process (get-buffer-process client-buffer))))
625631
(it "for a custom REPL type project that needs to switch to cljs"
626632
(cider-register-cljs-repl-type
@@ -631,7 +637,9 @@
631637
'(:cljs-repl-type not-cljs-initially)
632638
server-buffer)))
633639
(expect (buffer-local-value 'cider-repl-type client-buffer)
634-
:to-equal 'pending-cljs)
640+
:to-equal 'cljs)
641+
(expect (buffer-local-value 'cider-repl-cljs-upgrade-pending client-buffer)
642+
:to-equal t)
635643
(expect (buffer-local-value 'cider-repl-init-function client-buffer)
636644
:not :to-be nil)
637645
(delete-process (get-buffer-process client-buffer))))))

Diff for: test/integration/integration-tests.el

+59
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,65 @@
216216
(cider-itu-poll-until (not (eq (process-status nrepl-proc) 'run)) 15)
217217
(expect (member (process-status nrepl-proc) '(exit signal))))))))))
218218

219+
(it "to nbb"
220+
(with-cider-test-sandbox
221+
(with-temp-dir temp-dir
222+
;; Create a project in temp dir
223+
(let* ((project-dir temp-dir)
224+
(nbb-edn (expand-file-name "nbb.edn" project-dir)))
225+
(write-region "{}" nil nbb-edn)
226+
227+
(with-temp-buffer
228+
;; set default directory to temp project
229+
(setq-local default-directory project-dir)
230+
231+
(let* (;; Get a gv reference so as to poll if the client has
232+
;; connected to the nREPL server.
233+
(client-is-connected* (cider-itu-nrepl-client-connected-ref-make!))
234+
235+
;; jack in and get repl buffer
236+
(nrepl-proc (cider-jack-in-clj '(:cljs-repl-type nbb)))
237+
(nrepl-buf (process-buffer nrepl-proc)))
238+
239+
;; wait until the client has successfully connected to the
240+
;; nREPL server.
241+
(cider-itu-poll-until (eq (gv-deref client-is-connected*) 'connected) 5)
242+
243+
;; give it some time to setup the clj REPL
244+
(cider-itu-poll-until (cider-repls 'clj nil) 5)
245+
246+
;; send command to the REPL, and push stdout/stderr to
247+
;; corresponding eval-xxx variables.
248+
(let ((repl-buffer (cider-current-repl))
249+
(eval-err '())
250+
(eval-out '()))
251+
(expect repl-buffer :not :to-be nil)
252+
253+
;; send command to the REPL
254+
(cider-interactive-eval
255+
;; ask REPL to return a string that uniquely identifies it.
256+
"(print :nbb? (some? (nbb.core/version)))"
257+
(lambda (return)
258+
(nrepl-dbind-response
259+
return
260+
(out err)
261+
(when err (push err eval-err))
262+
(when out (push out eval-out)))) )
263+
264+
;; wait for a response to come back.
265+
(cider-itu-poll-until (or eval-err eval-out) 5)
266+
267+
;; ensure there are no errors and response is as expected.
268+
(expect eval-err :to-equal '())
269+
(expect eval-out :to-equal '(":nbb? true"))
270+
271+
;; exit the REPL.
272+
(cider-quit repl-buffer)
273+
274+
;; wait for the REPL to exit
275+
(cider-itu-poll-until (not (eq (process-status nrepl-proc) 'run)) 5)
276+
(expect (member (process-status nrepl-proc) '(exit signal))))))))))
277+
219278
(it "to shadow"
220279
;; shadow asks user whether they want to open a browser, force to no
221280
(spy-on 'y-or-n-p)

0 commit comments

Comments
 (0)