Browse files

Include namespace metadata in test-selector predicates, fixes #242

More specific metadata wins, e.g. deftest trumps its namespace.

Also tweaked the tests a bit so that actual/expected results are now
shown in the output.
  • Loading branch information...
1 parent 4f507a2 commit e770d5e649315e9661430b93f9a5e8f75e96bed1 @jcrossley3 jcrossley3 committed Oct 2, 2012
Showing with 24 additions and 9 deletions.
  1. +2 −1 src/leiningen/test.clj
  2. +11 −8 test/leiningen/test/test.clj
  3. +11 −0 test_projects/sample_no_aot/test/namespace.clj
View
3 src/leiningen/test.clj
@@ -15,7 +15,8 @@
(leiningen.core.injected/add-hook
(resolve 'clojure.test/test-var)
(fn test-var-with-selector [test-var# var#]
- (when (reduce #(or %1 (%2 (assoc (meta var#) ::var var#)))
+ (when (reduce #(or %1 (%2 (merge (-> var# meta :ns meta)
+ (assoc (meta var#) ::var var#))))
false ~selectors)
(test-var# var#))))))
View
19 test/leiningen/test/test.clj
@@ -10,12 +10,11 @@
(f)
(.delete (java.io.File. tmp-dir "lein-test-ran"))))
-(defn ran? [& expected]
+(defn ran? []
(let [ran-file (io/file tmp-dir "lein-test-ran")]
(and (.exists ran-file)
- (= (set expected)
- (set (for [ran (.split (slurp ran-file) "\n")]
- (read-string ran)))))))
+ (set (for [ran (.split (slurp ran-file) "\n")]
+ (read-string ran))))))
(deftest test-project-selectors
(is (= [:default :integration :int2 :no-custom]
@@ -24,16 +23,20 @@
(deftest test-default-selector
(test sample-no-aot-project ":default")
- (is (ran? :regular :int2 :not-custom)))
+ (is (= (ran?) #{:regular :int2 :not-custom})))
(deftest test-basic-selector
(test sample-no-aot-project ":integration")
- (is (ran? :integration)))
+ (is (= (ran?) #{:integration :integration-ns})))
(deftest test-complex-selector
(test sample-no-aot-project ":no-custom")
- (is (ran? :integration :regular :int2)))
+ (is (= (ran?) #{:integration :integration-ns :regular :int2})))
(deftest test-two-selectors
(test sample-no-aot-project ":integration" ":int2")
- (is (ran? :integration :int2)))
+ (is (= (ran?) #{:integration :integration-ns :int2})))
+
+(deftest test-override-namespace-selector
+ (test sample-no-aot-project ":int2")
+ (is (= (ran?) #{:integration-ns :int2})))
View
11 test_projects/sample_no_aot/test/namespace.clj
@@ -0,0 +1,11 @@
+(ns ^:integration namespace
+ (:use [clojure.test]
+ [selectors :only [record-ran]]))
+
+(deftest integration-test
+ (record-ran :integration-ns)
+ (is true))
+
+(deftest ^:int2 int2-integration-test
+ (record-ran :integration-ns)
+ (is true))

0 comments on commit e770d5e

Please sign in to comment.