Fork me on GitHub
#core-async
<
2023-05-02
>
pat15:05:59

i am trying to keep unit tests uniform in a cljc file with

(defmacro test-async [go-block]
  (if (boolean (:ns &env))
    `(cljs.test/async ~'done
      (cljs.core.async/take! ~go-block
                             (fn [_]
                               (~'done))))
    `(clojure.core.async/<!! ~go-block)))

(deftest foo (test-async (go (is false))))
this raises an IO stream is closed exception from clojure.test/do-report. Is there any idiom for accomplishing this? Is it failing because it does not want to block on top-level?

hiredman15:05:34

Are you running that code literally and only that code, or is that a simplified example of your tests

hiredman15:05:49

Because likely you have launched a go block or thread that is continuing to run after the test has completed, and called is and failed, which tried to report it, but the test finished running so the report output is closed

pat16:05:17

you are right i must have orphaned a var. thanks