[前][次][番号順一覧][スレッド一覧]

ruby-changes:34603

From: hsbt <ko1@a...>
Date: Fri, 4 Jul 2014 10:09:34 +0900 (JST)
Subject: [ruby-changes:34603] hsbt:r46684 (trunk): * test/rubygems/test_gem_package.rb: avoid tempfile leaks using Tempfile#close!

hsbt	2014-07-04 10:09:27 +0900 (Fri, 04 Jul 2014)

  New Revision: 46684

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46684

  Log:
    * test/rubygems/test_gem_package.rb: avoid tempfile leaks using Tempfile#close!
    * test/rubygems/test_gem_request_set.rb: ditto.
    * test/rubygems/test_gem_request_set_gem_dependency_api.rb: ditto.

  Modified files:
    trunk/ChangeLog
    trunk/test/rubygems/test_gem_package.rb
    trunk/test/rubygems/test_gem_request_set.rb
    trunk/test/rubygems/test_gem_request_set_gem_dependency_api.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46683)
+++ ChangeLog	(revision 46684)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jul  4 10:08:24 2014  SHIBATA Hiroshi  <shibata.hiroshi@g...>
+
+	* test/rubygems/test_gem_package.rb: avoid tempfile leaks using Tempfile#close!
+	* test/rubygems/test_gem_request_set.rb: ditto.
+	* test/rubygems/test_gem_request_set_gem_dependency_api.rb: ditto.
+
 Fri Jul  4 04:42:05 2014  NARUSE, Yui  <naruse@r...>
 
 	* lib/net/htp/response.rb (Net::Inflater#inflate_adapter):
Index: test/rubygems/test_gem_package.rb
===================================================================
--- test/rubygems/test_gem_package.rb	(revision 46683)
+++ test/rubygems/test_gem_package.rb	(revision 46684)
@@ -621,7 +621,7 @@ class TestGemPackage < Gem::Package::Tar https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_package.rb#L621
   end
 
   def test_verify_corrupt
-    Tempfile.open 'corrupt' do |io|
+    tf = Tempfile.open 'corrupt' do |io|
       data = Gem.gzip 'a' * 10
       io.write \
         tar_file_header('metadata.gz', "\000x", 0644, data.length, Time.now)
@@ -636,7 +636,9 @@ class TestGemPackage < Gem::Package::Tar https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_package.rb#L636
 
       assert_equal "tar is corrupt, name contains null byte in #{io.path}",
                    e.message
+      io
     end
+    tf.close!
   end
 
   def test_verify_empty
Index: test/rubygems/test_gem_request_set.rb
===================================================================
--- test/rubygems/test_gem_request_set.rb	(revision 46683)
+++ test/rubygems/test_gem_request_set.rb	(revision 46684)
@@ -156,12 +156,14 @@ DEPENDENCIES https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set.rb#L156
   def test_load_gemdeps
     rs = Gem::RequestSet.new
 
-    Tempfile.open 'gem.deps.rb' do |io|
+    tf = Tempfile.open 'gem.deps.rb' do |io|
       io.puts 'gem "a"'
       io.flush
 
       rs.load_gemdeps io.path
+      io
     end
+    tf.close!
 
     assert_equal [dep('a')], rs.dependencies
 
@@ -172,12 +174,14 @@ DEPENDENCIES https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set.rb#L174
   def test_load_gemdeps_without_groups
     rs = Gem::RequestSet.new
 
-    Tempfile.open 'gem.deps.rb' do |io|
+    tf = Tempfile.open 'gem.deps.rb' do |io|
       io.puts 'gem "a", :group => :test'
       io.flush
 
       rs.load_gemdeps io.path, [:test]
+      io
     end
+    tf.close!
 
     assert_empty rs.dependencies
   end
@@ -202,7 +206,7 @@ DEPENDENCIES https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set.rb#L206
 
     rs = Gem::RequestSet.new
 
-    Tempfile.open 'gem.deps.rb' do |io|
+    tf = Tempfile.open 'gem.deps.rb' do |io|
       io.puts <<-gems_deps_rb
         gem "#{name}", :git => "#{repository}"
       gems_deps_rb
@@ -210,7 +214,9 @@ DEPENDENCIES https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set.rb#L214
       io.flush
 
       rs.load_gemdeps io.path
+      io
     end
+    tf.close!
 
     res = rs.resolve
     assert_equal 1, res.size
@@ -263,7 +269,7 @@ DEPENDENCIES https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set.rb#L269
 
     rs = Gem::RequestSet.new
 
-    Tempfile.open 'gem.deps.rb' do |io|
+    tf = Tempfile.open 'gem.deps.rb' do |io|
       io.puts <<-gems_deps_rb
         gem "#{a_name}", :path => "#{a_directory}"
         gem "#{b_name}", :path => "#{b_directory}"
@@ -272,7 +278,9 @@ DEPENDENCIES https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set.rb#L278
       io.flush
 
       rs.load_gemdeps io.path
+      io
     end
+    tf.close!
 
     res = rs.resolve
     assert_equal 2, res.size
Index: test/rubygems/test_gem_request_set_gem_dependency_api.rb
===================================================================
--- test/rubygems/test_gem_request_set_gem_dependency_api.rb	(revision 46683)
+++ test/rubygems/test_gem_request_set_gem_dependency_api.rb	(revision 46684)
@@ -492,7 +492,7 @@ class TestGemRequestSetGemDependencyAPI https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set_gem_dependency_api.rb#L492
   end
 
   def test_load
-    Tempfile.open 'gem.deps.rb' do |io|
+    tf = Tempfile.open 'gem.deps.rb' do |io|
       io.write <<-GEM_DEPS
 gem 'a'
 
@@ -507,7 +507,9 @@ end https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set_gem_dependency_api.rb#L507
       gda.load
 
       assert_equal [dep('a'), dep('b')], @set.dependencies
+      io
     end
+    tf.close!
   end
 
   def test_name_typo

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]