Skip to content

Commit b59af7b

Browse files
marke000claude
andcommitted
Fix CLJS compatibility for test macros
- Make clojure.test/cljs.test require conditional - Fix with-instrument macro to emit correct namespace for instrumentable-syms - Fix do-spec-check-report macro to emit correct do-report symbol Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 7f67e77 commit b59af7b

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/provisdom/test/core.cljc

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
(:require
66
[clojure.pprint :as pprint]
77
[clojure.set :as set]
8-
[clojure.test :as t]
8+
#?(:clj [clojure.test :as t]
9+
:cljs [cljs.test :as t])
910
[clojure.string :as str]
1011
[clojure.spec.alpha :as s]
1112
[clojure.spec.test.alpha :as st]
1213
[clojure.spec.gen.alpha :as gen]
1314
#?(:clj [provisdom.test.spec-check :as p.st])
1415
#?(:cljs [orchestra-cljs.spec.test])
15-
#?(:cljs [cljs.test])
1616

1717
;; We require clojure.test for some CLJS code, in order for spec-check to run.
1818
#?(:cljs [clojure.test.check])
@@ -104,7 +104,10 @@
104104
"Enables instrumentation for `sym-or-syms` while executing `body`. Once `body` has completed,
105105
unstrument will be called."
106106
[sym-or-syms & body]
107-
(let [sym-or-syms (if (= :all sym-or-syms) `(st/instrumentable-syms) sym-or-syms)]
107+
(let [instrumentable-syms-sym (if (cljs-env? &env)
108+
'cljs.spec.test.alpha/instrumentable-syms
109+
'clojure.spec.test.alpha/instrumentable-syms)
110+
sym-or-syms (if (= :all sym-or-syms) `(~instrumentable-syms-sym) sym-or-syms)]
108111
`(with-instrument* ~[sym-or-syms] ~@body)))
109112

110113
#?(:clj (defn instrumentation
@@ -593,9 +596,12 @@
593596
;; must be done at compile time for correct line number resolution
594597
#?(:clj (defmacro do-spec-check-report
595598
[sym-or-syms opts]
596-
`(let [check-results# (spec-check- ~sym-or-syms ~opts)
597-
report-map# (spec-check-report check-results#)]
598-
(t/do-report report-map#))))
599+
(let [do-report-sym (if (cljs-env? &env)
600+
'cljs.test/do-report
601+
'clojure.test/do-report)]
602+
`(let [check-results# (spec-check- ~sym-or-syms ~opts)
603+
report-map# (spec-check-report check-results#)]
604+
(~do-report-sym report-map#)))))
599605

600606
#?(:clj (defmethod t/assert-expr 'spec-check
601607
[_msg form]

0 commit comments

Comments
 (0)