ruby-changes:62758
From: Benoit <ko1@a...>
Date: Sat, 29 Aug 2020 19:51:26 +0900 (JST)
Subject: [ruby-changes:62758] d7492a0be8 (master): Revert changes to rdoc & rubygems regarding Tempfile.open(&block)
https://git.ruby-lang.org/ruby.git/commit/?id=d7492a0be8 From d7492a0be885ea9f2b9f71e3e95582f9a859c439 Mon Sep 17 00:00:00 2001 From: Benoit Daloze <eregontp@g...> Date: Sat, 29 Aug 2020 12:49:20 +0200 Subject: Revert changes to rdoc & rubygems regarding Tempfile.open(&block) * They likely want to support older Ruby/tempfile versions * Reverts part of e8c3872555fc85640505974e6b1c39d315572689 diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb index 39408fa..305e1dc 100644 --- a/lib/rubygems/ext/ext_conf_builder.rb +++ b/lib/rubygems/ext/ext_conf_builder.rb @@ -36,6 +36,7 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/ext_conf_builder.rb#L36 siteconf.close destdir = ENV["DESTDIR"] + begin cmd = Gem.ruby.shellsplit << "-I" << File.expand_path("../../..", __FILE__) << "-r" << get_relative_path(siteconf.path) << File.basename(extension) @@ -75,6 +76,7 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/ext_conf_builder.rb#L76 end ensure ENV["DESTDIR"] = destdir + siteconf.close! end end diff --git a/test/rdoc/test_rdoc_parser.rb b/test/rdoc/test_rdoc_parser.rb index cd43aca..7cc3c2d 100644 --- a/test/rdoc/test_rdoc_parser.rb +++ b/test/rdoc/test_rdoc_parser.rb @@ -106,7 +106,7 @@ class TestRDocParser < RDoc::TestCase https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_parser.rb#L106 def test_class_for_forbidden omit 'chmod not supported' if Gem.win_platform? - Tempfile.open 'forbidden' do |io| + tf = Tempfile.open 'forbidden' do |io| begin File.chmod 0000, io.path forbidden = @store.add_file io.path @@ -117,7 +117,9 @@ class TestRDocParser < RDoc::TestCase https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_parser.rb#L117 ensure File.chmod 0400, io.path end + io end + tf.close! end def test_class_for_modeline diff --git a/test/rdoc/test_rdoc_rd_block_parser.rb b/test/rdoc/test_rdoc_rd_block_parser.rb index 24413ee..22f432e 100644 --- a/test/rdoc/test_rdoc_rd_block_parser.rb +++ b/test/rdoc/test_rdoc_rd_block_parser.rb @@ -154,7 +154,7 @@ class TestRDocRdBlockParser < RDoc::TestCase https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_rd_block_parser.rb#L154 blank_line, blank_line) - Tempfile.open %w[parse_include .rd] do |io| + tf = Tempfile.open %w[parse_include .rd] do |io| io.puts "=begin\ninclude ((*worked*))\n=end" io.flush @@ -163,7 +163,9 @@ class TestRDocRdBlockParser < RDoc::TestCase https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_rd_block_parser.rb#L163 STR assert_equal expected, parse(str) + io end + tf.close! end def test_parse_heading diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb index 7824099..f2cc901 100644 --- a/test/rdoc/test_rdoc_rdoc.rb +++ b/test/rdoc/test_rdoc_rdoc.rb @@ -342,14 +342,16 @@ class TestRDocRDoc < RDoc::TestCase https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_rdoc.rb#L342 @rdoc.options.encoding = Encoding::ISO_8859_1 @rdoc.store = RDoc::Store.new - Tempfile.open 'test.txt' do |io| + tf = Tempfile.open 'test.txt' do |io| io.write 'hi' io.rewind top_level = @rdoc.parse_file io.path assert_equal Encoding::ISO_8859_1, top_level.absolute_name.encoding + io end + tf.close! end def test_parse_file_forbidden @@ -358,7 +360,7 @@ class TestRDocRDoc < RDoc::TestCase https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_rdoc.rb#L360 @rdoc.store = RDoc::Store.new - Tempfile.open 'test.txt' do |io| + tf = Tempfile.open 'test.txt' do |io| io.write 'hi' io.rewind @@ -377,7 +379,9 @@ class TestRDocRDoc < RDoc::TestCase https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_rdoc.rb#L379 ensure File.chmod 0400, io.path end + io end + tf.close! end def test_remove_unparseable @@ -474,7 +478,7 @@ class TestRDocRDoc < RDoc::TestCase https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_rdoc.rb#L478 end def test_setup_output_dir_exists_file - Tempfile.open 'test_rdoc_rdoc' do |tempfile| + tf = Tempfile.open 'test_rdoc_rdoc' do |tempfile| path = tempfile.path e = assert_raise RDoc::Error do @@ -483,7 +487,9 @@ class TestRDocRDoc < RDoc::TestCase https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_rdoc.rb#L487 assert_match(%r%#{Regexp.escape path} exists and is not a directory%, e.message) + tempfile end + tf.close! end def test_setup_output_dir_exists_not_rdoc diff --git a/test/rubygems/test_gem_package.rb b/test/rubygems/test_gem_package.rb index b6f785f..5e9c3b7 100644 --- a/test/rubygems/test_gem_package.rb +++ b/test/rubygems/test_gem_package.rb @@ -887,7 +887,7 @@ class TestGemPackage < Gem::Package::TarTestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_package.rb#L887 def test_verify_corrupt skip "jruby strips the null byte and does not think it's corrupt" if Gem.java_platform? - Tempfile.open 'corrupt' do |io| + tf = Tempfile.open 'corrupt' do |io| data = Gem::Util.gzip 'a' * 10 io.write \ tar_file_header('metadata.gz', "\000x", 0644, data.length, Time.now) @@ -902,7 +902,9 @@ class TestGemPackage < Gem::Package::TarTestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_package.rb#L902 assert_equal "tar is corrupt, name contains null byte in #{io.path}", e.message + io end + tf.close! end def test_verify_empty diff --git a/test/rubygems/test_gem_request_set.rb b/test/rubygems/test_gem_request_set.rb index 7a21424..54ae772 100644 --- a/test/rubygems/test_gem_request_set.rb +++ b/test/rubygems/test_gem_request_set.rb @@ -261,14 +261,16 @@ ruby "0" https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set.rb#L261 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 gem_deps = rs.load_gemdeps io.path assert_kind_of Gem::RequestSet::GemDependencyAPI, gem_deps + io end + tf.close! assert_equal [dep('a')], rs.dependencies @@ -279,7 +281,7 @@ ruby "0" https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set.rb#L281 def test_load_gemdeps_installing rs = Gem::RequestSet.new - Tempfile.open 'gem.deps.rb' do |io| + tf = Tempfile.open 'gem.deps.rb' do |io| io.puts 'ruby "0"' io.puts 'gem "a"' io.flush @@ -287,7 +289,9 @@ ruby "0" https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set.rb#L289 gem_deps = rs.load_gemdeps io.path, [], true assert_kind_of Gem::RequestSet::GemDependencyAPI, gem_deps + io end + tf.close! assert_equal [dep('a')], rs.dependencies end @@ -295,12 +299,14 @@ ruby "0" https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set.rb#L299 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 @@ -388,7 +394,7 @@ ruby "0" https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set.rb#L394 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 @@ -396,7 +402,9 @@ ruby "0" https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set.rb#L402 io.flush rs.load_gemdeps io.path + io end + tf.close! res = rs.resolve assert_equal 1, res.size @@ -449,7 +457,7 @@ ruby "0" https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set.rb#L457 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}" @@ -458,7 +466,9 @@ ruby "0" https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set.rb#L466 io.flush rs.load_gemdeps io.path + io end + tf.close! res = rs.resolve assert_equal 2, res.size diff --git a/test/rubygems/test_gem_request_set_gem_dependency_api.rb b/test/rubygems/test_gem_request_set_gem_dependency_api.rb index 249f2e1..2a96639 100644 --- a/test/rubygems/test_gem_request_set_gem_dependency_api.rb +++ b/test/rubygems/test_gem_request_set_gem_dependency_api.rb @@ -632,7 +632,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set_gem_dependency_api.rb#L632 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' @@ -647,7 +647,9 @@ end https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set_gem_dependency_api.rb#L647 assert_equal gda, gda.load assert_equal [dep('a'), dep('b')], @set.dependencies + io end + tf.close! end def test_pin_gem_source -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/