This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-30
Channels
- # announcements (8)
- # babashka (102)
- # beginners (312)
- # calva (9)
- # clj-kondo (9)
- # cljfx (7)
- # clojure (128)
- # clojure-europe (52)
- # clojure-nl (2)
- # clojure-norway (2)
- # clojure-spec (5)
- # clojure-uk (4)
- # clojurescript (13)
- # conjure (5)
- # cursive (5)
- # datalog (18)
- # datomic (8)
- # emacs (1)
- # events (3)
- # fulcro (16)
- # graphql (2)
- # gratitude (1)
- # helix (16)
- # inf-clojure (17)
- # introduce-yourself (9)
- # java (11)
- # lambdaisland (3)
- # leiningen (3)
- # lsp (8)
- # malli (3)
- # membrane (7)
- # missionary (26)
- # nextjournal (1)
- # off-topic (19)
- # pathom (3)
- # polylith (13)
- # portal (16)
- # reagent (39)
- # reitit (2)
- # releases (23)
- # remote-jobs (1)
- # shadow-cljs (40)
- # specter (3)
- # sql (12)
- # tools-deps (8)
- # tree-sitter (1)
- # vim (3)
- # web-security (6)
- # xtdb (16)
Hi folks. Is anyone rebinding #'clojure.test/*test-out*
for getting test output in the repl buffer?
I replicated the nrepl
workaround:
https://github.com/nrepl/nrepl/blob/a057874cd3bfc83e465cc163fbc1d4c00223e1b1/src/clojure/nrepl/middleware/interruptible_eval.clj#L93-L99
with this:
(inf-clojure-eval-string "(do (require '[clojure.main :as m])
(clojure.main/repl
:init #(do
;; The :init hook replicates what clojure.main uses as an initial binding set, so it's good to repeat that.
;; From
(apply require m/repl-requires)
;; Workaround for rebinding clojure.test/*test-out*.
;; For details, see \"
(require 'clojure.test)
(let [bindings (into (get-thread-bindings)
{#'clojure.test/*test-out* *out*})]
(pop-thread-bindings)
(push-thread-bindings bindings)))))")
however, I”m getting a stack overflow error when running a state-flow test [1]
Unfortunately the code is private and I don’t have a minimum reproducible example, but I’d like to know if something seems wrong with my attempt to do the same (the code is similar to nrepl
s, but it’s not equal).
[1]: https://github.com/nubank/state-flow/i always run the test as (binding [*test-out* *out*] (run-tests))
or an individual test
i use registers and have a send register to repl function. I’m not sure if that’s made it into inf or i just keep that as separate
but i always have that run-tests
form in register t
and then have individual tests in register i
interesting. I still get the stack overflow error. This only happens when I bind clojure.test/*test-out*
.
I suppose this is a bug in state-flow
. I’ll try to investigate it.
error:
https://gist.github.com/Andre0991/d771b0823e92b42b90038d9bd82da113
I was still using the nrepl approach in this gist but the error I got now is the same, anyway
It gets stuck in this:
clojure.core/fn (core_print.clj:317)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
clojure.core$pr_on.invokeStatic (core.clj:3675)
clojure.core$pr_on.invoke (core.clj:3669)
clojure.core$print_sequential.invokeStatic (core_print.clj:66)
clojure.core$fn__7411.invokeStatic (core_print.clj:225)
clojure.core/fn (core_print.clj:225)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
clojure.core$pr_on.invokeStatic (core.clj:3675)
clojure.core$pr_on.invoke (core.clj:3669)
clojure.core$print_prefix_map$fn__7414.invoke (core_print.clj:233)
clojure.core$print_sequential.invokeStatic (core_print.clj:66)
clojure.core$print_prefix_map.invokeStatic (core_print.clj:229)
clojure.core$print_map.invokeStatic (core_print.clj:238)
clojure.core$fn__7443.invokeStatic (core_print.clj:266)
clojure.core/fn (core_print.clj:263)
ah, and actually, binding the var as you did still redirected the output to the original repl, not inf-clojure’s
if you remove all tooling and just use a socket repl you can have the best way to come up with a minimal example
but at this point it’s not inf-clojure
’s fault it seems. You could ask in #clojure for more eyes
yeap, it’s useful I also set pprint as the default printer https://github.com/Andre0991/dotfiles/blob/master/elisp/apt-inf-clojure.el#L19
yeah i use this:
(clojure.main/repl
:prompt (fn [] (printf "%s=> " (peek (str/split (str *ns*) #"\."))))
:read server/repl-read
:print fipp/pprint)
annoyingly, with this form
(clojure.main/repl
:init (fn [] {#'clojure.test/*test-out* *out*})
:prompt (fn [] (printf "%s=> " (peek (str/split (str *ns*) #"\."))))
:read server/repl-read
:print fipp/pprint)
the behavior is not what i want
bookmark-test=> (with-bindings {#'*test-out* *out*} (run-tests)) ;; using manual bindings
Testing metabase.api.bookmark-test
FAIL in (foo) (NO_SOURCE_FILE:36)
expected: 1
actual: 2
diff: - 1
+ 2
Ran 3 tests containing 21 assertions.
1 failures, 0 errors.
{:test 3, :pass 20, :fail 1, :error 0, :type :summary}
bookmark-test=> (run-tests) ;; relying on bindings in #init
{:test 3, :pass 20, :fail 1, :error 0, :type :summary}
bookmark-test=>