Permalink
Browse files

Revert and use leiningen.core. Too risky.

  • Loading branch information...
1 parent 5ede0e6 commit 53529f6fd38324249fb6bfee42e45cba65b6fa07 @marick committed Feb 13, 2013
Showing with 33 additions and 37 deletions.
  1. +1 −0 project.clj
  2. +28 −33 src/midje/util/ecosystem.clj
  3. +4 −4 test/midje/util/t_ecosystem.clj
View
1 project.clj 100644 → 100755
@@ -11,6 +11,7 @@
[org.clojure/tools.macro "0.1.1"]
[org.clojure/core.incubator "0.1.0"]
[bultitude "0.1.7"]
+ [leiningen-core "2.0.0-preview10"]
[swiss-arrows "0.1.0"]
[org.clojure/tools.namespace "0.2.2"]
[slingshot "0.10.3"]
@@ -8,7 +8,8 @@
(ns ^{:doc "Environmental factors."}
midje.util.ecosystem
(:require [clojure.string :as str]
- midje.clojure.backwards-compatibility))
+ midje.clojure.backwards-compatibility
+ [leiningen.core.project :as project]))
(def issues-url "https://github.com/marick/Midje/issues")
(def syntax-errors-that-will-not-be-fixed
@@ -88,38 +89,32 @@
;; get that from `lein repl`, so the default value from `project.clj`
;; is returned.
-(def leiningen-paths-var nil)
+(when-1-3+
-(defmacro around-initial-paths [& body]
- `(let [original# leiningen-paths-var]
- (try
- (alter-var-root #'leiningen-paths-var (constantly nil))
- ~@body
- (finally (alter-var-root #'leiningen-paths-var (constantly original#))))))
+ (def leiningen-paths-var nil)
+
+ (defmacro around-initial-paths [& body]
+ `(let [original# leiningen-paths-var]
+ (try
+ (alter-var-root #'leiningen-paths-var (constantly nil))
+ ~@body
+ (finally (alter-var-root #'leiningen-paths-var (constantly original#))))))
-(defn set-leiningen-paths! [project]
- ;; Note that the order is guaranteed: test paths come before project paths.
- (alter-var-root #'leiningen-paths-var
- (constantly (concat (:test-paths project) (:source-paths project)))))
-
-
-(defn leiningen-project []
- (try
- (binding [*ns* *ns*]
- (in-ns 'midje.util.temporary)
- (load-file "./project.clj")
- (resolve 'midje.util.temporary/project))
- (catch java.io.FileNotFoundException e
- nil)
- (catch Exception e
- (println "======================================================")
- (println "==== There was an error loading the project file. ====")
- (println "======================================================")
- (println)
- (throw e))))
+ (defn set-leiningen-paths! [project]
+ ;; Note that the order is guaranteed: test paths come before project paths.
+ (alter-var-root #'leiningen-paths-var
+ (constantly (concat (:test-paths project) (:source-paths project)))))
+
+ (defn- project-with-paths []
+ (try
+ (project/read)
+ (catch java.io.FileNotFoundException e
+ {:test-paths ["test"]})))
-(defn leiningen-paths []
- (or leiningen-paths-var
- (do
- (set-leiningen-paths! (or (leiningen-project) {:test-paths ["test"]}))
- leiningen-paths-var)))
+ (defn leiningen-paths []
+ (or leiningen-paths-var
+ (do
+ (set-leiningen-paths! (project-with-paths))
+ leiningen-paths-var)))
+
+)
@@ -9,13 +9,13 @@
(against-background (around :facts (around-initial-paths ?form)))
(fact "if it exists"
(leiningen-paths) => ["/test1" "/src1"]
- (provided
- (leiningen-project) => {:test-paths ["/test1"] :source-paths ["/src1"]}))
+ (provided (leiningen.core.project/read) => {:test-paths ["/test1"]
+ :source-paths ["/src1"]}))
(fact "and provides a default if it does not"
(leiningen-paths) => ["test"]
- (provided
- (load-file "./project.clj") =throws=> (new java.io.FileNotFoundException)))
+ (provided (leiningen.core.project/read)
+ =throws=> (new java.io.FileNotFoundException)))
(fact "except that lein-midje can explicitly set the value"
(set-leiningen-paths! {:test-paths ["t"] :source-paths ["s"]})

0 comments on commit 53529f6

Please sign in to comment.