Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions deps-clr.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{:paths ["src"]
:deps {io.github.clojure/clr.tools.namespace {:git/tag "v1.5.4" :git/sha "46d81cb"}
io.github.clojure/tools.cli {:git/tag "v1.1.230" :git/sha "717e187"}}
:aliases {:test {:extra-paths ["test"]
:extra-deps {io.github.clojure/clr.test.check {:git/tag "v1.1.2" :git/sha "26f34e6"}}
:main-opts ["-m" "cognitect.test-runner"]
:exec-fn cognitect.test-runner.api/test}}}
9 changes: 7 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@ suite of decomplected project management tools.

## Configuration

This fork of test-runner has a port of the JVM version to run in CLR;
this is in the clr-port branch.



Include a dependency on this project in your `deps.edn`. You will
probably wish to put it in the `test` alias:

```clojure
;; v0.5.1
;; v0.5.3
:aliases {:test {:extra-paths ["test"]
:extra-deps {io.github.cognitect-labs/test-runner
{:git/tag "v0.5.1" :git/sha "dfb30dd"}}
{:git/tag "v0.5.3clr" :git/sha "ae91dd2"}}
:main-opts ["-m" "cognitect.test-runner"]
:exec-fn cognitect.test-runner.api/test}}
```
Expand Down
15 changes: 9 additions & 6 deletions src/cognitect/test_runner.clj → src/cognitect/test_runner.cljc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns cognitect.test-runner
(:require [clojure.tools.namespace.find :as find]
[clojure.java.io :as io]
#?(:clj [clojure.java.io :as io]
:cljr [clojure.clr.io :as io])
[clojure.test :as test]
[clojure.tools.cli :as cli])
(:refer-clojure :exclude [test]))
Expand Down Expand Up @@ -63,9 +64,11 @@
[options]
(let [dirs (or (:dir options)
#{"test"})

nses (->> dirs
(map io/file)
(mapcat find/find-namespaces-in-dir))
#?(:clj (map io/file)
:cljr (map io/dir-info))
(mapcat #(find/find-namespaces-in-dir % #?(:cljr find/cljr :default nil))))
nses (filter (ns-filter options) nses)]
(println (format "\nRunning tests in %s" dirs))
(dorun (map require nses))
Expand All @@ -77,7 +80,7 @@

(defn- parse-kw
[^String s]
(if (.startsWith s ":") (read-string s) (keyword s)))
(if (#?(:clj .startsWith :cljr .StartsWith) s ":") (read-string s) (keyword s)))


(defn- accumulate [m k v]
Expand Down Expand Up @@ -120,12 +123,12 @@
(do (doseq [e (:errors args)]
(println e))
(help args)
(System/exit 1))
(#?(:clj System/exit :cljr Environment/Exit) 1))
(if (-> args :options :test-help)
(help args)
(try
(let [{:keys [fail error]} (test (:options args))]
(System/exit (if (zero? (+ fail error)) 0 1)))
(#?(:clj System/exit :cljr Environment/Exit) (if (zero? (+ fail error)) 0 1)))
(finally
;; Only called if `test` raises an exception
(shutdown-agents)))))))