Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/cognitect/test_runner.clj
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,32 @@
(alter-meta! var #(-> %
(assoc :test (::test %))
(dissoc ::test)))))))

(defn- require-and-resolve
[sym]
(require (symbol (namespace sym)))
(resolve sym))

(defn test
[options]
(let [dirs (or (:dir options)
#{"test"})
nses (->> dirs
(map io/file)
(mapcat find/find-namespaces-in-dir))
nses (filter (ns-filter options) nses)]
nses (filter (ns-filter options) nses)
with-output (require-and-resolve
(:with-output options 'clojure.test/with-test-out))]
(when (not with-output)
(throw (ex-info "Specified with-output not found" {})))
(println (format "\nRunning tests in %s" dirs))
(dorun (map require nses))
(try
(filter-vars! nses (var-filter options))
(apply test/run-tests nses)
(binding [test/*test-out* (if (:output options)
(java.io.FileWriter. (:output options))
test/*test-out*)]
(eval `(~with-output (apply test/run-tests (quote ~nses)))))
(finally
(restore-vars! nses)))))

Expand Down Expand Up @@ -91,6 +104,9 @@
["-e" "--exclude KEYWORD" "Exclude tests with this metadata keyword."
:parse-fn parse-kw
:assoc-fn accumulate]
["-w" "--with-output SYMBOL" "Symbol indicating the with output wrapper."
:parse-fn symbol]
["-o" "--output STRING" "String indicating path to file to write output to."]
["-H" "--test-help" "Display this help message"]])

(defn- help
Expand Down