Permalink
Browse files

Add a test for the optional #_ defdeps prefix.

  • Loading branch information...
1 parent aa77fe6 commit e4095e22d51714b35ec9f679b82741c4772aeffd @mtyaka committed Jan 1, 2012
@@ -1,15 +1,22 @@
(ns leiningen.test.oneoff
- (:use [leiningen.oneoff] :reload)
+ (:use [leiningen.oneoff :only [execute-script]] :reload)
(:use [clojure.test]
[clojure.java.io :only [file delete-file]]))
-(def sample-project (file "test_projects/sample.clj"))
(def output-file (file "test_projects/output"))
-(deftest test-execute-script
+(defn- exec [filename & args]
(delete-file output-file true)
- (execute-script (.getCanonicalPath sample-project) "bake" "honk!")
+ (let [script-file (file "test_projects" filename)]
+ (apply execute-script (.getCanonicalPath script-file) args)))
+
+(deftest test-execute-script
+ (exec "sample1.clj" "bake" "honk!")
+ (let [output (slurp output-file)]
+ (is (re-find #"1\.3\.0-alpha5" output))
+ (is (re-find #"arguments: \[\"bake\" \"honk!\"\]" output)))
+ (exec "sample2.clj")
(let [output (slurp output-file)]
- (is (re-find #"1.3.0-alpha5" output))
- (is (re-find #"\[\"bake\" \"honk!\"\]" output)))
+ (is (re-find #"1\.2\.1" output))
+ (is (re-find #"arguments: nil" output)))
(delete-file output-file))
File renamed without changes.
@@ -0,0 +1,9 @@
+#_(defdeps
+ [[org.clojure/clojure "1.2.1"]])
+
+(ns sample1
+ (:use [clojure.java.io :only [file]]))
+
+(spit (file *file* "../output")
+ (str "Running sample.clj under clojure " (clojure-version) " "
+ "with arguments: " (prn-str *command-line-args*)))

0 comments on commit e4095e2

Please sign in to comment.