ruby-changes:54983
From: hsbt <ko1@a...>
Date: Thu, 7 Mar 2019 20:24:54 +0900 (JST)
Subject: [ruby-changes:54983] hsbt:r67190 (trunk): Ignore to handle the different platform
hsbt 2019-03-07 20:24:48 +0900 (Thu, 07 Mar 2019) New Revision: 67190 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67190 Log: Ignore to handle the different platform When `GEM_HOME` was shared with CRuby and JRuby. RubyGems try to handle both platforms. It should be ignored the different platform. Modified files: trunk/lib/rubygems/basic_specification.rb trunk/lib/rubygems/commands/pristine_command.rb trunk/test/rubygems/test_gem_commands_pristine_command.rb trunk/test/rubygems/test_gem_specification.rb Index: test/rubygems/test_gem_specification.rb =================================================================== --- test/rubygems/test_gem_specification.rb (revision 67189) +++ test/rubygems/test_gem_specification.rb (revision 67190) @@ -6,6 +6,7 @@ require 'stringio' https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L6 require 'rubygems/ext' require 'rubygems/specification' require 'rubygems/installer' +require 'rubygems/platform' class TestGemSpecification < Gem::TestCase @@ -59,12 +60,13 @@ end https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L60 end end - def ext_spec + def ext_spec(platform: Gem::Platform::RUBY) @ext = util_spec 'ext', '1' do |s| s.executable = 'exec' s.test_file = 'test/suite.rb' s.extensions = %w[ext/extconf.rb] s.license = 'MIT' + s.platform = platform s.mark_version s.files = %w[lib/code.rb] @@ -1673,6 +1675,16 @@ dependencies: [] https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L1675 assert_equal expected, err end + def test_contains_requirable_file_eh_extension + ext_spec(platform: Gem::Platform.new("java")) + + _, err = capture_io do + refute @ext.contains_requirable_file? 'nonexistent' + end + + assert_empty err + end + def test_date assert_equal Gem::Specification::TODAY, @a1.date end Index: test/rubygems/test_gem_commands_pristine_command.rb =================================================================== --- test/rubygems/test_gem_commands_pristine_command.rb (revision 67189) +++ test/rubygems/test_gem_commands_pristine_command.rb (revision 67190) @@ -514,6 +514,47 @@ class TestGemCommandsPristineCommand < G https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_pristine_command.rb#L514 assert_empty(@ui.error) end + def test_execute_multi_platform + a = util_spec 'a' do |s| + s.extensions << 'ext/a/extconf.rb' + end + + b = util_spec 'b' do |s| + s.extensions << 'ext/a/extconf.rb' + s.platform = Gem::Platform.new("java") + end + + ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb' + write_file ext_path do |io| + io.write <<-'RUBY' + File.open "Makefile", "w" do |f| + f.puts "clean:\n\techo cleaned\n" + f.puts "all:\n\techo built\n" + f.puts "install:\n\techo installed\n" + end + RUBY + end + + install_gem a + install_gem b + + @cmd.options[:extensions] = true + @cmd.options[:extensions_set] = true + @cmd.options[:args] = [] + + use_ui @ui do + @cmd.execute + end + + out = @ui.output.split "\n" + + assert_equal 'Restoring gems to pristine condition...', out.shift + assert_equal 'Building native extensions. This could take a while...', + out.shift + assert_equal "Restored #{a.full_name}", out.shift + assert_empty out, out.inspect + end + def test_handle_options @cmd.handle_options %w[] Index: lib/rubygems/commands/pristine_command.rb =================================================================== --- lib/rubygems/commands/pristine_command.rb (revision 67189) +++ lib/rubygems/commands/pristine_command.rb (revision 67190) @@ -104,6 +104,8 @@ extensions will be restored. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/pristine_command.rb#L104 end.flatten end + specs = specs.select{|spec| spec.platform == RUBY_ENGINE } + if specs.to_a.empty? raise Gem::Exception, "Failed to find gems #{options[:args]} #{options[:version]}" Index: lib/rubygems/basic_specification.rb =================================================================== --- lib/rubygems/basic_specification.rb (revision 67189) +++ lib/rubygems/basic_specification.rb (revision 67190) @@ -71,8 +71,11 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L71 elsif missing_extensions? @ignored = true - warn "Ignoring #{full_name} because its extensions are not built. " + - "Try: gem pristine #{name} --version #{version}" + if platform == RUBY_ENGINE + warn "Ignoring #{full_name} because its extensions are not built. " + + "Try: gem pristine #{name} --version #{version}" + end + return false end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/