Skip to content

Instantly share code, notes, and snippets.

@ghoseb
Forked from swannodette/delay.clj
Created January 26, 2010 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghoseb/286633 to your computer and use it in GitHub Desktop.
Save ghoseb/286633 to your computer and use it in GitHub Desktop.
(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