rlm@10: (ns clojure.contrib.test-shell rlm@10: (:use clojure.test rlm@10: clojure.contrib.shell) rlm@10: (:import (java.io File))) rlm@10: rlm@10: ; workaroung to access private parse-args. Better way? rlm@10: (def parse-args ((ns-interns 'clojure.contrib.shell) 'parse-args)) rlm@10: (def as-file ((ns-interns 'clojure.contrib.shell) 'as-file)) rlm@10: (def as-env-string ((ns-interns 'clojure.contrib.shell) 'as-env-string)) rlm@10: rlm@10: (deftest test-parse-args rlm@10: (are [x y] (= x y) rlm@10: {:cmd [nil] :out "UTF-8" :dir nil :env nil} (parse-args []) rlm@10: {:cmd ["ls"] :out "UTF-8" :dir nil :env nil} (parse-args ["ls"]) rlm@10: {:cmd ["ls" "-l"] :out "UTF-8" :dir nil :env nil} (parse-args ["ls" "-l"]) rlm@10: {:cmd ["ls"] :out "ISO-8859-1" :dir nil :env nil} (parse-args ["ls" :out "ISO-8859-1"]) rlm@10: )) rlm@10: rlm@10: (deftest test-with-sh-dir rlm@10: (are [x y] (= x y) rlm@10: nil *sh-dir* rlm@10: "foo" (with-sh-dir "foo" *sh-dir*))) rlm@10: rlm@10: (deftest test-with-sh-env rlm@10: (are [x y] (= x y) rlm@10: nil *sh-env* rlm@10: {:KEY "VAL"} (with-sh-env {:KEY "VAL"} *sh-env*))) rlm@10: rlm@10: (deftest test-as-env-string rlm@10: (are [x y] (= x y) rlm@10: nil (as-env-string nil) rlm@10: ["FOO=BAR"] (seq (as-env-string {"FOO" "BAR"})) rlm@10: ["FOO_SYMBOL=BAR"] (seq (as-env-string {'FOO_SYMBOL "BAR"})) rlm@10: ["FOO_KEYWORD=BAR"] (seq (as-env-string {:FOO_KEYWORD "BAR"})))) rlm@10: rlm@10: rlm@10: (deftest test-as-file rlm@10: (are [x y] (= x y) rlm@10: (File. "foo") (as-file "foo") rlm@10: nil (as-file nil) rlm@10: (File. "bar") (as-file (File. "bar"))))