summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-05 10:07:13 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-05 10:07:13 +0000
commit415e2cbd88b1af7c81292d762f15969d78643bfa (patch)
tree2979fdc28d817773b89aab0aa7ef84b8eeb16948 /test
parent1385ce5f89ddbc0660677a136fb785ab10cf08b2 (diff)
* lib/open3.rb (Open3.pipeline_start): new method.
(Open3.pipeline): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/test_open3.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/test_open3.rb b/test/test_open3.rb
index 5acc1c3..b0b9475 100644
--- a/test/test_open3.rb
+++ b/test/test_open3.rb
@@ -196,4 +196,39 @@ class TestOpen3 < Test::Unit::TestCase
}
end
+ def test_pipeline_start
+ command = [RUBY, '-e', 's=STDIN.read; print s[1..-1]; exit s[0] == ?t']
+ str = 'ttftff'
+ Open3.pipeline_start([RUBY, '-e', 'print ARGV[0]', str],
+ *([command]*str.length)) {|ts|
+ assert_kind_of(Array, ts)
+ assert_equal(str.length+1, ts.length)
+ ts.each {|t| assert_kind_of(Thread, t) }
+ ts.each_with_index {|t, i|
+ if i == 0
+ assert(t.value.success?)
+ else
+ assert_equal(str[i-1] == ?t, t.value.success?)
+ end
+ }
+ }
+ end
+
+ def test_pipeline
+ command = [RUBY, '-e', 's=STDIN.read; print s[1..-1]; exit s[0] == ?t']
+ str = 'ttftff'
+ ss = Open3.pipeline([RUBY, '-e', 'print ARGV[0]', str],
+ *([command]*str.length))
+ assert_kind_of(Array, ss)
+ assert_equal(str.length+1, ss.length)
+ ss.each {|s| assert_kind_of(Process::Status, s) }
+ ss.each_with_index {|s, i|
+ if i == 0
+ assert(s.success?)
+ else
+ assert_equal(str[i-1] == ?t, s.success?)
+ end
+ }
+ end
+
end