From ba55706fb6b98a01f17909bf5830b66aa68f8fc4 Mon Sep 17 00:00:00 2001 From: lukeg Date: Sun, 26 Feb 2023 17:20:52 -0500 Subject: [PATCH] fix test/rubygems/test_gem_package_task.rb when in -j mode This test skipped sometimes due to failure to load 'rake/packagetask'. This is due to manipulation of $LOAD_PATH by other rubygems tests. If rake is loaded before any rubygems tests run, then it works fine. To reproduce the skipping behavior: $ make test-all TESTOPTS="-j6 --test-order=sorted test/rubygems/test_*.rb" --- test/rubygems/test_gem_bundler_version_finder.rb | 4 ++-- test/rubygems/test_gem_commands_exec_command.rb | 8 ++++---- test/rubygems/test_gem_commands_install_command.rb | 2 +- test/rubygems/test_gem_ext_builder.rb | 8 +++----- test/rubygems/test_gem_gem_runner.rb | 4 ++-- test/rubygems/test_kernel.rb | 8 -------- tool/lib/test/unit/parallel.rb | 4 ++++ 7 files changed, 16 insertions(+), 22 deletions(-) diff --git a/test/rubygems/test_gem_bundler_version_finder.rb b/test/rubygems/test_gem_bundler_version_finder.rb index fd61000b8a..2f5094c526 100644 --- a/test/rubygems/test_gem_bundler_version_finder.rb +++ b/test/rubygems/test_gem_bundler_version_finder.rb @@ -4,10 +4,10 @@ require "rubygems/bundler_version_finder" class TestGemBundlerVersionFinder < Gem::TestCase def setup - super - @argv = ARGV.dup @dollar_0 = $0 + super + without_any_upwards_gemfiles end diff --git a/test/rubygems/test_gem_commands_exec_command.rb b/test/rubygems/test_gem_commands_exec_command.rb index 642926769f..bd67bbe46c 100644 --- a/test/rubygems/test_gem_commands_exec_command.rb +++ b/test/rubygems/test_gem_commands_exec_command.rb @@ -4,15 +4,15 @@ require "rubygems/commands/exec_command" class TestGemCommandsExecCommand < Gem::TestCase def setup + @orig_args = Gem::Command.build_args + @orig_specific_extra_args = Gem::Command.specific_extra_args_hash.dup + @orig_extra_args = Gem::Command.extra_args.dup + super common_installer_setup @cmd = Gem::Commands::ExecCommand.new - @orig_args = Gem::Command.build_args - @orig_specific_extra_args = Gem::Command.specific_extra_args_hash.dup - @orig_extra_args = Gem::Command.extra_args.dup - @gem_home = Gem.dir @gem_path = Gem.path @test_arch = RbConfig::CONFIG["arch"] diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb index 14bddec485..686be17c7c 100644 --- a/test/rubygems/test_gem_commands_install_command.rb +++ b/test/rubygems/test_gem_commands_install_command.rb @@ -7,6 +7,7 @@ require "rubygems/rdoc" class TestGemCommandsInstallCommand < Gem::TestCase def setup + @orig_args = Gem::Command.build_args super common_installer_setup @@ -14,7 +15,6 @@ class TestGemCommandsInstallCommand < Gem::TestCase @cmd.options[:document] = [] @gemdeps = "tmp_install_gemdeps" - @orig_args = Gem::Command.build_args common_installer_setup end diff --git a/test/rubygems/test_gem_ext_builder.rb b/test/rubygems/test_gem_ext_builder.rb index 34d8903595..dcf02156df 100644 --- a/test/rubygems/test_gem_ext_builder.rb +++ b/test/rubygems/test_gem_ext_builder.rb @@ -5,6 +5,8 @@ require "rubygems/installer" class TestGemExtBuilder < Gem::TestCase def setup + @orig_DESTDIR = ENV["DESTDIR"] + @orig_make = ENV["make"] super @ext = File.join @tempdir, "ext" @@ -13,19 +15,15 @@ class TestGemExtBuilder < Gem::TestCase FileUtils.mkdir_p @ext FileUtils.mkdir_p @dest_path - @orig_DESTDIR = ENV["DESTDIR"] - @orig_make = ENV["make"] - @spec = util_spec "a" @builder = Gem::Ext::Builder.new @spec, "" end def teardown + super ENV["DESTDIR"] = @orig_DESTDIR ENV["make"] = @orig_make - - super end def test_class_make diff --git a/test/rubygems/test_gem_gem_runner.rb b/test/rubygems/test_gem_gem_runner.rb index f0128febc8..bc59c278d2 100644 --- a/test/rubygems/test_gem_gem_runner.rb +++ b/test/rubygems/test_gem_gem_runner.rb @@ -3,13 +3,13 @@ require_relative "helper" class TestGemGemRunner < Gem::TestCase def setup - super - require "rubygems/command" @orig_args = Gem::Command.build_args @orig_specific_extra_args = Gem::Command.specific_extra_args_hash.dup @orig_extra_args = Gem::Command.extra_args.dup + super + require "rubygems/gem_runner" @runner = Gem::GemRunner.new end diff --git a/test/rubygems/test_kernel.rb b/test/rubygems/test_kernel.rb index ce38d92d8d..959907444c 100644 --- a/test/rubygems/test_kernel.rb +++ b/test/rubygems/test_kernel.rb @@ -5,19 +5,11 @@ class TestKernel < Gem::TestCase def setup super - @old_path = $:.dup - util_make_gems without_any_upwards_gemfiles end - def teardown - super - - $:.replace @old_path - end - def test_gem assert gem("a", "= 1"), "Should load" assert $:.any? {|p| p.include?("a-1/lib") } diff --git a/tool/lib/test/unit/parallel.rb b/tool/lib/test/unit/parallel.rb index b3a8957f26..407e3fa1a2 100644 --- a/tool/lib/test/unit/parallel.rb +++ b/tool/lib/test/unit/parallel.rb @@ -208,5 +208,9 @@ if $0 == __FILE__ end end require 'rubygems' + begin + require 'rake' + rescue LoadError + end Test::Unit::Worker.new.run(ARGV) end