branch: elpa/cider commit 7571f4dbc3ca1304091e6ef3d669068175df8bf8 Author: ikappaki <ikapp...@users.noreply.github.com> Commit: Bozhidar Batsov <bozhi...@batsov.dev>
Add nbb integration tests, pick up pending-cljs changes --- .github/workflows/test.yml | 1 + cider.el | 18 ++++++----- test/cider-tests.el | 12 +++++-- test/integration/integration-tests.el | 59 +++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 91fd0cd6bc..fb8701862b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -67,6 +67,7 @@ jobs: with: node-version: 16 - run: npm install shadow-cljs@2.20.13 -g + - run: npm install nbb@1.1.152 -g - name: Test integration run: | diff --git a/cider.el b/cider.el index 1c0f53178b..e7283bc697 100644 --- a/cider.el +++ b/cider.el @@ -12,7 +12,7 @@ ;; Maintainer: Bozhidar Batsov <bozhi...@batsov.dev> ;; URL: http://www.github.com/clojure-emacs/cider ;; Version: 1.6.0-snapshot -;; 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")) +;; 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")) ;; Keywords: languages, clojure, cider ;; 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." (cider--update-cljs-type) (cider--update-cljs-init-function) (plist-put :session-name ses-name) - (plist-put :cider-repl-cljs-upgrade-pending t))))) + (plist-put :repl-type 'cljs))))) ;;;###autoload (defun cider-connect-clj (&optional params) @@ -1330,7 +1330,7 @@ parameters regardless of their supplied or default values." (cider--update-cljs-type) (cider--update-cljs-init-function) (plist-put :session-name nil) - (plist-put :cider-repl-cljs-upgrade-pending t)))) + (plist-put :repl-type 'cljs)))) ;;;###autoload (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." The updated params are: -:cljs-type 'cljs if it is a cljs REPL, or 'pending-cljs when the init form -is required to be sent to the REPL to switch over to cljs. +:cider-repl-cljs-upgrade-pending nil if it is a cljs REPL, or t +when the init form is required to be sent to the REPL to switch +over to cljs. :repl-init-form The form that can switch the REPL over to cljs. @@ -1517,9 +1518,11 @@ is required to be sent to the REPL to switch over to cljs. (let* ((cljs-type (plist-get params :cljs-repl-type)) (repl-init-form (cider-cljs-repl-form cljs-type))) (if (null repl-init-form) - (plist-put params :repl-type 'cljs) + (plist-put params :cider-repl-cljs-upgrade-pending nil) + (thread-first params + (plist-put :cider-repl-cljs-upgrade-pending t) (plist-put :repl-init-function (lambda () (cider--check-cljs cljs-type) @@ -1533,8 +1536,7 @@ is required to be sent to the REPL to switch over to cljs. (when (and (buffer-live-p nrepl-server-buffer) cider-offer-to-open-cljs-app-in-browser) (cider--offer-to-open-app-in-browser nrepl-server-buffer)))) - (plist-put :repl-init-form repl-init-form) - (plist-put :repl-type 'pending-cljs)))))) + (plist-put :repl-init-form repl-init-form)))))) (defun cider--check-existing-session (params) "Ask for confirmation if a session with similar PARAMS already exists. diff --git a/test/cider-tests.el b/test/cider-tests.el index 052c09f128..ecb6cabbc4 100644 --- a/test/cider-tests.el +++ b/test/cider-tests.el @@ -597,6 +597,8 @@ ;; native cljs REPL (expect (buffer-local-value 'cider-repl-type client-buffer) :to-equal 'cljs) + (expect (buffer-local-value 'cider-repl-cljs-upgrade-pending client-buffer) + :to-equal nil) (expect (buffer-local-value 'cider-repl-init-function client-buffer) :to-be nil) (delete-process (get-buffer-process client-buffer)))) @@ -608,7 +610,9 @@ '(:cljs-repl-type shadow) server-buffer))) ;; starts as clj REPL and requires a form to switch over to cljs (expect (buffer-local-value 'cider-repl-type client-buffer) - :to-equal 'pending-cljs) + :to-equal 'cljs) + (expect (buffer-local-value 'cider-repl-cljs-upgrade-pending client-buffer) + :to-equal t) (expect (buffer-local-value 'cider-repl-init-function client-buffer) :not :to-be nil) (delete-process (get-buffer-process client-buffer)))) @@ -621,6 +625,8 @@ server-buffer))) (expect (buffer-local-value 'cider-repl-type client-buffer) :to-equal 'cljs) + (expect (buffer-local-value 'cider-repl-cljs-upgrade-pending client-buffer) + :to-equal nil) (delete-process (get-buffer-process client-buffer)))) (it "for a custom REPL type project that needs to switch to cljs" (cider-register-cljs-repl-type @@ -631,7 +637,9 @@ '(:cljs-repl-type not-cljs-initially) server-buffer))) (expect (buffer-local-value 'cider-repl-type client-buffer) - :to-equal 'pending-cljs) + :to-equal 'cljs) + (expect (buffer-local-value 'cider-repl-cljs-upgrade-pending client-buffer) + :to-equal t) (expect (buffer-local-value 'cider-repl-init-function client-buffer) :not :to-be nil) (delete-process (get-buffer-process client-buffer)))))) diff --git a/test/integration/integration-tests.el b/test/integration/integration-tests.el index b4f76022a7..27e0448bd5 100644 --- a/test/integration/integration-tests.el +++ b/test/integration/integration-tests.el @@ -216,6 +216,65 @@ (cider-itu-poll-until (not (eq (process-status nrepl-proc) 'run)) 15) (expect (member (process-status nrepl-proc) '(exit signal)))))))))) + (it "to nbb" + (with-cider-test-sandbox + (with-temp-dir temp-dir + ;; Create a project in temp dir + (let* ((project-dir temp-dir) + (nbb-edn (expand-file-name "nbb.edn" project-dir))) + (write-region "{}" nil nbb-edn) + + (with-temp-buffer + ;; set default directory to temp project + (setq-local default-directory project-dir) + + (let* (;; Get a gv reference so as to poll if the client has + ;; connected to the nREPL server. + (client-is-connected* (cider-itu-nrepl-client-connected-ref-make!)) + + ;; jack in and get repl buffer + (nrepl-proc (cider-jack-in-clj '(:cljs-repl-type nbb))) + (nrepl-buf (process-buffer nrepl-proc))) + + ;; wait until the client has successfully connected to the + ;; nREPL server. + (cider-itu-poll-until (eq (gv-deref client-is-connected*) 'connected) 5) + + ;; give it some time to setup the clj REPL + (cider-itu-poll-until (cider-repls 'clj nil) 5) + + ;; send command to the REPL, and push stdout/stderr to + ;; corresponding eval-xxx variables. + (let ((repl-buffer (cider-current-repl)) + (eval-err '()) + (eval-out '())) + (expect repl-buffer :not :to-be nil) + + ;; send command to the REPL + (cider-interactive-eval + ;; ask REPL to return a string that uniquely identifies it. + "(print :nbb? (some? (nbb.core/version)))" + (lambda (return) + (nrepl-dbind-response + return + (out err) + (when err (push err eval-err)) + (when out (push out eval-out)))) ) + + ;; wait for a response to come back. + (cider-itu-poll-until (or eval-err eval-out) 5) + + ;; ensure there are no errors and response is as expected. + (expect eval-err :to-equal '()) + (expect eval-out :to-equal '(":nbb? true")) + + ;; exit the REPL. + (cider-quit repl-buffer) + + ;; wait for the REPL to exit + (cider-itu-poll-until (not (eq (process-status nrepl-proc) 'run)) 5) + (expect (member (process-status nrepl-proc) '(exit signal)))))))))) + (it "to shadow" ;; shadow asks user whether they want to open a browser, force to no (spy-on 'y-or-n-p)