mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Simplify nested require exceptions
https://github.com/rubygems/rubygems/commit/7fbef2f0e3
This commit is contained in:
parent
43daf4d288
commit
1039c32de6
Notes:
git
2020-05-08 14:14:28 +09:00
2 changed files with 20 additions and 2 deletions
|
@ -156,8 +156,7 @@ module Kernel
|
|||
RUBYGEMS_ACTIVATION_MONITOR.enter
|
||||
|
||||
begin
|
||||
if load_error.message.start_with?("Could not find") or
|
||||
(load_error.message.end_with?(path) and Gem.try_activate(path))
|
||||
if load_error.message.end_with?(path) and Gem.try_activate(path)
|
||||
require_again = true
|
||||
end
|
||||
ensure
|
||||
|
|
|
@ -91,6 +91,25 @@ class TestKernel < Gem::TestCase
|
|||
refute $:.any? { |p| %r{a-1/bin} =~ p }
|
||||
end
|
||||
|
||||
def test_gem_failing_inside_require_doesnt_cause_double_exceptions
|
||||
File.write("activate.rb", "gem('a', '= 999')\n")
|
||||
|
||||
require "open3"
|
||||
|
||||
output, _ = Open3.capture2e(
|
||||
{ "GEM_HOME" => Gem.paths.home },
|
||||
Gem.ruby,
|
||||
"-I",
|
||||
File.expand_path("../../lib", __dir__),
|
||||
"-r",
|
||||
"./activate.rb"
|
||||
)
|
||||
|
||||
load_errors = output.split("\n").select { |line| line.include?("Could not find")}
|
||||
|
||||
assert_equal 1, load_errors.size
|
||||
end
|
||||
|
||||
def test_gem_bundler
|
||||
quick_gem 'bundler', '1'
|
||||
quick_gem 'bundler', '2.a'
|
||||
|
|
Loading…
Add table
Reference in a new issue