diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/clojure/contrib/test_contrib/test_shell.clj	Sat Aug 21 06:25:44 2010 -0400
     1.3 @@ -0,0 +1,41 @@
     1.4 +(ns clojure.contrib.test-shell
     1.5 +  (:use clojure.test
     1.6 +	clojure.contrib.shell)
     1.7 +  (:import (java.io File)))
     1.8 +
     1.9 +; workaroung to access private parse-args. Better way?
    1.10 +(def parse-args ((ns-interns 'clojure.contrib.shell) 'parse-args))
    1.11 +(def as-file ((ns-interns 'clojure.contrib.shell) 'as-file))
    1.12 +(def as-env-string ((ns-interns 'clojure.contrib.shell) 'as-env-string))
    1.13 +
    1.14 +(deftest test-parse-args
    1.15 +  (are [x y] (= x y)
    1.16 +    {:cmd [nil] :out "UTF-8" :dir nil :env nil} (parse-args [])
    1.17 +    {:cmd ["ls"] :out "UTF-8" :dir nil :env nil} (parse-args ["ls"])
    1.18 +    {:cmd ["ls" "-l"] :out "UTF-8" :dir nil :env nil} (parse-args ["ls" "-l"])
    1.19 +    {:cmd ["ls"] :out "ISO-8859-1" :dir nil :env nil} (parse-args ["ls" :out "ISO-8859-1"])
    1.20 +))
    1.21 +  
    1.22 +(deftest test-with-sh-dir
    1.23 +  (are [x y] (= x y)
    1.24 +    nil *sh-dir*
    1.25 +    "foo" (with-sh-dir "foo" *sh-dir*)))
    1.26 +
    1.27 +(deftest test-with-sh-env
    1.28 +  (are [x y] (= x y)
    1.29 +    nil *sh-env*
    1.30 +    {:KEY "VAL"} (with-sh-env {:KEY "VAL"} *sh-env*)))
    1.31 +
    1.32 +(deftest test-as-env-string
    1.33 +  (are [x y] (= x y)
    1.34 +    nil (as-env-string nil)
    1.35 +    ["FOO=BAR"] (seq (as-env-string {"FOO" "BAR"}))
    1.36 +    ["FOO_SYMBOL=BAR"] (seq (as-env-string {'FOO_SYMBOL "BAR"}))
    1.37 +    ["FOO_KEYWORD=BAR"] (seq (as-env-string {:FOO_KEYWORD "BAR"}))))
    1.38 +
    1.39 +
    1.40 +(deftest test-as-file
    1.41 +  (are [x y] (= x y)
    1.42 +    (File. "foo") (as-file "foo")
    1.43 +    nil (as-file nil)
    1.44 +    (File. "bar") (as-file (File. "bar"))))
    1.45 \ No newline at end of file