summaryrefslogtreecommitdiff
path: root/test/test_open3.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-21 07:00:58 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-21 07:00:58 +0000
commit3d9453994c965abff8851d008a01b40153ffee77 (patch)
tree84b4778409112ee0f17e82f004b814abb36a744b /test/test_open3.rb
parentb6d97cc9a8496339df5055131cfbca21c5cb9f8b (diff)
downloadruby-3d9453994c965abff8851d008a01b40153ffee77.tar.gz
lib/open3.rb: accept IO-like object for :stdin_data argument.
Open3.capture3, Open3.capture2, Open3.capture2e accepts IO-like object for :stdin_data argument. [ruby-core:80936] [Feature #13527] proposed by janko. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_open3.rb')
-rw-r--r--test/test_open3.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/test_open3.rb b/test/test_open3.rb
index d52ab6a9bf..6011ddd733 100644
--- a/test/test_open3.rb
+++ b/test/test_open3.rb
@@ -155,6 +155,17 @@ class TestOpen3 < Test::Unit::TestCase
assert(s.success?)
end
+ def test_capture3_stdin_data_io
+ IO.pipe {|r, w|
+ w.write "i"
+ w.close
+ o, e, s = Open3.capture3(RUBY, '-e', 'i=STDIN.read; print i+"o"; STDOUT.flush; STDERR.print i+"e"', :stdin_data=>r)
+ assert_equal("io", o)
+ assert_equal("ie", e)
+ assert(s.success?)
+ }
+ end
+
def test_capture3_flip
o, e, s = Open3.capture3(RUBY, '-e', 'STDOUT.sync=true; 1000.times { print "o"*1000; STDERR.print "e"*1000 }')
assert_equal("o"*1000000, o)
@@ -168,12 +179,32 @@ class TestOpen3 < Test::Unit::TestCase
assert(s.success?)
end
+ def test_capture2_stdin_data_io
+ IO.pipe {|r, w|
+ w.write "i"
+ w.close
+ o, s = Open3.capture2(RUBY, '-e', 'i=STDIN.read; print i+"o"', :stdin_data=>r)
+ assert_equal("io", o)
+ assert(s.success?)
+ }
+ end
+
def test_capture2e
oe, s = Open3.capture2e(RUBY, '-e', 'i=STDIN.read; print i+"o"; STDOUT.flush; STDERR.print i+"e"', :stdin_data=>"i")
assert_equal("ioie", oe)
assert(s.success?)
end
+ def test_capture2e_stdin_data_io
+ IO.pipe {|r, w|
+ w.write "i"
+ w.close
+ oe, s = Open3.capture2e(RUBY, '-e', 'i=STDIN.read; print i+"o"; STDOUT.flush; STDERR.print i+"e"', :stdin_data=>r)
+ assert_equal("ioie", oe)
+ assert(s.success?)
+ }
+ end
+
def test_capture3_stdin_data
o, e, s = Open3.capture3(RUBY, '-e', '', :stdin_data=>"z"*(1024*1024))
assert_equal("", o)