 
 ; test runner results
 
-;; holds a persistent queue or a list or a vector (perf test this)
-;; of test results, for later analysis by the runner
-(def ^:dynamic *test-runner-state* nil)
+(def ^{:dynamic true
+       :doc
+       "holds an (atom []) of test results, for later analysis by the runner, iff the runner is reporting slow tests"}
+  *test-runner-state* nil)
+
+       (def ^{:dynamic true
+       :doc "because we print exceptions via clojure.test's report methods, we have to stuff these options in a dynamic var"}
+  *frame-options* {:frame-limit 10})
 
 (defn record-test-finished [m]
   (when *test-runner-state*

  :exit-with-error-code : an boolean (defaults to false)

  if set to a truthy value, calls (System/exit) after running, with exit code 0 if all the tests passed, or exit code 1 if any tests failed.
  "
  ([] (run-all-tests #".*"))
  ([ns-re] (run-all-tests ns-re {}))
  ([ns-re options]
   (let [writer (if (:force-real-stdout options) (java.io.PrintWriter. System/out) *out*)]
     (binding [*out* writer
               clojure.test/*test-out* writer
               *test-runner-state* (if (:show-slow-tests options)
                                     (atom {:last-test-finished (System/nanoTime) :results []}))]

         (maybe-show-slow-tests results options)
         (maybe-system-exit results options)
         results)))))

(defn pretty-reload
  ([] (pretty-reload [] {}))
  ([tools-ns-args frame-options]
   (require 'clojure.tools.namespace.repl)
   (require 'io.aviso.exception)
   (let [r (apply (resolve 'clojure.tools.namespace.repl/refresh) tools-ns-args)]
     (when (instance? Throwable r)
       ((resolve 'io.aviso.exception/write-exception) r))
     r))
  )
