cljs.test/run-tests-block
(run-tests-block env-or-ns & namespaces)
Source docstring:
Like test-vars, but returns a block for further composition and
later execution.
(defmacro run-tests-block
[env-or-ns & namespaces]
(assert (every?
(fn [[quote ns]] (and (= quote 'quote) (symbol? ns)))
namespaces)
"All arguments to run-tests must be quoted symbols")
(let [is-ns (ns? env-or-ns)
env (gensym "env")
summary (gensym "summary")]
`(let [~env ~(if is-ns
`(empty-env)
env-or-ns)
~summary (cljs.core/volatile!
{:test 0 :pass 0 :fail 0 :error 0
:type :summary})]
(concat ~@(map
(fn [ns]
`(concat (test-ns-block ~env ~ns)
[(fn []
(cljs.core/vswap!
~summary
(partial merge-with +)
(:report-counters
(get-and-clear-env!))))]))
(if is-ns
(concat [env-or-ns] namespaces)
namespaces))
[(fn []
(set-env! ~env)
(do-report (deref ~summary))
(report (assoc (deref ~summary) :type :end-run-tests))
(clear-env!))]))))