|
232 | 232 | (defn run-testables |
233 | 233 | "Run a collection of testables, returning a result collection." |
234 | 234 | [testables test-plan] |
235 | | - (let [load-error? (some ::load-error testables) |
| 235 | + (let [load-error? (some ::load-error testables)] |
| 236 | + (loop [result [] |
| 237 | + [test & testables] testables] |
| 238 | + (if test |
| 239 | + (let [test (cond-> test |
| 240 | + (and load-error? (not (::load-error test))) |
| 241 | + (assoc ::skip true)) |
| 242 | + r (run-testable test test-plan)] |
| 243 | + (if (or (and *fail-fast?* (result/failed? r)) (::skip-remaining? r)) |
| 244 | + (reduce into result [[r] testables]) |
| 245 | + (recur (conj result r) testables))) |
| 246 | + result)))) |
| 247 | + |
| 248 | + |
| 249 | +(defn run-testables-parallel |
| 250 | + "Run a collection of testables, returning a result collection." |
| 251 | + [testables test-plan] |
| 252 | +(let [load-error? (some ::load-error testables) |
236 | 253 | ;; results (watch/make-queue) |
237 | 254 | put-return (fn [acc value] |
238 | 255 | (if (instance? BlockingQueue value) |
239 | 256 | (.drainTo value acc) |
240 | 257 | (.put acc value)) |
241 | | - acc)] |
242 | | - (loop [result (ArrayBlockingQueue. 1024) |
| 258 | + acc) |
| 259 | + futures (map #(future (run-testable % test-plan)) testables)] |
| 260 | + (println "Running in parallel!") |
| 261 | + (comment (loop [result [] ;(ArrayBlockingQueue. 1024) |
243 | 262 | [test & testables] testables] |
244 | 263 | (if test |
245 | 264 | (let [test (cond-> test |
246 | 265 | (and load-error? (not (::load-error test))) |
247 | 266 | (assoc ::skip true)) |
248 | 267 | r (run-testable test test-plan)] |
249 | 268 | (if (or (and *fail-fast?* (result/failed? r)) (::skip-remaining? r)) |
250 | | - (reduce put-return result [[r] testables]) |
251 | | - (recur (doto result (.put r)) testables))) |
252 | | - result)))) |
| 269 | + ;(reduce put-return result [[r] testables]) |
| 270 | + (reduce into result [[r] testables]) |
| 271 | + ;(recur (doto result (.put r)) testables) |
| 272 | + (recur (conj result r) testables))) |
| 273 | + result))) |
| 274 | + (map deref futures) |
| 275 | + )) |
253 | 276 |
|
254 | 277 | (defn test-seq [testable] |
255 | 278 | (cond->> (mapcat test-seq (remove ::skip (or (:kaocha/tests testable) |
|
0 commit comments