Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
nREPL testing
Loading src/nrepl_tests/src.clj... done
(let [server (start-server :port 7888)]
(try
(test-on 7888)
(finally
(stop-server server))))
; These are responses from the CLJ version
{:id "ba047b32-13fa-40ef-9c06-bb43484463b0",
:session "4c4d9109-2550-4fd4-9bcc-c97ac0ffdc8d",
:value "#'cursive.repl.runtime/print-last-error"}
{:id "ba047b32-13fa-40ef-9c06-bb43484463b0",
:session "4c4d9109-2550-4fd4-9bcc-c97ac0ffdc8d",
:status ["done"]}
{:id "a65e79ed-fb0e-4832-9624-bde27c682100",
:ns "user",
:session "3b395854-c208-4aaf-a6c9-6383b45aa74b",
:value "#object[clojure.lang.Namespace 0x457fdf42 \"user\"]"}
{:id "a65e79ed-fb0e-4832-9624-bde27c682100",
:session "3b395854-c208-4aaf-a6c9-6383b45aa74b",
:status ["done"]}
=> nil
Loading src/nrepl_tests/src.clj... done
(test-on 1667)
; These are responses from the bb version
{:id "8bf98357-98ac-4c57-93e7-05f576c39bce",
:ns "cursive.repl.runtime",
:session "none",
:value "nil"}
{:id "8bf98357-98ac-4c57-93e7-05f576c39bce",
:ns "cursive.repl.runtime",
:session "none",
:value "#'cursive.repl.runtime/mapped-metadata"}
{:id "8bf98357-98ac-4c57-93e7-05f576c39bce",
:ns "cursive.repl.runtime",
:session "none",
:value "#'cursive.repl.runtime/symbol-details"}
{:id "8bf98357-98ac-4c57-93e7-05f576c39bce",
:ns "cursive.repl.runtime",
:session "none",
:value "#'cursive.repl.runtime/ns-symbols-by-name"}
{:id "8bf98357-98ac-4c57-93e7-05f576c39bce",
:ns "cursive.repl.runtime",
:session "none",
:value "#'cursive.repl.runtime/symbols-for"}
{:id "8bf98357-98ac-4c57-93e7-05f576c39bce",
:ns "cursive.repl.runtime",
:session "none",
:value "#'cursive.repl.runtime/ns-info"}
{:id "8bf98357-98ac-4c57-93e7-05f576c39bce",
:ns "cursive.repl.runtime",
:session "none",
:value "#'cursive.repl.runtime/completions"}
{:id "8bf98357-98ac-4c57-93e7-05f576c39bce",
:ns "cursive.repl.runtime",
:session "none",
:value "#'cursive.repl.runtime/print-last-error"}
{:id "8bf98357-98ac-4c57-93e7-05f576c39bce",
:session "none",
:status ["done"]}
{:id "9ed8befe-d7aa-4ae6-b1a5-ef6bc0a1c5c7",
:ns "cursive.repl.runtime",
:session "none",
:value
"#object[sci.impl.vars.SciNamespace 0x258eb260 \"cursive.repl.runtime\"]"}
{:id "9ed8befe-d7aa-4ae6-b1a5-ef6bc0a1c5c7",
:session "none",
:status ["done"]}
=> nil
(ns nrepl-tests.src
(:require [nrepl.server :refer [start-server stop-server]]
[nrepl.core :as nrepl]
[clojure.pprint :as pp]))
(defn print-responses [client request]
(loop [response (nrepl/message client request)]
(let [msg (first response)]
(pp/pprint msg)
(when-not (some #(= "done" %) (:status msg))
(recur (rest response))))))
(defn test-on [port]
(with-open [conn (nrepl/connect :port port)]
(let [client (nrepl/client conn 1000)]
(print-responses client {:op "load-file"
:file (slurp "/Users/colin/dev/cursive/runtime/src/cursive/repl/runtime.clj")
:file-name "runtime.clj"
:file-path "cursive/repl/runtime.clj"})
(print-responses client {:op "eval"
:code "*ns*"}))))
(comment
; test with clj
(let [server (start-server :port 7888)]
(try
(test-on 7888)
(finally
(stop-server server))))
; test with bb
(test-on 1667))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment