Permalink
Browse files

Add tests for timeout functionality.

  • Loading branch information...
Raynes committed Sep 30, 2012
1 parent 459d26b commit b724ec6df37b1efb0ba88555012a26e3c9286b5f
Showing with 15 additions and 1 deletion.
  1. +8 −1 test/conch/sh_test.clj
  2. +7 −0 test/testfiles/sloop
View
@@ -22,4 +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)))))))
+
+(deftest timeout-test
+ (sh/let-programs [sloop "test/testfiles/sloop"]
+ (testing "Process exits and doesn't block forever"
+ (sloop {:timeout 1000})) ; If the test doesn't sit here forever, we have won.
+ (testing "Accumulate output before process dies from timeout"
+ (is (= "hi\nhi\n" (sloop {:timeout 2000}))))))
View
@@ -0,0 +1,7 @@
+#! /bin/bash
+
+while true
+do
+ echo "hi"
+ sleep 1
+done

0 comments on commit b724ec6

Please sign in to comment.