Skip to content

Commit

Permalink
Make :reporter "internal"
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahTheDuke committed Nov 19, 2024
1 parent b7f04c8 commit ace704a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/clojure/lazytest/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
(if (:lazytest.runner/depth config)
config
(let [reporter (resolve-reporter
(or (:reporter config) 'lazytest.reporters/nested))]
(or (:output config) 'lazytest.reporters/nested))]
(-> config
(assoc :lazytest.runner/depth 1)
(assoc :lazytest.runner/suite-history [])
Expand Down
3 changes: 1 addition & 2 deletions src/clojure/lazytest/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
nses))

(defn run-impl [{:keys [dir output] :as config}]
(let [output (or (not-empty output) ['lazytest.reporters/nested])
config (->config (assoc config :output output :reporter output))
(let [config (->config (assoc config :output (not-empty output)))
nses (require-dirs config dir)]
(run-tests nses config)))

Expand Down
6 changes: 5 additions & 1 deletion src/clojure/lazytest/repl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
[lazytest.runner :as runner]))

(def repl-config
{:reporter [r/focused r/results r/summary]})
{:output [r/focused r/results r/summary]})

(defn run-tests
"Runs tests defined in the given namespaces."
{:arglists '([namespaces] [namespaces {:keys [output] :as config}])}
([namespaces] (run-tests namespaces repl-config))
([namespaces config]
(if (sequential? namespaces)
Expand All @@ -18,11 +19,14 @@

(defn run-all-tests
"Run tests defined in all namespaces."
{:arglists '([] [{:keys [output] :as config}])}
([] (run-all-tests repl-config))
([config]
(summarize (runner/run-all-tests (->config config)))))

(defn run-test-var
"Run test var."
{:arglists '([var] [var {:keys [output] :as config}])}
([v] (run-test-var v repl-config))
([v config]
(summarize (runner/run-test-var v (->config config)))))
4 changes: 2 additions & 2 deletions src/clojure/lazytest/runner.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
run-afters run-before-eachs run-befores]]
[lazytest.filter :refer [filter-tree]]
[lazytest.find :refer [find-suite find-var-test-value]]
[lazytest.reporters :as r :refer [nested report]]
[lazytest.reporters :as r :refer [report]]
[lazytest.suite :as s :refer [suite suite-result suite?]]
[lazytest.test-case :refer [try-test-case]]))

Expand Down Expand Up @@ -109,7 +109,7 @@

(defn run-tests
"Runs tests defined in the given namespaces. Applies filters in config."
([namespaces] (run-tests namespaces (->config {:reporter nested})))
([namespaces] (run-tests namespaces (->config nil)))
([namespaces config]
(-> (apply find-suite namespaces)
(filter-and-run config))))
Expand Down
2 changes: 1 addition & 1 deletion test/clojure/lazytest/libs_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
(match? {:total 80 :pass 80 :fail 0}
(summarize
(lr/run-tests [(the-ns honeysql-ns)]
(->config {:reporter ['lazytest.reporters/quiet]})))))))))
(->config {:output ['lazytest.reporters/quiet]})))))))))
12 changes: 6 additions & 6 deletions test/clojure/lazytest/reporters_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
(defn ->passing [& {:as extra}]
(-> (tc/test-case {:doc "example test-case"
:body (fn [] true)})
(runner/run-tree (->config {:reporter [(constantly nil)]}))
(runner/run-tree (->config {:output [(constantly nil)]}))
(merge extra)))

(defn ->failing [& {:as extra}]
(-> (tc/test-case {:doc "example test-case"
:body (fn [] (expect (= 1 2) (if (contains? extra :message)
(:message extra)
"failing")))})
(runner/run-tree (->config {:reporter [(constantly nil)]}))
(runner/run-tree (->config {:output [(constantly nil)]}))
(assoc :file "example.clj")
(assoc :line 1)
(merge (dissoc extra :message))))
Expand All @@ -55,7 +55,7 @@
:line 1})]
(-> (tc/test-case {:doc "example test-case"
:body (fn [] (throw thrown))})
(runner/run-tree (->config {:reporter [(constantly nil)]})))))
(runner/run-tree (->config {:output [(constantly nil)]})))))

(defn stub-stack-trace
[_ex]
Expand Down Expand Up @@ -348,7 +348,7 @@
(suite {:type :lazytest/ns
:nses [*ns*]
:children [test-suite]})
(->config {:reporter (constantly nil)}))
(->config {:output (constantly nil)}))
suite-results (assoc test-suite :type :end-test-run :results results)]
(expect (match? (re-compile "Top 1 slowest test namespaces.*Top 1 slowest test vars" :dotall)
(-> (sut/profile nil suite-results)
Expand All @@ -361,10 +361,10 @@
(it "uses the var if given no doc string"
(expect (= " defdescribe-no-doc\n √ works\n\n"
(-> (runner/run-test-var #'defdescribe-no-doc
(->config {:reporter sut/nested*}))
(->config {:output sut/nested*}))
(with-out-str-no-color)))))
(it "uses the doc string when available"
(expect (= " cool docs\n √ works\n\n"
(-> (runner/run-test-var #'defdescribe-with-doc
(->config {:reporter sut/nested*}))
(->config {:output sut/nested*}))
(with-out-str-no-color))))))
4 changes: 2 additions & 2 deletions test/clojure/lazytest/runner_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
""
""])
(-> (sut/run-test-suite test-suite
(->config {:reporter reporters/nested*}))
(->config {:output reporters/nested*}))
(with-out-str-no-color)))))))

(defdescribe run-test-var-test
Expand All @@ -32,5 +32,5 @@
""
""])
(-> (sut/run-test-var #'run-test-suite-test
(->config {:reporter reporters/nested*}))
(->config {:output reporters/nested*}))
(with-out-str-no-color))))))

0 comments on commit ace704a

Please sign in to comment.