Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add an implementation of Redirectable for Writer.

  • Loading branch information...
commit 315157f9c0a46ade01f9abdd6c3e0cafc2a491d5 1 parent 24c57d4
@Raynes authored
Showing with 11 additions and 1 deletion.
  1. +6 −0 src/conch/sh.clj
  2. +5 −1 test/conch/sh_test.clj
View
6 src/conch/sh.clj
@@ -22,6 +22,12 @@
(doseq [buffer (get proc k)]
(f buffer proc)))))
+(extend-type java.io.Writer
+ Redirectable
+ (redirect [w options k proc]
+ (doseq [x (get proc k)]
+ (.write w x))))
+
(defn seqify? [options k]
(let [seqify (:seq options)]
(or (= seqify k)
View
6 test/conch/sh_test.clj
@@ -22,7 +22,11 @@
(echo "hi\nthere" {:out (fn [line _] (swap! x conj line))})
(is (= ["hi" "there"] @x))
(errecho "hi\nthere" {:err (fn [line _] (swap! ex conj line))})
- (is (= ["hi" "there"] @ex)))))))
+ (is (= ["hi" "there"] @ex))))
+ (testing "Can redirect output to a writer"
+ (let [writer (java.io.StringWriter.)]
+ (echo "hi" {:out writer})
+ (is (= (str writer) "hi\n")))))))
(deftest timeout-test
(sh/let-programs [sloop "test/testfiles/sloop"]

0 comments on commit 315157f

Please sign in to comment.
Something went wrong with that request. Please try again.