Permalink
Browse files

Add some subproject tests (Issue #70).

  • Loading branch information...
1 parent f8c13b5 commit 2d85a5380c93ef377b7e3ee5fa10eab0a7f0e865 @emezeske committed Apr 8, 2012
Showing with 69 additions and 1 deletion.
  1. +1 −1 bin/test-install.sh
  2. +68 −0 plugin/test/leiningen/test/cljsbuild/subproject.clj
View
@@ -14,7 +14,7 @@ pushd $project_root
rm -rf ~/.m2/repository/lein-cljsbuild ~/.m2/repository/cljsbuild/
for d in support plugin; do
pushd $d
- lein install
+ lein install, test
popd
done
for d in $projects; do
@@ -0,0 +1,68 @@
+(ns leiningen.test.cljsbuild.subproject
+ (:use
+ leiningen.cljsbuild.subproject
+ clojure.test))
+
+(deftest test-check-clojure-version
+ (are [x] (= nil x)
+ (check-clojure-version {'org.clojure/clojure ["1.3.0"]})
+ (check-clojure-version {'org.clojure/clojure ["1.4.0"]}))
+ (are [x] (thrown? Exception x)
+ (check-clojure-version {'org.clojure/clojure ["1.2.0"]})
+ (check-clojure-version {})))
+
+(deftest test-merge-dependencies
+ (are [x] (apply =
+ (map dependency-map [(concat x cljsbuild-dependencies)
+ (merge-dependencies x)]))
+ [['org.clojure/clojure "1.3.0"] ['a "1"] ['b "2"]]
+ [['org.clojure/clojure "1.3.0"] ['cljsbuild "9.9.9"]]))
+
+(def lein-crossover ".crossovers")
+(def lein-build-path "src-cljs-a")
+(def lein-source-path "src-clj")
+(def lein-extra-classpath-dirs ["a" "b"])
+(def lein-dependencies [['org.clojure/clojure "1.3.0"] ['a "1"]])
+(def lein-dev-dependencies [['b "2"]])
+(def lein-repositories ["repository"])
+(def lein-builds [{:source-path lein-build-path}])
+
+(def lein1-project
+ {:dependencies lein-dependencies
+ :dev-dependencies lein-dev-dependencies
+ :source-path lein-source-path
+ :extra-classpath-dirs lein-extra-classpath-dirs
+ :repositories lein-repositories})
+
+(deftest test-make-subproject-lein1
+ (let [subproject (make-subproject-lein1 lein1-project lein-crossover lein-builds)]
+ (doseq [dir (concat lein-extra-classpath-dirs [lein-build-path lein-crossover])]
+ (is (some #{dir} (:extra-classpath-dirs subproject))))
+ (is (= lein-source-path (:source-path subproject)))
+ (is (:local-repo-classpath subproject))
+ (is (= lein-dev-dependencies (:dev-dependencies subproject)))
+ (is (= lein-repositories (:repositories subproject)))
+ (is (apply = (map dependency-map [(concat lein-dependencies cljsbuild-dependencies)
+ (:dependencies subproject)])))))
+
+(def lein2-eval-in :trampoline)
+(def lein2-resources-path "resources")
+(def lein2-project
+ {:dependencies lein-dependencies
+ :dev-dependencies lein-dev-dependencies
+ :source-paths (concat [lein-source-path] lein-extra-classpath-dirs)
+ :repositories lein-repositories
+ :eval-in lein2-eval-in
+ :resources-path lein2-resources-path})
+
+(deftest test-make-subproject-lein2
+ (let [subproject (make-subproject-lein2 lein2-project lein-crossover lein-builds)]
+ (doseq [dir (concat lein-extra-classpath-dirs [lein-source-path lein-build-path lein-crossover])]
+ (is (some #{dir} (:source-paths subproject))))
+ (is (:local-repo-classpath subproject))
+ (is (= lein-dev-dependencies (:dev-dependencies subproject)))
+ (is (= lein-repositories (:repositories subproject)))
+ (is (= lein2-eval-in (:eval-in subproject)))
+ (is (= lein2-resources-path (:resources-path subproject)))
+ (is (apply = (map dependency-map [(concat lein-dependencies cljsbuild-dependencies)
+ (:dependencies subproject)])))))

0 comments on commit 2d85a53

Please sign in to comment.