core-async

pat 2023-05-02T15:31:59.307329Z

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?

2023-05-02T15:54:34.814629Z

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

2023-05-02T15:55:49.305509Z

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

pat 2023-05-02T16:54:17.120609Z

you are right i must have orphaned a var. thanks