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"
This commit is contained in:
lukeg 2023-02-26 17:20:52 -05:00 committed by Hiroshi SHIBATA
parent 283c71eeff
commit ba55706fb6
Notes: git 2023-02-27 21:34:47 +00:00
7 changed files with 16 additions and 22 deletions

View file

@ -4,10 +4,10 @@ require "rubygems/bundler_version_finder"
class TestGemBundlerVersionFinder < Gem::TestCase class TestGemBundlerVersionFinder < Gem::TestCase
def setup def setup
super
@argv = ARGV.dup @argv = ARGV.dup
@dollar_0 = $0 @dollar_0 = $0
super
without_any_upwards_gemfiles without_any_upwards_gemfiles
end end

View file

@ -4,15 +4,15 @@ require "rubygems/commands/exec_command"
class TestGemCommandsExecCommand < Gem::TestCase class TestGemCommandsExecCommand < Gem::TestCase
def setup 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 super
common_installer_setup common_installer_setup
@cmd = Gem::Commands::ExecCommand.new @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_home = Gem.dir
@gem_path = Gem.path @gem_path = Gem.path
@test_arch = RbConfig::CONFIG["arch"] @test_arch = RbConfig::CONFIG["arch"]

View file

@ -7,6 +7,7 @@ require "rubygems/rdoc"
class TestGemCommandsInstallCommand < Gem::TestCase class TestGemCommandsInstallCommand < Gem::TestCase
def setup def setup
@orig_args = Gem::Command.build_args
super super
common_installer_setup common_installer_setup
@ -14,7 +15,6 @@ class TestGemCommandsInstallCommand < Gem::TestCase
@cmd.options[:document] = [] @cmd.options[:document] = []
@gemdeps = "tmp_install_gemdeps" @gemdeps = "tmp_install_gemdeps"
@orig_args = Gem::Command.build_args
common_installer_setup common_installer_setup
end end

View file

@ -5,6 +5,8 @@ require "rubygems/installer"
class TestGemExtBuilder < Gem::TestCase class TestGemExtBuilder < Gem::TestCase
def setup def setup
@orig_DESTDIR = ENV["DESTDIR"]
@orig_make = ENV["make"]
super super
@ext = File.join @tempdir, "ext" @ext = File.join @tempdir, "ext"
@ -13,19 +15,15 @@ class TestGemExtBuilder < Gem::TestCase
FileUtils.mkdir_p @ext FileUtils.mkdir_p @ext
FileUtils.mkdir_p @dest_path FileUtils.mkdir_p @dest_path
@orig_DESTDIR = ENV["DESTDIR"]
@orig_make = ENV["make"]
@spec = util_spec "a" @spec = util_spec "a"
@builder = Gem::Ext::Builder.new @spec, "" @builder = Gem::Ext::Builder.new @spec, ""
end end
def teardown def teardown
super
ENV["DESTDIR"] = @orig_DESTDIR ENV["DESTDIR"] = @orig_DESTDIR
ENV["make"] = @orig_make ENV["make"] = @orig_make
super
end end
def test_class_make def test_class_make

View file

@ -3,13 +3,13 @@ require_relative "helper"
class TestGemGemRunner < Gem::TestCase class TestGemGemRunner < Gem::TestCase
def setup def setup
super
require "rubygems/command" require "rubygems/command"
@orig_args = Gem::Command.build_args @orig_args = Gem::Command.build_args
@orig_specific_extra_args = Gem::Command.specific_extra_args_hash.dup @orig_specific_extra_args = Gem::Command.specific_extra_args_hash.dup
@orig_extra_args = Gem::Command.extra_args.dup @orig_extra_args = Gem::Command.extra_args.dup
super
require "rubygems/gem_runner" require "rubygems/gem_runner"
@runner = Gem::GemRunner.new @runner = Gem::GemRunner.new
end end

View file

@ -5,19 +5,11 @@ class TestKernel < Gem::TestCase
def setup def setup
super super
@old_path = $:.dup
util_make_gems util_make_gems
without_any_upwards_gemfiles without_any_upwards_gemfiles
end end
def teardown
super
$:.replace @old_path
end
def test_gem def test_gem
assert gem("a", "= 1"), "Should load" assert gem("a", "= 1"), "Should load"
assert $:.any? {|p| p.include?("a-1/lib") } assert $:.any? {|p| p.include?("a-1/lib") }

View file

@ -208,5 +208,9 @@ if $0 == __FILE__
end end
end end
require 'rubygems' require 'rubygems'
begin
require 'rake'
rescue LoadError
end
Test::Unit::Worker.new.run(ARGV) Test::Unit::Worker.new.run(ARGV)
end end