|
47 | 47 | (try-require (symbol (namespace type))))
|
48 | 48 | (try-require (symbol (name type)))))
|
49 | 49 |
|
| 50 | + |
| 51 | +(defn- try-assert-spec [type testable n] |
| 52 | + (let [ result (try (assert-spec type testable) (catch Exception _e false))] |
| 53 | + (if (or result (<= n 1)) result |
| 54 | + (try-assert-spec type testable (dec n))) ;otherwise, retry |
| 55 | + )) |
| 56 | + |
50 | 57 | (defn- load-type+validate
|
51 | 58 | "Try to load a testable type, and validate it both to be a valid generic testable, and a valid instance given the type.
|
52 | 59 |
|
|
60 | 67 | (let [type (::type testable)]
|
61 | 68 | (try-load-third-party-lib type)
|
62 | 69 | (try
|
63 |
| - (assert-spec type testable) |
| 70 | + (try-assert-spec type testable 3) |
64 | 71 | (catch Exception e
|
65 |
| - (prn e) |
66 |
| - ) |
67 |
| - ))) |
| 72 | + (output/warn (format "Could not load %s. This is a known bug in parallelization.\n%s" type e)))))) |
68 | 73 |
|
69 | 74 | (defmulti -load
|
70 | 75 | "Given a testable, load the specified tests, producing a test-plan."
|
|
130 | 135 | Also performs validation, and lazy loading of the testable type's
|
131 | 136 | implementation."
|
132 | 137 | [testable test-plan]
|
133 |
| - ;; (println (class testable)) |
| 138 | + (load-type+validate testable) |
134 | 139 | (binding [*current-testable* testable]
|
135 |
| - ;; (println (:kaocha.testable/id *current-testable*)) |
136 |
| - (load-type+validate testable) |
137 | 140 | (let [run (plugin/run-hook :kaocha.hooks/wrap-run -run test-plan)
|
138 | 141 | result (run testable test-plan)]
|
139 | 142 | (if-let [history history/*history*]
|
|
220 | 223 | (run % test-plan)
|
221 | 224 | (plugin/run-hook :kaocha.hooks/post-test % test-plan)))))
|
222 | 225 |
|
| 226 | + |
| 227 | +(defn try-run-testable [test test-plan n] |
| 228 | + (let [ result (try (run-testable test test-plan) (catch Exception _e false))] |
| 229 | + (if (or result (> n 1)) result ;success or last try, return |
| 230 | + (try-run-testable test test-plan (dec n))) ;otherwise retry |
| 231 | + )) |
| 232 | + |
223 | 233 | (defn f [acc value]
|
224 | 234 | (if (instance? BlockingQueue value)
|
225 | 235 | (.drainTo value acc)
|
|
274 | 284 | (println (:parallel *config*) \space (.getName (Thread/currentThread)))
|
275 | 285 | (future
|
276 | 286 | ;(do #_(println "Firing off future!" (Thread/currentThread)) )
|
277 |
| - (binding [*config* (dissoc *config* :parallel)] (run-testable % test-plan)))) |
| 287 | + (binding [*config* (dissoc *config* :parallel)] (try-run-testable % test-plan 3)))) |
278 | 288 | testables))]
|
279 | 289 | (comment (loop [result [] ;(ArrayBlockingQueue. 1024)
|
280 | 290 | [test & testables] testables]
|
|
0 commit comments