summaryrefslogtreecommitdiff
path: root/test/test_pty.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-29 13:38:39 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-29 13:38:39 +0000
commit6f39cf2d1e9677e29fefc76bc22b167b1e987624 (patch)
tree3b4e502f49ef137371fa9de392082184f4dfdd72 /test/test_pty.rb
parentb519ce9a8a0ae6b74e452a51bec2400a9bf5fcd4 (diff)
test/test_pty.rb: Close fds.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_pty.rb')
-rw-r--r--test/test_pty.rb42
1 files changed, 32 insertions, 10 deletions
diff --git a/test/test_pty.rb b/test/test_pty.rb
index 1ec383d04b..7639f6ac77 100644
--- a/test/test_pty.rb
+++ b/test/test_pty.rb
@@ -12,19 +12,26 @@ class TestPTY < Test::Unit::TestCase
RUBY = EnvUtil.rubybin
def test_spawn_without_block
- r, _, pid = PTY.spawn(RUBY, '-e', 'puts "a"')
+ r, w, pid = PTY.spawn(RUBY, '-e', 'puts "a"')
rescue RuntimeError
skip $!
else
assert_equal("a\r\n", r.gets)
ensure
+ r.close if r
+ w.close if w
Process.wait pid if pid
end
def test_spawn_with_block
PTY.spawn(RUBY, '-e', 'puts "b"') {|r,w,pid|
- assert_equal("b\r\n", r.gets)
- Process.wait(pid)
+ begin
+ assert_equal("b\r\n", r.gets)
+ ensure
+ r.close
+ w.close
+ Process.wait(pid)
+ end
}
rescue RuntimeError
skip $!
@@ -33,8 +40,13 @@ class TestPTY < Test::Unit::TestCase
def test_commandline
commandline = Shellwords.join([RUBY, '-e', 'puts "foo"'])
PTY.spawn(commandline) {|r,w,pid|
- assert_equal("foo\r\n", r.gets)
- Process.wait(pid)
+ begin
+ assert_equal("foo\r\n", r.gets)
+ ensure
+ r.close
+ w.close
+ Process.wait(pid)
+ end
}
rescue RuntimeError
skip $!
@@ -42,8 +54,13 @@ class TestPTY < Test::Unit::TestCase
def test_argv0
PTY.spawn([RUBY, "argv0"], '-e', 'puts "bar"') {|r,w,pid|
- assert_equal("bar\r\n", r.gets)
- Process.wait(pid)
+ begin
+ assert_equal("bar\r\n", r.gets)
+ ensure
+ r.close
+ w.close
+ Process.wait(pid)
+ end
}
rescue RuntimeError
skip $!
@@ -209,9 +226,14 @@ class TestPTY < Test::Unit::TestCase
assert(s.close_on_exec?)
}
PTY.spawn(RUBY, '-e', '') {|r, w, pid|
- assert(r.close_on_exec?)
- assert(w.close_on_exec?)
- Process.wait(pid)
+ begin
+ assert(r.close_on_exec?)
+ assert(w.close_on_exec?)
+ ensure
+ r.close
+ w.close
+ Process.wait(pid)
+ end
}
rescue RuntimeError
skip $!