diff --git a/README.md b/README.md index 452dbc6..69c742b 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ parallel, execute all the tests flagged as such. ## Usage -Put `[com.holychao/parallel-test "0.3.1"]` into the `:plugins` vector of your project.clj. +Put `[com.holychao/parallel-test "0.3.2"]` into the `:plugins` vector of your project.clj. $ lein parallel-test @@ -65,6 +65,8 @@ parallel. The default sequencing configuration is: ## Caveats +Parallel-test requires Clojure 1.5 or greater. + Running tests in parallel means exactly that; parallel-test does not tackle the subjects of isolation or concurrent access for you. If your tests or their fixtures make use of resources such as global diff --git a/project.clj b/project.clj index f5a8957..701ef11 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject com.holychao/parallel-test "0.3.1" +(defproject com.holychao/parallel-test "0.3.2" :description "Executes tests in parallel." :url "http://github.com/aredington/parallel-test" :license {:name "EPL" diff --git a/src/com/holychao/parallel_test.clj b/src/com/holychao/parallel_test.clj index ac3a3a3..fe09179 100644 --- a/src/com/holychao/parallel_test.clj +++ b/src/com/holychao/parallel_test.clj @@ -1,6 +1,6 @@ (ns com.holychao.parallel-test) -(def VERSION "0.3.1") +(def VERSION "0.3.2") (def ^:dynamic *category* "Var holding the current category while tests are being run." diff --git a/src/leiningen/parallel_test.clj b/src/leiningen/parallel_test.clj index 1f9baae..875ddbf 100644 --- a/src/leiningen/parallel_test.clj +++ b/src/leiningen/parallel_test.clj @@ -2,6 +2,7 @@ "Run the project's tests in parallel." (:refer-clojure :exclude [test]) (:require [clojure.java.io :as io] + [clojure.set :as set] [bultitude.core :as b] [leiningen.core.eval :as eval] [leiningen.core.main :as main] @@ -17,10 +18,10 @@ :parallel (fn [] (.availableProcessors (Runtime/getRuntime)))} :sequence [:serial]}) -(def ^:private parallel-test-profile - {:dependencies [['org.clojure/core.async "0.2.395"] - ['com.holychao/parallel-test ptest/VERSION] - ['robert/hooke "1.3.0"]]}) +(def ^:private parallel-test-dependencies + {'org.clojure/core.async "0.4.474" + 'com.holychao/parallel-test ptest/VERSION + 'robert/hooke "1.3.0"}) ;; TODO: make this an arg to form-for-testing-namespaces in 3.0. (def ^:private ^:dynamic *monkeypatch?* true) @@ -93,6 +94,18 @@ namespace and print an overall summary." (main/abort "Please specify :test-selectors in project.clj")) [nses selectors])) +(defn ensure-ptest-deps + "Ensure that deps holds SOME version of the libraries required by + parallel-test. This always yields primacy to the project.clj, but if + e.g. core.async is missing, it'll slot in the default version the + plugin defines." + [deps] + (let [missing-deps (->> deps + (map first) + set + (set/difference (set (keys parallel-test-dependencies))))] + (into deps (select-keys parallel-test-dependencies missing-deps)))) + (defn parallel-test "Run the project's tests in parallel." [project & tests] @@ -103,10 +116,12 @@ namespace and print an overall summary." false *exit-after-tests*) *monkeypatch?* (:monkeypatch-clojure-test project true)] - (let [profile (or (:parallel-test (:profiles project)) parallel-test-profile) + (let [profile (:parallel-test (:profiles project)) + profile-targets (cond-> [:leiningen/test :test] + profile (conj :parallel-test)) project (-> project - (project/add-profiles {:parallel-test profile}) - (project/merge-profiles [:leiningen/test :test :parallel-test])) + (project/merge-profiles profile-targets) + (update :dependencies ensure-ptest-deps)) [nses selectors] (read-args tests project) config (merge default-config (:parallel-test project))