Last active
December 21, 2015 18:19
-
-
Save gtrak/6346408 to your computer and use it in GitHub Desktop.
Clojure.test hacks.
This file contains 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
(defmacro rcf | |
"Reports from the calling stack frame, useful for utility | |
assertion functions to workaround clojure.test's reporting of file-and-line info." | |
[& expr] | |
`(let [reports# (atom []) | |
out# (with-redefs [clojure.test/do-report (fn [m#] (swap! reports# conj m#))] | |
~@expr) | |
final# @reports#] | |
(doseq [m# final#] | |
(clojure.test/do-report m#)))) | |
(defn- test-inner | |
[] | |
(is (= true false))) | |
(clojure.test/deftest test-rcf | |
[] | |
;; rcf will report file-and-line from here instead of test-inner | |
(rcf (test-inner))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment