ruby-changes:45364
From: nobu <ko1@a...>
Date: Fri, 27 Jan 2017 14:01:25 +0900 (JST)
Subject: [ruby-changes:45364] nobu:r57437 (trunk): leakchecker.rb: get rid of uninitialized Tempfile
nobu 2017-01-27 14:01:18 +0900 (Fri, 27 Jan 2017) New Revision: 57437 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57437 Log: 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. Modified files: trunk/test/lib/leakchecker.rb trunk/test/test_tempfile.rb Index: test/lib/leakchecker.rb =================================================================== --- test/lib/leakchecker.rb (revision 57436) +++ test/lib/leakchecker.rb (revision 57437) @@ -114,7 +114,9 @@ class LeakChecker https://github.com/ruby/ruby/blob/trunk/test/lib/leakchecker.rb#L114 if prev_count == count [prev_count, []] 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] end end Index: test/test_tempfile.rb =================================================================== --- test/test_tempfile.rb (revision 57436) +++ test/test_tempfile.rb (revision 57437) @@ -20,6 +20,10 @@ class TestTempfile < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/test_tempfile.rb#L20 end end + def test_leackchecker + assert_instance_of(Tempfile, Tempfile.allocate) + end + def test_basic t = tempfile("foo") path = t.path -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/