Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
Allow filtering of the test set
Browse files Browse the repository at this point in the history
With the full test set taking 90 seconds and producing a lot of
output, this improves the ergonomy when one wants to run only a
limited set of tests.
  • Loading branch information
muep committed Oct 13, 2022
1 parent b5a0d82 commit ce4e011
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions etp-backend/src/main/clj/user.clj
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,23 @@
(defn run-test [var-name]
(t/test-vars [var-name]))

(defn run-tests []
(defn matching-test [test-searches]
(if (empty? test-searches) (fn [_] true)
(fn [test]
(some #(re-find % (str test)) test-searches))))

(defn run-tests [test-searches]
(let [cpu-count (.availableProcessors (Runtime/getRuntime))
thread-count (if-let [thread-limit (System/getenv "ETP_THREAD_LIMIT")]
(min (Integer/parseInt thread-limit) cpu-count)
cpu-count)]
(require 'eftest.runner)
(-> ((resolve 'eftest.runner/find-tests) "src/test")
((resolve 'eftest.runner/run-tests) {:thread-count thread-count}))))
(->> ((resolve 'eftest.runner/find-tests) "src/test")
(filter (matching-test test-searches))
((resolve 'eftest.runner/run-tests)))))

(defn run-tests-and-exit! []
(let [{:keys [fail error]} (run-tests)]
(let [{:keys [fail error]} (run-tests (map re-pattern *command-line-args*))]
(System/exit (if (and (zero? fail) (zero? error)) 0 1))))

(defn- process-key [key] (if (schema/optional-key? key) (:k key) key))
Expand Down

0 comments on commit ce4e011

Please sign in to comment.