Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup test-runner.clj #726

Merged
merged 1 commit into from
Jan 11, 2025
Merged
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
16 changes: 4 additions & 12 deletions test-runner.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,13 @@
'[clojure.string :as str]
'[rewrite-clj.zip :as z])

;(cp/add-classpath "libs.jar")

#_(require '[clojure.spec.alpha :as s]
'[clojure.spec.gen.alpha :as gen])

;; Add solution source and tests to classpath
(def slug (first *command-line-args*))
(def in-dir (second *command-line-args*))
(def test-ns (symbol (str slug "-test")))
(cp/add-classpath (str in-dir "src:" in-dir "test"))
(require test-ns)

;; clojure.test runs the tests in random order,
;; but the spec requires that we report them in order.

;; Parse test file into zipper using rewrite-clj
(def zloc (z/of-file (str in-dir "/test/" (str/replace slug "-" "_") "_test.clj")))

Expand Down Expand Up @@ -69,9 +61,9 @@

;; Override clojure.test reporting methods to capture their results

(defmethod t/report :begin-test-ns [m])
(defmethod t/report :begin-test-ns [_m])

(defmethod t/report :pass [m]
(defmethod t/report :pass [_m]
(swap! passes conj {:name (:name (meta (first t/*testing-vars*)))
:status "pass"}))

Expand All @@ -80,10 +72,10 @@
:status "fail"
:message (str "Expected " (:expected m) " but got " (:actual m))}))

(defmethod t/report :error [m]
(defmethod t/report :error [_m]
(swap! errors conj (:name (meta (first t/*testing-vars*)))))

(defmethod t/report :summary [m])
(defmethod t/report :summary [_m])

(t/run-tests test-ns)

Expand Down