leiningen/test/test_run.clj

31 lines
953 B
Clojure
Raw Normal View History

2010-10-29 03:02:39 +00:00
(ns test-run
(:use [clojure.test]
[clojure.java.io :only [delete-file]]
[leiningen.core :only [read-project]]
2010-11-17 20:22:24 +00:00
[leiningen.run]
[leiningen.util.file :only [tmp-dir]]))
2010-10-29 03:02:39 +00:00
2010-11-17 20:22:24 +00:00
(def out-file (format "%s/lein-test" tmp-dir))
2010-10-29 03:02:39 +00:00
(def project (binding [*ns* (find-ns 'leiningen.core)]
(read-project "test_projects/tricky-name/project.clj")))
(use-fixtures :each (fn [f]
(delete-file out-file :silently)
(f)))
(deftest test-basic
(is (zero? (run project "1")))
(is (= "nom:1" (slurp out-file))))
(deftest test-alt-main
(is (zero? (run project "-m" "org.domain.tricky-name.munch" "1")))
(is (= ":munched (\"1\")" (slurp out-file))))
(deftest test-aliases
(is (zero? (run project ":bbb" "1")))
(is (= "BRUNCH" (slurp out-file)))
(delete-file out-file :silently)
(is (zero? (run project ":mmm" "1")))
(is (= ":munched (\"1\")" (slurp out-file))))