mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
leakchecker.rb: get rid of uninitialized Tempfile
* test/lib/leakchecker.rb (LeakChecker#find_tempfiles): get rid of errors on uninitialized Tempfile, which can be left when Dir.tmpdir failed or by Tempfile.allocate. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
70410163f5
commit
640bcdf217
2 changed files with 7 additions and 1 deletions
|
@ -114,7 +114,9 @@ class LeakChecker
|
||||||
if prev_count == count
|
if prev_count == count
|
||||||
[prev_count, []]
|
[prev_count, []]
|
||||||
else
|
else
|
||||||
tempfiles = ObjectSpace.each_object(Tempfile).find_all {|t| t.path }
|
tempfiles = ObjectSpace.each_object(Tempfile).find_all {|t|
|
||||||
|
t.instance_variable_defined?(:@tmpfile) and t.path
|
||||||
|
}
|
||||||
[count, tempfiles]
|
[count, tempfiles]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,6 +20,10 @@ class TestTempfile < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_leackchecker
|
||||||
|
assert_instance_of(Tempfile, Tempfile.allocate)
|
||||||
|
end
|
||||||
|
|
||||||
def test_basic
|
def test_basic
|
||||||
t = tempfile("foo")
|
t = tempfile("foo")
|
||||||
path = t.path
|
path = t.path
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue