aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_io.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-09 09:32:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-09 09:32:48 +0000
commitfdb4c75a6549a976a2f05412ad15e7a7aa404e51 (patch)
tree23bf7eb1ccb8e246c3dc493d158dbe09a882473f /test/ruby/test_io.rb
parent8f6128303102d0b73eef15b4c02b62bfb1cb05f9 (diff)
downloadruby-fdb4c75a6549a976a2f05412ad15e7a7aa404e51.tar.gz
test_io.rb: fix tempfile leaks
* test/ruby/test_io.rb (test_flush_in_finalizer2): cannot unlink opened file on Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r--test/ruby/test_io.rb28
1 files changed, 15 insertions, 13 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 2f656d4c36..99f962bb19 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -2396,22 +2396,24 @@ End
Tempfile.open("bug3910") {|t|
path = t.path
t.close
- 1.times do
- io = open(path,"w")
- io.instance_variable_set(:@test_flush_in_finalizer2, true)
- io.print "hoge"
- end
- assert_nothing_raised(TypeError, bug3910) do
- GC.start
+ begin
+ 1.times do
+ io = open(path,"w")
+ io.instance_variable_set(:@test_flush_in_finalizer2, true)
+ io.print "hoge"
+ end
+ assert_nothing_raised(TypeError, bug3910) do
+ GC.start
+ end
+ ensure
+ ObjectSpace.each_object(File) {|f|
+ if f.instance_variables.include?(:@test_flush_in_finalizer2)
+ f.close
+ end
+ }
end
t.close!
}
- ensure
- ObjectSpace.each_object(File) {|f|
- if f.instance_variables.include?(:@test_flush_in_finalizer2)
- f.close
- end
- }
end
def test_readlines_limit_0