Skip to content
Permalink
Browse files
OK, so relative paths in project maps was the wrong way to go.
  • Loading branch information
technomancy committed Jan 7, 2012
1 parent 1fe2fed commit c2b40834e0b3c60105d7204e81232c270e9a589e
Showing 5 changed files with 50 additions and 36 deletions.
@@ -140,6 +140,19 @@
(profiles-for project profiles-to-apply))
{:without-profiles project}))

(defn- absolutize [root path]
(if (coll? path) ; paths can be either strings or collections of strings
(map (partial absolutize root) path)
(str (io/file root path))))

(defn- absolutize-path [project key]
(if (re-find #"-path$" (name key))
(update-in project [key] (partial absolutize (:root project)))
project))

(defn- absolutize-paths [project]
(reduce absolutize-path project (keys project)))

(defn read
"Read project map out of file, which defaults to project.clj."
([file profiles]
@@ -149,6 +162,6 @@
(when-not project
(throw (Exception. "project.clj must define project map.")))
(ns-unmap *ns* 'project) ; return it to original state
(merge-profiles @project profiles)))
(absolutize-paths (merge-profiles @project profiles))))
([file] (read file [:dev :user]))
([] (read "project.clj")))
@@ -10,34 +10,40 @@
(with-redefs [user/plugins (constantly {})]
(f))))

(def paths {:source-path ["src"],
:test-path ["test"],
:resources-path ["dev-resources" "resources"],
:compile-path "classes",
:native-path "native",
:target-path "target"})

(def expected {:name "leiningen", :group "leiningen",
:version "2.0.0-SNAPSHOT",
:url "https://github.com/technomancy/leiningen"

:disable-implicit-clean true,
:eval-in :leiningen,
:license {:name "Eclipse Public License"}

:dependencies '[[leiningen-core "2.0.0-SNAPSHOT"]
[clucy "0.2.2"] [lancet "1.0.1"]
[robert/hooke "1.1.2"]
[stencil "0.2.0"]],
:twelve 12 ; testing unquote

:repositories [["central" {:url "http://repo1.maven.org/maven2"}]
["clojars" {:url "http://clojars.org/repo/"}]]})

(deftest test-read-project
(is (= {:name "leiningen", :group "leiningen", :version "2.0.0-SNAPSHOT",
:url "https://github.com/technomancy/leiningen"

:source-path ["src"],
:compile-path "classes",
:test-path ["test"],
:resources-path ["dev-resources" "resources"],
:native-path "native",
:target-path "target",

:disable-implicit-clean true,
:eval-in :leiningen,
:license {:name "Eclipse Public License"}

:dependencies '[[leiningen-core "2.0.0-SNAPSHOT"]
[clucy "0.2.2"] [lancet "1.0.1"]
[robert/hooke "1.1.2"]
[stencil "0.2.0"]],
:twelve 12 ; testing unquote

;; wtf, (= [#"^\."] [#"^\."]) <- false
;; :jar-exclusions [#"^\."],
;; :uberjar-exclusions [#"^META-INF/DUMMY.SF"],
:repositories [["central" {:url "http://repo1.maven.org/maven2"}]
["clojars" {:url "http://clojars.org/repo/"}]]}
(dissoc (read "dev-resources/p1.clj")
:description :root :jar-exclusions :uberjar-exclusions))))
(let [actual (read "dev-resources/p1.clj")]
(doseq [[k v] expected]
(is (= (k actual) v)))
(doseq [[k path] paths
:when (string? path)]
(is (= (k actual) (str (:root actual) "/" path))))
(doseq [[k path] paths
:when (coll? path)]
(is (= (k actual) (for [p path] (str (:root actual) "/" p)))))))

;; TODO: test omit-default
;; TODO: test reading project that doesn't def project
@@ -41,7 +41,7 @@
(doseq [jar (jar-files files)
entry (enumeration-seq (.entries jar))
:when (.startsWith (.getName entry) "native/")]
(let [f (io/file (:root project) (:native-path project)
(let [f (io/file (:native-path project)
(subs (.getName entry) (count "native/")))]
(if (.isDirectory entry)
(.mkdirs f)
@@ -49,11 +49,7 @@ each namespace and print an overall summary."
nses (if (or (empty? args) (every? keyword? args))
;; maybe this is stupid and all *-path entries should
;; be absolute?
(sort (apply concat (for [test-path (:test-path project)]
(ns/namespaces-in-dir
(io/file (:root project) test-path)))))

#_(mapcat (:test-path project))
(sort (mapcat ns/namespaces-in-dir (:test-path project)))
(filter symbol? args))
selectors (map (merge {:all '(constantly true)}
(:test-selectors project)) (filter keyword? args))
@@ -84,7 +84,6 @@
(deps native-project)
(is (= (conj (get-in native-lib-files-map [(eval/get-os) (eval/get-arch)])
".gitkeep")
(set (for [f (rest (file-seq (io/file (:root native-project)
(eval/native-arch-path
(set (for [f (rest (file-seq (io/file (eval/native-arch-path
native-project))))]
(.getName f))))))

0 comments on commit c2b4083

Please sign in to comment.