Permalink
Browse files

No more delete-file-recursively - use a commons-io method instead

  • Loading branch information...
1 parent d38f7ce commit ef2d46d85111479b3e67b7e0cf1a73d7cbfb9936 Matthew Maravillas committed Nov 13, 2011
Showing with 26 additions and 18 deletions.
  1. +2 −3 project.clj
  2. +24 −15 test/leiningen/test/multi.clj
View
@@ -3,9 +3,8 @@
:url "http://github.com/maravillas/lein-multi"
:license {:name "MIT License"
:url "http://www.opensource.org/licenses/mit-license.php"}
- :dev-dependencies [[org.clojure/clojure "1.2.1"]
- [org.clojure/clojure-contrib "1.2.0"]
-
+ :dev-dependencies [[org.clojure/clojure "1.3.0"]
+ [commons-io/commons-io "2.1"]
;; A lein jar is necessary for the tests. Clojars is a bit
;; oudated, though, so I'll just let you pull it in yourself.
;; Sorry.
@@ -1,12 +1,13 @@
(ns leiningen.test.multi
(:use [leiningen.multi] :reload-all)
(:use [leiningen.core :only [defproject read-project]]
- [clojure.test]
- [clojure.contrib.io :only [file delete-file-recursively]]))
+ [clojure.test]
+ [clojure.java.io :only [file]])
+ (:import [org.apache.commons.io FileUtils]))
(def test-project (merge (read-project "test-project/project.clj")
- ;; See comment in multi/run-deps re: path
- {:multi-library-path "test-project/multi-lib-test"}))
+ ;; See comment in multi/run-deps re: path
+ {:multi-library-path "test-project/multi-lib-test"}))
(defn add-clojure-deps
[project & versions]
@@ -19,9 +20,17 @@
[path]
(set (map #(.getName %) (.listFiles (file path)))))
+(defn delete-dirs
+ [& dirs]
+ (try
+ (doseq [dir dirs]
+ (FileUtils/deleteDirectory dir))
+ (catch Exception e
+ (println e))))
+
(deftest test-multi-deps
- (delete-file-recursively (file (:root test-project) "lib") true)
- (delete-file-recursively (file (:root test-project) "multi-lib-test") true)
+ (delete-dirs (file (:root test-project) "lib")
+ (file (:root test-project) "multi-lib-test"))
(let [test-project (add-clojure-deps test-project "1.1.0" "1.2.0")
lib-path (str (:root test-project) "/multi-lib-test")]
(multi test-project "deps")
@@ -30,26 +39,26 @@
(is (= #{"clojure-1.2.0.jar"} (list-files (str lib-path "/1.2.0"))))))
(deftest test-failing-multi-tests
- (delete-file-recursively (file (:root test-project) "multi-lib-test") true)
+ (delete-dirs (file (:root test-project) "multi-lib-test"))
(println "*** Begin embedded tests - ignore results below ***")
(let [test-project (add-clojure-deps test-project "1.1.0" "1.2.0")
- result (multi test-project "test")]
+ result (multi test-project "test")]
(println "*** End embedded tests - ignore results above ***")
(is (= result 1))))
(deftest test-passing-multi-tests
- (delete-file-recursively (file (:root test-project) "multi-lib-test") true)
+ (delete-dirs (file (:root test-project) "multi-lib-test"))
(println "*** Begin embedded tests - ignore results below ***")
(let [test-project (add-clojure-deps test-project "1.2.0")
- result (multi test-project "test")]
+ result (multi test-project "test")]
(println "*** End embedded tests - ignore results above ***")
(is (= result 0))))
(deftest test-multi-tests-with-namespaces
- (delete-file-recursively (file (:root test-project) "multi-lib-test") true)
+ (delete-dirs (file (:root test-project) "multi-lib-test"))
(println "*** Begin embedded tests - ignore results below ***")
(let [test-project (add-clojure-deps test-project "1.1.0")
- result (multi test-project "test" "sample2")]
+ result (multi test-project "test" "sample2")]
(println "*** End embedded tests - ignore results above ***")
;; If the sample2 namespace argument is ignored, sample/failing-test-1.1.0
;; will result in a return value of 1, as in test-failing-multi-tests
@@ -58,17 +67,17 @@
(deftest test-multi-no-sets
(println "*** Begin embedded tests - ignore results below ***")
(let [test-project (merge test-project {:multi-deps nil})
- result (multi test-project "test")]
+ result (multi test-project "test")]
(println "*** End embedded tests - ignore results above ***")
(is (= result 0))))
(deftest test-multi-new
(multi test-project "new" "multi-test-new-project")
(is (.exists (file "multi-test-new-project")))
- (delete-file-recursively (file "multi-test-new-project") true))
+ (delete-dirs (file "multi-test-new-project")))
(deftest test-with-dep
- (delete-file-recursively (file (:root test-project) "multi-lib-test") true)
+ (delete-dirs (file (:root test-project) "multi-lib-test"))
(let [test-project (add-clojure-deps test-project "1.1.0" "1.2.0")
lib-path (str (:root test-project) "/multi-lib-test")
result (multi test-project "deps" "--with" "1.2.0")]

0 comments on commit ef2d46d

Please sign in to comment.