Skip to content

Commit 575218c

Browse files
committed
Fixed version of cognitect-labs#13
1 parent 7284cda commit 575218c

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/cognitect/test_runner.clj

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
[clojure.tools.cli :as cli])
66
(:refer-clojure :exclude [test]))
77

8+
(defn- require-and-resolve
9+
[sym]
10+
(require (symbol (namespace sym)))
11+
(resolve sym))
12+
813
(defn- ns-filter
914
[{:keys [namespace namespace-regex]}]
1015
(let [[include-ns include-regexes]
@@ -66,12 +71,20 @@
6671
nses (->> dirs
6772
(map io/file)
6873
(mapcat find/find-namespaces-in-dir))
69-
nses (filter (ns-filter options) nses)]
74+
nses (filter (ns-filter options) nses)
75+
with-output (require-and-resolve
76+
(:with-output options 'clojure.test/with-test-out))]
77+
(when (not with-output)
78+
(throw (ex-info "Specified with-output not found" {})))
7079
(println (format "\nRunning tests in %s" dirs))
7180
(dorun (map require nses))
7281
(try
7382
(filter-vars! nses (var-filter options))
74-
(apply test/run-tests (filter contains-tests? nses))
83+
(binding [test/*test-out* (if (:output options)
84+
(java.io.FileWriter. (:output options))
85+
test/*test-out*)]
86+
(let [test-nses (seq (filter contains-tests? nses))]
87+
(eval `(~with-output (apply test/run-tests (quote ~test-nses))))))
7588
(finally
7689
(restore-vars! nses)))))
7790

@@ -102,6 +115,9 @@
102115
["-e" "--exclude KEYWORD" "Exclude tests with this metadata keyword."
103116
:parse-fn parse-kw
104117
:assoc-fn accumulate]
118+
["-w" "--with-output SYMBOL" "Symbol indicating the with output wrapper."
119+
:parse-fn symbol]
120+
["-o" "--output STRING" "String indicating path to file to write output to."]
105121
["-H" "--test-help" "Display this help message"]])
106122

107123
(defn- help

0 commit comments

Comments
 (0)