Mercurial > lasercutter
annotate 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 |
rev | line source |
---|---|
rlm@10 | 1 (ns clojure.contrib.test-shell |
rlm@10 | 2 (:use clojure.test |
rlm@10 | 3 clojure.contrib.shell) |
rlm@10 | 4 (:import (java.io File))) |
rlm@10 | 5 |
rlm@10 | 6 ; workaroung to access private parse-args. Better way? |
rlm@10 | 7 (def parse-args ((ns-interns 'clojure.contrib.shell) 'parse-args)) |
rlm@10 | 8 (def as-file ((ns-interns 'clojure.contrib.shell) 'as-file)) |
rlm@10 | 9 (def as-env-string ((ns-interns 'clojure.contrib.shell) 'as-env-string)) |
rlm@10 | 10 |
rlm@10 | 11 (deftest test-parse-args |
rlm@10 | 12 (are [x y] (= x y) |
rlm@10 | 13 {:cmd [nil] :out "UTF-8" :dir nil :env nil} (parse-args []) |
rlm@10 | 14 {:cmd ["ls"] :out "UTF-8" :dir nil :env nil} (parse-args ["ls"]) |
rlm@10 | 15 {:cmd ["ls" "-l"] :out "UTF-8" :dir nil :env nil} (parse-args ["ls" "-l"]) |
rlm@10 | 16 {:cmd ["ls"] :out "ISO-8859-1" :dir nil :env nil} (parse-args ["ls" :out "ISO-8859-1"]) |
rlm@10 | 17 )) |
rlm@10 | 18 |
rlm@10 | 19 (deftest test-with-sh-dir |
rlm@10 | 20 (are [x y] (= x y) |
rlm@10 | 21 nil *sh-dir* |
rlm@10 | 22 "foo" (with-sh-dir "foo" *sh-dir*))) |
rlm@10 | 23 |
rlm@10 | 24 (deftest test-with-sh-env |
rlm@10 | 25 (are [x y] (= x y) |
rlm@10 | 26 nil *sh-env* |
rlm@10 | 27 {:KEY "VAL"} (with-sh-env {:KEY "VAL"} *sh-env*))) |
rlm@10 | 28 |
rlm@10 | 29 (deftest test-as-env-string |
rlm@10 | 30 (are [x y] (= x y) |
rlm@10 | 31 nil (as-env-string nil) |
rlm@10 | 32 ["FOO=BAR"] (seq (as-env-string {"FOO" "BAR"})) |
rlm@10 | 33 ["FOO_SYMBOL=BAR"] (seq (as-env-string {'FOO_SYMBOL "BAR"})) |
rlm@10 | 34 ["FOO_KEYWORD=BAR"] (seq (as-env-string {:FOO_KEYWORD "BAR"})))) |
rlm@10 | 35 |
rlm@10 | 36 |
rlm@10 | 37 (deftest test-as-file |
rlm@10 | 38 (are [x y] (= x y) |
rlm@10 | 39 (File. "foo") (as-file "foo") |
rlm@10 | 40 nil (as-file nil) |
rlm@10 | 41 (File. "bar") (as-file (File. "bar")))) |