summaryrefslogtreecommitdiff
path: root/test/test_open3.rb
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2020-06-18 16:01:36 +0200
committerAaron Patterson <aaron.patterson@gmail.com>2020-06-18 10:00:20 -0700
commitadbdf11f94afd52d276c7891515e0eb808f6003f (patch)
tree9c541b9a5c970318a7515d382f1e162509e9d114 /test/test_open3.rb
parent42b4234ba486d4613f0e8b7c9e67bc37d511fa37 (diff)
[open3] only close streams if a block is passed
Ref: 5429deb075beb9a2b67adae269bbac16325876d1 The previous change totally borke `popen2e` in this usage: ```ruby require 'open3' stdin, stdout, process = Open3.popen2e("cat") puts stdout.read ```
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3236
Diffstat (limited to 'test/test_open3.rb')
-rw-r--r--test/test_open3.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/test_open3.rb b/test/test_open3.rb
index 24bd08e597..47d471c031 100644
--- a/test/test_open3.rb
+++ b/test/test_open3.rb
@@ -149,6 +149,17 @@ class TestOpen3 < Test::Unit::TestCase
}
end
+ def test_popen2e_noblock
+ i, o, t = Open3.popen2e(RUBY, '-e', 'STDOUT.print STDIN.read')
+ i.print "baz"
+ i.close
+ assert_equal("baz", o.read)
+ ensure
+ i.close
+ o.close
+ t.join
+ end
+
def test_capture3
o, e, s = Open3.capture3(RUBY, '-e', 'i=STDIN.read; print i+"o"; STDOUT.flush; STDERR.print i+"e"', :stdin_data=>"i")
assert_equal("io", o)