Skip to content

Commit

Permalink
Add data structure foundation.
Browse files Browse the repository at this point in the history
  • Loading branch information
alysbrooks committed Jun 21, 2021
1 parent 58d7870 commit 461c4b6
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions src/kaocha/testable.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
[kaocha.classpath :as classpath]
[clojure.test :as t]
[kaocha.hierarchy :as hierarchy])
(:import [clojure.lang Compiler$CompilerException]))
(:import [clojure.lang Compiler$CompilerException]
[java.util.concurrent ArrayBlockingQueue BlockingQueue]))

(def ^:dynamic *fail-fast?*
"Should testing terminate immediately upon failure or error?"
Expand Down Expand Up @@ -212,20 +213,42 @@
(run % test-plan)
(plugin/run-hook :kaocha.hooks/post-test % test-plan)))))

(defn f [acc value]
(if (instance? BlockingQueue value)
(.drainTo value acc)
(.put acc value))
acc)

(defn f [acc value] (doto acc (.put value)))

(def q (ArrayBlockingQueue. 1024))
(def r (ArrayBlockingQueue. 1024))

(.put r 5)


(reduce f [q 1 2 r])

(defn run-testables
"Run a collection of testables, returning a result collection."
[testables test-plan]
(let [load-error? (some ::load-error testables)]
(loop [result []
(let [load-error? (some ::load-error testables)
;; results (watch/make-queue)
put-return (fn [acc value]
(if (instance? BlockingQueue value)
(.drainTo value acc)
(.put acc value))
acc)]
(loop [result (ArrayBlockingQueue. 1024)
[test & testables] testables]
(if test
(let [test (cond-> test
(and load-error? (not (::load-error test)))
(assoc ::skip true))
r (run-testable test test-plan)]
(if (or (and *fail-fast?* (result/failed? r)) (::skip-remaining? r))
(reduce into result [[r] testables])
(recur (conj result r) testables)))
(reduce put-return result [[r] testables])
(recur (doto result (.put r)) testables)))
result))))

(defn test-seq [testable]
Expand Down

0 comments on commit 461c4b6

Please sign in to comment.