-
-
Save ghoseb/286633 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn tests [] | |
[{:name 'suiteA | |
:total 3 | |
:tests [{:name 'testA} | |
{:name 'testB} | |
{:name 'testC}]} | |
{:name 'suiteB | |
:total 3 | |
:tests [{:name 'testD} | |
{:name 'testE} | |
{:name 'testF}]}]) | |
(def dummy-results | |
{'testA 0 | |
'testB 1 | |
'testC 0 | |
'testD 1 | |
'testE 1 | |
'testF 0}) | |
(defn run-test [test] | |
(dummy-results (:name test))) | |
(defn prepare-tests [tests] | |
(loop [test (first tests), tests (rest tests), torun []] | |
(if (nil? test) | |
torun | |
(if (:tests test) | |
(let [subtests (prepare-tests (:tests test))] | |
(recur (first tests) | |
(rest tests) | |
(conj torun | |
(delay | |
(let [passed (reduce + (map force subtests))] | |
(println (:name test) | |
"passed" passed | |
"failed" (- (:total test) passed) | |
"total" (:total test))))))) | |
(recur (first tests) | |
(rest tests) | |
(if (nil? (:tests test)) | |
(conj torun (delay | |
(let [passed (run-test test)] | |
(println (:name test) "passed" passed) | |
passed))) | |
torun)))))) | |
(defn run [tests] | |
(doseq [test (prepare-tests tests)] | |
(force test))) | |
(comment | |
(run (tests))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment