Mercurial > lasercutter
view src/clojure/contrib/test_contrib/test_shell.clj @ 10:ef7dbbd6452c
added clojure source goodness
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 21 Aug 2010 06:25:44 -0400 |
parents | |
children |
line wrap: on
line source
1 (ns clojure.contrib.test-shell2 (:use clojure.test3 clojure.contrib.shell)4 (:import (java.io File)))6 ; workaroung to access private parse-args. Better way?7 (def parse-args ((ns-interns 'clojure.contrib.shell) 'parse-args))8 (def as-file ((ns-interns 'clojure.contrib.shell) 'as-file))9 (def as-env-string ((ns-interns 'clojure.contrib.shell) 'as-env-string))11 (deftest test-parse-args12 (are [x y] (= x y)13 {:cmd [nil] :out "UTF-8" :dir nil :env nil} (parse-args [])14 {:cmd ["ls"] :out "UTF-8" :dir nil :env nil} (parse-args ["ls"])15 {:cmd ["ls" "-l"] :out "UTF-8" :dir nil :env nil} (parse-args ["ls" "-l"])16 {:cmd ["ls"] :out "ISO-8859-1" :dir nil :env nil} (parse-args ["ls" :out "ISO-8859-1"])17 ))19 (deftest test-with-sh-dir20 (are [x y] (= x y)21 nil *sh-dir*22 "foo" (with-sh-dir "foo" *sh-dir*)))24 (deftest test-with-sh-env25 (are [x y] (= x y)26 nil *sh-env*27 {:KEY "VAL"} (with-sh-env {:KEY "VAL"} *sh-env*)))29 (deftest test-as-env-string30 (are [x y] (= x y)31 nil (as-env-string nil)32 ["FOO=BAR"] (seq (as-env-string {"FOO" "BAR"}))33 ["FOO_SYMBOL=BAR"] (seq (as-env-string {'FOO_SYMBOL "BAR"}))34 ["FOO_KEYWORD=BAR"] (seq (as-env-string {:FOO_KEYWORD "BAR"}))))37 (deftest test-as-file38 (are [x y] (= x y)39 (File. "foo") (as-file "foo")40 nil (as-file nil)41 (File. "bar") (as-file (File. "bar"))))