diff --git a/src/kaocha/testable.clj b/src/kaocha/testable.clj index 3c5fe0cb..5f111184 100644 --- a/src/kaocha/testable.clj +++ b/src/kaocha/testable.clj @@ -1,7 +1,6 @@ (ns kaocha.testable (:refer-clojure :exclude [load]) (:require [clojure.java.io :as io] - [clojure.pprint :as pprint] [clojure.spec.alpha :as s] [clojure.test :as t] [com.climate.claypoole :as cp] @@ -12,10 +11,7 @@ [kaocha.plugin :as plugin] [kaocha.result :as result] [kaocha.specs :refer [assert-spec]] - [kaocha.util :as util] - [kaocha.hierarchy :as hierarchy]) - (:import [clojure.lang Compiler$CompilerException] - [java.util.concurrent ArrayBlockingQueue BlockingQueue])) + [kaocha.util :as util])) (def ^:dynamic *fail-fast?* "Should testing terminate immediately upon failure or error?" @@ -258,23 +254,28 @@ (defn run-testables-parallel "Run a collection of testables, returning a result collection." [testables test-plan] - (let [num-threads (or (:parallel-threads *config*) (+ 2 (cp/ncpus))) - types (set (:parallel-children-exclude *config*))] - (cp/with-shutdown! [pool (cp/threadpool num-threads :name "kaocha-test-runner")] - (doall - (cp/pmap - pool - #(binding [*config* - (cond-> *config* - (contains? types (:kaocha.testable/type %)) (dissoc :parallel) - true (update :levels (fn [x] (if (nil? x) 1 (inc x)))))] - (run-testable % test-plan)) - testables))))) + (let [num-threads (or (:parallel-threads *config*) (* 2 (inc (cp/ncpus)))) + pred #(= :kaocha.type/ns (:kaocha.testable/type %)) + nses (seq (filter pred testables)) + others (seq (remove pred testables))] + (concat + (when others (run-testables-serial others test-plan)) + (when nses + (cp/with-shutdown! [pool (cp/threadpool num-threads :name "kaocha-test-runner")] + (doall + (cp/pmap + pool + #(binding [*config* + (-> *config* + (dissoc :parallel) + (update :levels (fn [x] (if (nil? x) 1 (inc x)))))] + (run-testable % test-plan)) + nses))))))) (defn run-testables [testables test-plan] (if (:parallel *config*) - (doall (run-testables-parallel testables test-plan)) + (run-testables-parallel testables test-plan) (run-testables-serial testables test-plan))) (defn test-seq [testable]