Skip to content
Browse files

allow `lein test` to take file args

closes #996
  • Loading branch information...
1 parent 2e349c6 commit 5cc3aa874bb7474ad835afae6676945695de1571 @cldwalker cldwalker committed Feb 11, 2013
Showing with 16 additions and 2 deletions.
  1. +11 −2 src/leiningen/test.clj
  2. +5 −0 test/leiningen/test/test.clj
View
13 src/leiningen/test.clj
@@ -6,7 +6,7 @@
[leiningen.core.eval :as eval]
[leiningen.core.main :as main]
[leiningen.core.project :as project])
- (:import (java.io File)))
+ (:import (java.io File PushbackReader)))
(def ^:dynamic *exit-after-tests* true)
@@ -109,8 +109,17 @@
'(fn [m & vars]
(some #(= (str "#'" %) (-> m ::var str)) vars))])
+;; from bultitude's namespaces-in-dir
+(defn- ns-form-for-file [file]
+ (with-open [r (PushbackReader. (io/reader file))] (@#'b/read-ns-form r)))
+
+(defn- convert-to-ns [possible-file]
+ (if (and (.endsWith possible-file ".clj") (.exists (io/file possible-file)))
+ (str (ns-form-for-file possible-file))
+ possible-file))
+
(defn- read-args [args project]
- (let [args (map read-string args)
+ (let [args (->> args (map convert-to-ns) (map read-string))
[nses given-selectors] (split-selectors args)
nses (or (seq nses)
(sort
View
5 test/leiningen/test/test.clj
@@ -59,6 +59,11 @@
test sample-no-aot-project "boom")
"java.io.FileNotFoundException: Could not locate")))
+(deftest test-file-argument
+ (let [file (io/file (first (:test-paths sample-no-aot-project)) "selectors.clj")]
+ (test sample-no-aot-project (.getPath file)))
+ (is (= (ran?) #{:regular :not-custom :int2})))
+
(def called? (atom false))
(defmethod clojure.test/report :begin-test-ns [_]

0 comments on commit 5cc3aa8

Please sign in to comment.
Something went wrong with that request. Please try again.