Skip to content

Commit 9bf486b

Browse files
author
dnolen
committed
cljs.test needs to default to sync, remove broken validation
1 parent a594ded commit 9bf486b

File tree

1 file changed

+25
-38
lines changed

1 file changed

+25
-38
lines changed

src/cljs/cljs/test.cljs

+25-38
Original file line numberDiff line numberDiff line change
@@ -443,16 +443,14 @@
443443
(update-current-env! [:testing-vars] conj v)
444444
(update-current-env! [:report-counters :test] inc)
445445
(do-report {:type :begin-test-var :var v})
446-
(let [{:keys [async-disabled]} (get-current-env)]
447-
(cond-> (try
448-
(t)
449-
(catch :default e
450-
(do-report
451-
{:type :error
452-
:message "Uncaught exception, not in assertion."
453-
:expected nil
454-
:actual e})))
455-
async-disabled (-> async? not (assert async-disabled)))))
446+
(try
447+
(t)
448+
(catch :default e
449+
(do-report
450+
{:type :error
451+
:message "Uncaught exception, not in assertion."
452+
:expected nil
453+
:actual e}))))
456454
(fn []
457455
(do-report {:type :end-test-var :var v})
458456
(update-current-env! [:testing-vars] rest))]))
@@ -493,28 +491,22 @@
493491
block
494492
(reverse (keep :after map-fixtures))))
495493

496-
(defn- fixtures-type
497-
[coll]
498-
(cond (empty? coll)
499-
:none
500-
(every? map? coll)
501-
:map
502-
(every? fn? coll)
503-
:fn))
504-
505-
(defn- execution-strategy
506-
[once-fixtures each-fixtures]
507-
(let [types (map fixtures-type [once-fixtures each-fixtures])
508-
_ (assert (not-any? nil? types)
509-
"Fixtures may not be of mixed types")
510-
types (->> types
511-
(remove #{:none})
512-
(distinct))
513-
_ (assert (> 2 (count types)) "fixtures specified in :once and :each must be of the same type")]
514-
(case (first types)
515-
:map :async
516-
:fn :sync
517-
nil :async)))
494+
(defn- execution-strategy [once each]
495+
(letfn [(fixtures-type [coll]
496+
(cond
497+
(empty? coll) :none
498+
(every? map? coll) :map
499+
(every? fn? coll) :fn))
500+
(fixtures-types []
501+
(->> (map fixtures-type [once each])
502+
(remove #{:none})
503+
(distinct)))]
504+
(let [[type :as types] (fixtures-types)]
505+
(assert (not-any? nil? types)
506+
"Fixtures may not be of mixed types")
507+
(assert (> 2 (count types))
508+
"fixtures specified in :once and :each must be of the same type")
509+
({:map :async :fn :sync} type :sync))))
518510

519511
(defn test-vars-block
520512
"Like test-vars, but returns a block for further composition and
@@ -536,9 +528,6 @@
536528
(wrap-map-fixtures once-fixtures))
537529
:sync
538530
(do
539-
(update-current-env! [:async-disabled]
540-
(constantly
541-
"Async tests require fixtures to be specified as maps"))
542531
(let [each-fixture-fn (join-fixtures each-fixtures)]
543532
[(fn []
544533
((join-fixtures once-fixtures)
@@ -547,9 +536,7 @@
547536
(when (:test (meta v))
548537
(each-fixture-fn
549538
(fn []
550-
(test-var v)))))))
551-
(update-current-env! [:async-disabled]
552-
(constantly nil)))])))))))
539+
(test-var v))))))))])))))))
553540
(group-by (comp :ns meta) vars)))
554541

555542
(defn test-vars

0 commit comments

Comments
 (0)