Skip to content

Commit

Permalink
tests: don't throw in test result summary (#588)
Browse files Browse the repository at this point in the history
Closes #586
  • Loading branch information
lread committed May 18, 2024
1 parent c31a497 commit 2b9ba2b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
4 changes: 2 additions & 2 deletions bb.edn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{:min-bb-version "0.8.2"
:paths ["script"]
:paths ["script" "build"]
:deps {doric/doric {:mvn/version "0.9.0"}
lread/status-line {:git/url "https://github.com/lread/status-line.git"
:sha "cf44c15f30ea3867227fa61ceb823e5e942c707f"}
Expand Down Expand Up @@ -55,7 +55,7 @@
:task (do
;; timbre default logging level is debug, which generates a lot of http logging noise
(timbre/set-level! :info)
(exec 'cognitect.test-runner.api/test))
(exec 'build-shared/test))
:org.babashka/cli {:coerce {:nses [:symbol]
:patterns [:string]
:vars [:symbol]}}}
Expand Down
26 changes: 26 additions & 0 deletions build/build_shared.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(ns build-shared
(:refer-clojure :exclude [test])
(:require
[cognitect.test-runner :as tr]))

;; private fn pasted from original sources
(defn- do-test
[{:keys [dirs nses patterns vars includes excludes]}]
(let [adapted {:dir (when (seq dirs) (set dirs))
:namespace (when (seq nses) (set nses))
:namespace-regex (when (seq patterns) (map re-pattern patterns))
:var (when (seq vars) (set vars))
:include (when (seq includes) (set includes))
:exclude (when (seq excludes) (set excludes))}]
(tr/test adapted)))


(defn test
"Reimplement test to not throw but instead exit with 1 on error."
[opts]
(try
(let [{:keys [fail error]} (do-test opts)]
(System/exit (if (zero? (+ fail error)) 0 1)))
(finally
;; Only called if `test` raises an exception
(shutdown-agents))))
4 changes: 2 additions & 2 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
{:1.11 {:replace-deps {org.clojure/clojure {:mvn/version "1.11.2"}}}
:1.12 {:replace-deps {org.clojure/clojure {:mvn/version "1.12.0-alpha9"}}}
:debug {:extra-paths ["env/dev/resources"]}
:test {:extra-paths ["test" "env/test/resources"]
:test {:extra-paths ["test" "env/test/resources" "build"]
:extra-deps {io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"}
org.babashka/cli {:mvn/version "0.8.58"}
ch.qos.logback/logback-classic {:mvn/version "1.3.14"}
;; for http-client which uses apache http client 4.x which uses commons logging
org.slf4j/jcl-over-slf4j {:mvn/version "2.0.12"}}
:exec-fn cognitect.test-runner.api/test
:exec-fn build-shared/test
:org.babashka/cli {:coerce {:nses [:symbol]
:patterns [:string]
:vars [:symbol]}}
Expand Down
1 change: 0 additions & 1 deletion doc/02-developer-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ Babashka supports everything that Etaoin needs, but when making changes, be awar
3. Replace use of `ImageIO` in tests with a callout to ImageMagick instead.
4. Replace some JDK file related class references with `babashka/fs` abstractions
5. Use `http-client-lite` in place of `http-client` when running under Babashka
6. Run existing tests with cognitect test runner by including `babashka/tools.namespace`

Nothing earth shattering there, but gives you and idea.

Expand Down

0 comments on commit 2b9ba2b

Please sign in to comment.