diff --git a/build.clj b/build.clj index 20b4273..832c7c8 100644 --- a/build.clj +++ b/build.clj @@ -37,19 +37,39 @@ (b/jar {:class-dir class-dir :jar-file jar-file})) -(defn run-tests "Run regular tests." [_] - (let [basis (b/create-basis {:aliases [:test]}) - combined (t/combine-aliases basis [:test]) +(defn- run-task + [aliases] + (println "\nRunning task for:" aliases) + (let [basis (b/create-basis {:aliases aliases}) + combined (t/combine-aliases basis aliases) cmds (b/java-command {:basis basis :java-opts (:jvm-opts combined) :main 'clojure.main - :main-args ["-m" "cognitect.test-runner"]}) + :main-args (:main-opts combined)}) {:keys [exit]} (b/process cmds)] (when-not (zero? exit) - (throw (ex-info "Tests failed" {}))))) + (throw (ex-info (str "Task failed for: " aliases) {}))))) + + +(defn run-tests + "Run regular tests. + + Optionally specify :aliases: + [:1.10] -- test against Clojure 1.10.3 (the default) + [:master] -- test against Clojure 1.11 master snapshot" + [{:keys [aliases] :as opts}] + (run-task (into [:test] aliases)) + opts) (defn ci "Run the CI pipeline of tests (and build the JAR)." [opts] - (-> opts (run-tests) (clean) (jar))) + (-> opts + (as-> opts + (reduce (fn [opts alias] + (run-tests (assoc opts :aliases [alias :runner]))) + opts + [:1.10 :master])) + (clean) + (jar))) (defn deploy "Deploy the JAR to Clojars." [opts] (dd/deploy (merge {:installer :remote :artifact jar-file diff --git a/deps.edn b/deps.edn index 82ded8e..13218a1 100644 --- a/deps.edn +++ b/deps.edn @@ -9,8 +9,12 @@ io.github.slipset/deps-deploy {:sha "b4359c5d67ca002d9ed0c4b41b710d7e5a82e3bf"}} :ns-default build} + ;; versions to test against: + :1.10 {:override-deps {org.clojure/clojure {:mvn/version "1.10.3"}}} + :master {:override-deps {org.clojure/clojure {:mvn/version "1.11.1-master-SNAPSHOT"}}} + ;; running tests/checks of various kinds: - :test {:extra-paths ["test"] + :test {:extra-paths ["test"] ; can also run clojure -X:test :extra-deps {org.clojure/test.check {:mvn/version "1.1.0"} io.github.cognitect-labs/test-runner {:git/tag "v0.4.0" :git/sha "334f2e2"} @@ -44,4 +48,8 @@ org.apache.logging.log4j/log4j-jul {:mvn/version "2.14.1"} org.apache.logging.log4j/log4j-slf4j-impl {:mvn/version "2.14.1"}} :jvm-opts ["-Dlog4j2.configurationFile=log4j2-info.properties"] - :exec-fn cognitect.test-runner.api/test}}} + :exec-fn cognitect.test-runner.api/test} + + ;; various "runners" for tests/CI: + :runner + {:main-opts ["-m" "cognitect.test-runner"]}}}