Skip to content

Commit

Permalink
Allow test selectors and namespaces to be specified in the same run.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Nov 10, 2010
1 parent fa2a0a0 commit 38347be
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ Then add a :test-selectors map to project.clj:

Now if you run "lein test" it will only run deftests that don't have
:integration metadata, while "lein test :integration" will only run
the integration tests and "lein test :all" will run everything.
the integration tests and "lein test :all" will run everything. You
can include test selectors and listing test namespaces in the same run.

Because it starts a new JVM process, lein test is not a good solution
for test-driven development. For that you would either need to look
Expand Down
4 changes: 1 addition & 3 deletions src/leiningen/test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ each namespace and print an overall summary."
(let [args (map read-string args)
nses (if (or (empty? args) (every? keyword? args))
(sort (namespaces-in-dir (:test-path project)))
args)
(filter symbol? args))
selectors (map (:test-selectors project) (filter keyword? args))
selectors (if (and (empty? selectors)
(:default (:test-selectors project)))
Expand All @@ -56,8 +56,6 @@ tests. If none are given, runs them all." ; TODO: update
(require '[clojure walk template stacktrace]))
(let [[nses selectors] (read-args tests project)
result (doto (File/createTempFile "lein" "result") .deleteOnExit)]
(when-not (or (every? symbol? nses) (every? keyword? nses))
(throw (Exception. "Args must be either all namespaces or keywords.")))
(eval-in-project project (form-for-testing-namespaces
nses (.getAbsolutePath result) (vec selectors))
nil nil `(do (require '~'clojure.test)
Expand Down
5 changes: 4 additions & 1 deletion test_projects/sample/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@
:main nom.nom.nom
:warn-on-reflection true
:shell-wrapper {:main nom.nom.nom
:bin "bin/nom"})
:bin "bin/nom"}
:test-selectors {:integration :integration
:default (complement :integration)
:all (constantly true)})

0 comments on commit 38347be

Please sign in to comment.