|
443 | 443 | (update-current-env! [:testing-vars] conj v)
|
444 | 444 | (update-current-env! [:report-counters :test] inc)
|
445 | 445 | (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})))) |
456 | 454 | (fn []
|
457 | 455 | (do-report {:type :end-test-var :var v})
|
458 | 456 | (update-current-env! [:testing-vars] rest))]))
|
|
493 | 491 | block
|
494 | 492 | (reverse (keep :after map-fixtures))))
|
495 | 493 |
|
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)))) |
518 | 510 |
|
519 | 511 | (defn test-vars-block
|
520 | 512 | "Like test-vars, but returns a block for further composition and
|
|
536 | 528 | (wrap-map-fixtures once-fixtures))
|
537 | 529 | :sync
|
538 | 530 | (do
|
539 |
| - (update-current-env! [:async-disabled] |
540 |
| - (constantly |
541 |
| - "Async tests require fixtures to be specified as maps")) |
542 | 531 | (let [each-fixture-fn (join-fixtures each-fixtures)]
|
543 | 532 | [(fn []
|
544 | 533 | ((join-fixtures once-fixtures)
|
|
547 | 536 | (when (:test (meta v))
|
548 | 537 | (each-fixture-fn
|
549 | 538 | (fn []
|
550 |
| - (test-var v))))))) |
551 |
| - (update-current-env! [:async-disabled] |
552 |
| - (constantly nil)))]))))))) |
| 539 | + (test-var v))))))))]))))))) |
553 | 540 | (group-by (comp :ns meta) vars)))
|
554 | 541 |
|
555 | 542 | (defn test-vars
|
|
0 commit comments