Project

General

Profile

Bug #12248 ยป 65ab980dbc13d1b8e95b7d1f7266406720718c24.patch

hsbt (Hiroshi SHIBATA), 04/05/2016 03:55 AM

View differences:

lib/rubygems/core_ext/kernel_require.rb
begin
RUBYGEMS_ACTIVATION_MONITOR.exit
return gem_original_require(spec.to_fullpath(path) || path)
return gem_original_require(path)
end if spec
# Attempt to find +path+ in any unresolved gems...
test/rubygems/test_require.rb
end
end
# Providing -I on the commandline should always beat gems
def test_dash_i_beats_gems
a1 = new_spec "a", "1", {"b" => "= 1"}, "lib/test_gem_require_a.rb"
b1 = new_spec "b", "1", {"c" => "> 0"}, "lib/b/c.rb"
c1 = new_spec "c", "1", nil, "lib/c/c.rb"
c2 = new_spec "c", "2", nil, "lib/c/c.rb"
install_specs c1, c2, b1, a1
dir = Dir.mktmpdir
dash_i_arg = File.join Dir.mktmpdir, 'lib'
c_rb = File.join dash_i_arg, 'b', 'c.rb'
FileUtils.mkdir_p File.dirname c_rb
File.open(c_rb, 'w') { |f| f.write "class Object; HELLO = 'world' end" }
lp = $LOAD_PATH.dup
# Pretend to provide a commandline argument that overrides a file in gem b
$LOAD_PATH.unshift dash_i_arg
assert_require 'test_gem_require_a'
assert_require 'b/c' # this should be required from -I
assert_equal "world", ::Object::HELLO
ensure
$LOAD_PATH.replace lp
Object.send :remove_const, :HELLO if Object.const_defined? :HELLO
end
def test_concurrent_require
Object.const_set :FILE_ENTERED_LATCH, Latch.new(2)
Object.const_set :FILE_EXIT_LATCH, Latch.new(1)
    (1-1/1)