1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[bundler/bundler] Remove unnecessary rubygems monkeypatch

Instead, make sure we always load the local copy of bundler during
specs, and never end up using the default copy.

https://github.com/bundler/bundler/commit/ac655ffeda
This commit is contained in:
David Rodríguez 2019-07-23 18:44:21 +02:00 committed by Hiroshi SHIBATA
parent 5a69a23afc
commit 4756c5f7e7
11 changed files with 48 additions and 48 deletions

View file

@ -42,8 +42,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
expect(changes_txt).to_not be_file
end
it "does not delete the bundler gem", :rubygems => ">= 2.6.2" do
ENV["BUNDLER_SPEC_KEEP_DEFAULT_BUNDLER_GEM"] = "true"
it "does not delete the bundler gem" do
system_gems :bundler
bundle! "install"
bundle! "pristine", :system_bundler => true

View file

@ -333,7 +333,7 @@ RSpec.describe "bundle install with groups" do
G
ruby <<-R
require "bundler"
require "#{lib}/bundler"
Bundler.setup :default
Bundler.require :default
puts RACK

View file

@ -25,9 +25,9 @@ RSpec.describe "double checking sources", :realworld => true, :sometimes => true
RUBY
cmd = <<-RUBY
require "bundler"
require "#{lib}/bundler"
require #{File.expand_path("../../support/artifice/vcr.rb", __FILE__).dump}
require "bundler/inline"
require "#{lib}/bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "rails", path: "."

View file

@ -2,7 +2,7 @@
RSpec.describe "bundler/inline#gemfile" do
def script(code, options = {})
requires = ["bundler/inline"]
requires = ["#{lib}/bundler/inline"]
requires.unshift File.expand_path("../../support/artifice/" + options.delete(:artifice) + ".rb", __FILE__) if options.key?(:artifice)
requires = requires.map {|r| "require '#{r}'" }.join("\n")
@out = ruby("#{requires}\n\n" + code, options)
@ -96,7 +96,7 @@ RSpec.describe "bundler/inline#gemfile" do
it "lets me use my own ui object" do
script <<-RUBY, :artifice => "endpoint"
require 'bundler'
require '#{lib}/bundler'
class MyBundlerUI < Bundler::UI::Silent
def confirm(msg, newline = nil)
puts "CONFIRMED!"
@ -140,7 +140,7 @@ RSpec.describe "bundler/inline#gemfile" do
it "does not mutate the option argument" do
script <<-RUBY
require 'bundler'
require '#{lib}/bundler'
options = { :ui => Bundler::UI::Shell.new }
gemfile(false, options) do
path "#{lib_path}" do

View file

@ -80,7 +80,7 @@ RSpec.describe "Bundler.load" do
G
ruby! <<-RUBY
require "bundler"
require "#{lib}/bundler"
Bundler.setup :default
Bundler.require :default
puts RACK

View file

@ -193,7 +193,7 @@ RSpec.describe "Bundler.require" do
G
cmd = <<-RUBY
require 'bundler'
require '#{lib}/bundler'
Bundler.require
RUBY
ruby(cmd)

View file

@ -12,7 +12,7 @@ RSpec.describe "Bundler.setup" do
G
ruby <<-RUBY
require 'bundler'
require '#{lib}/bundler'
Bundler.setup
require 'rack'
@ -34,7 +34,7 @@ RSpec.describe "Bundler.setup" do
it "doesn't make all groups available" do
ruby <<-RUBY
require 'bundler'
require '#{lib}/bundler'
Bundler.setup(:default)
begin
@ -49,7 +49,7 @@ RSpec.describe "Bundler.setup" do
it "accepts string for group name" do
ruby <<-RUBY
require 'bundler'
require '#{lib}/bundler'
Bundler.setup(:default, 'test')
require 'rack'
@ -61,7 +61,7 @@ RSpec.describe "Bundler.setup" do
it "leaves all groups available if they were already" do
ruby <<-RUBY
require 'bundler'
require '#{lib}/bundler'
Bundler.setup
Bundler.setup(:default)
@ -74,7 +74,7 @@ RSpec.describe "Bundler.setup" do
it "leaves :default available if setup is called twice" do
ruby <<-RUBY
require 'bundler'
require '#{lib}/bundler'
Bundler.setup(:default)
Bundler.setup(:default, :test)
@ -91,7 +91,7 @@ RSpec.describe "Bundler.setup" do
it "handles multiple non-additive invocations" do
ruby <<-RUBY
require 'bundler'
require '#{lib}/bundler'
Bundler.setup(:default, :test)
Bundler.setup(:default)
require 'rack'
@ -122,7 +122,7 @@ RSpec.describe "Bundler.setup" do
ENV["RUBYLIB"] = "rubylib_dir"
ruby <<-RUBY
require 'bundler'
require '#{lib}/bundler'
Bundler.setup
puts $LOAD_PATH
RUBY
@ -144,7 +144,7 @@ RSpec.describe "Bundler.setup" do
G
ruby! <<-RUBY
require 'bundler'
require '#{lib}/bundler'
Bundler.setup
puts $LOAD_PATH
RUBY
@ -172,7 +172,7 @@ RSpec.describe "Bundler.setup" do
G
ruby! <<-RUBY
require 'bundler/setup'
require '#{lib}/bundler/setup'
puts $LOAD_PATH
RUBY
@ -193,7 +193,7 @@ RSpec.describe "Bundler.setup" do
G
ruby <<-R
require 'bundler'
require '#{lib}/bundler'
begin
Bundler.setup
@ -213,7 +213,7 @@ RSpec.describe "Bundler.setup" do
G
ruby <<-R
require 'bundler'
require '#{lib}/bundler'
Bundler.setup
R
@ -236,7 +236,7 @@ RSpec.describe "Bundler.setup" do
G
ruby <<-R
require 'bundler'
require '#{lib}/bundler'
Bundler.setup
R
@ -289,7 +289,7 @@ RSpec.describe "Bundler.setup" do
ENV["BUNDLE_GEMFILE"] = "Gemfile"
ruby <<-R
require 'bundler'
require '#{lib}/bundler'
begin
Bundler.setup
@ -444,7 +444,7 @@ RSpec.describe "Bundler.setup" do
break_git!
ruby <<-R
require 'bundler'
require '#{lib}/bundler'
begin
Bundler.setup
@ -465,7 +465,7 @@ RSpec.describe "Bundler.setup" do
break_git!
ruby <<-R
require "bundler"
require "#{lib}/bundler"
begin
Bundler.setup
@ -774,7 +774,7 @@ end
s.class.send(:define_method, :build_extensions) { nil }
end
require 'bundler'
require '#{lib}/bundler'
gem '#{gem_name}'
puts $LOAD_PATH.count {|path| path =~ /#{gem_name}/} >= 2
@ -1028,7 +1028,7 @@ end
bundle "install"
ruby <<-RUBY
require 'bundler'
require '#{lib}/bundler'
def Bundler.require(path)
raise "LOSE"
end
@ -1083,7 +1083,7 @@ end
context "is not present" do
it "does not change the lock" do
lockfile lock_with(nil)
ruby "require 'bundler/setup'"
ruby "require '#{lib}/bundler/setup'"
lockfile_should_be lock_with(nil)
end
end
@ -1091,7 +1091,7 @@ end
context "is newer" do
it "does not change the lock or warn" do
lockfile lock_with(Bundler::VERSION.succ)
ruby "require 'bundler/setup'"
ruby "require '#{lib}/bundler/setup'"
expect(out).to eq("")
expect(err).to eq("")
lockfile_should_be lock_with(Bundler::VERSION.succ)
@ -1101,7 +1101,7 @@ end
context "is older" do
it "does not change the lock" do
lockfile lock_with("1.10.1")
ruby "require 'bundler/setup'"
ruby "require '#{lib}/bundler/setup'"
lockfile_should_be lock_with("1.10.1")
end
end
@ -1148,14 +1148,14 @@ end
context "is not present" do
it "does not change the lock" do
expect { ruby! "require 'bundler/setup'" }.not_to change { lockfile }
expect { ruby! "require '#{lib}/bundler/setup'" }.not_to change { lockfile }
end
end
context "is newer" do
let(:ruby_version) { "5.5.5" }
it "does not change the lock or warn" do
expect { ruby! "require 'bundler/setup'" }.not_to change { lockfile }
expect { ruby! "require '#{lib}/bundler/setup'" }.not_to change { lockfile }
expect(out).to eq("")
expect(err).to eq("")
end
@ -1164,7 +1164,7 @@ end
context "is older" do
let(:ruby_version) { "1.0.0" }
it "does not change the lock" do
expect { ruby! "require 'bundler/setup'" }.not_to change { lockfile }
expect { ruby! "require '#{lib}/bundler/setup'" }.not_to change { lockfile }
end
end
end
@ -1173,7 +1173,7 @@ end
it "does not load Psych" do
gemfile ""
ruby <<-RUBY
require 'bundler/setup'
require '#{lib}/bundler/setup'
puts defined?(Psych::VERSION) ? Psych::VERSION : "undefined"
require 'psych'
puts Psych::VERSION
@ -1186,7 +1186,7 @@ end
it "does not load openssl" do
install_gemfile! ""
ruby! <<-RUBY
require "bundler/setup"
require "#{lib}/bundler/setup"
puts defined?(OpenSSL) || "undefined"
require "openssl"
puts defined?(OpenSSL) || "undefined"
@ -1240,7 +1240,7 @@ end
it "activates no gems with -rbundler/setup" do
install_gemfile! ""
ruby! code, :env => { :RUBYOPT => activation_warning_hack_rubyopt + " -rbundler/setup" }
ruby! code, :env => { :RUBYOPT => activation_warning_hack_rubyopt + " -r#{lib}/bundler/setup" }
expect(out).to eq("{}")
end
@ -1315,7 +1315,7 @@ end
G
ruby! <<-RUBY
require "bundler/setup"
require "#{lib}/bundler/setup"
Object.new.gem "rack"
puts Gem.loaded_specs["rack"].full_name
RUBY
@ -1330,7 +1330,7 @@ end
G
ruby <<-RUBY
require "bundler/setup"
require "#{lib}/bundler/setup"
Object.new.gem "rack"
puts "FAIL"
RUBY
@ -1346,7 +1346,7 @@ end
G
ruby <<-RUBY
require "bundler/setup"
require "#{lib}/bundler/setup"
Object.new.require "rack"
puts "FAIL"
RUBY

View file

@ -1,15 +1,15 @@
# frozen_string_literal: true
RSpec.describe "Bundler.with_env helpers" do
def bundle_exec_ruby!(code)
build_bundler_context
bundle! "exec '#{Gem.ruby}' -e #{code}"
def bundle_exec_ruby!(code, options = {})
build_bundler_context options
bundle! "exec '#{Gem.ruby}' -e #{code}", options
end
def build_bundler_context
def build_bundler_context(options = {})
bundle "config set path vendor/bundle"
gemfile ""
bundle "install"
bundle "install", options
end
describe "Bundler.original_env" do
@ -75,7 +75,7 @@ RSpec.describe "Bundler.with_env helpers" do
it "should remove '-rbundler/setup' from RUBYOPT" do
code = "print #{modified_env}['RUBYOPT']"
ENV["RUBYOPT"] = "-W2 -rbundler/setup #{ENV["RUBYOPT"]}"
bundle_exec_ruby! code.dump
bundle_exec_ruby! code.dump, :env => { "BUNDLER_SPEC_DISABLE_DEFAULT_BUNDLER_GEM" => "true" }
expect(last_command.stdboth).not_to include("-rbundler/setup")
end

View file

@ -44,7 +44,7 @@ class Endpoint < Sinatra::Base
def dependencies_for(gem_names, gem_repo = GEM_REPO)
return [] if gem_names.nil? || gem_names.empty?
require "bundler"
require "#{Spec::Path.lib}/bundler"
Bundler::Deprecate.skip_during do
all_specs = %w[specs.4.8 prerelease_specs.4.8].map do |filename|
Marshal.load(File.open(gem_repo.join(filename)).read)

View file

@ -11,7 +11,8 @@ module Gem
end
@platforms = [Gem::Platform::RUBY, Gem::Platform.local]
if defined?(@path_to_default_spec_map) && !ENV["BUNDLER_SPEC_KEEP_DEFAULT_BUNDLER_GEM"]
# We only need this hack for rubygems versions without the BundlerVersionFinder
if Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0") || ENV["BUNDLER_SPEC_DISABLE_DEFAULT_BUNDLER_GEM"]
@path_to_default_spec_map.delete_if do |_path, spec|
spec.name == "bundler"
end

View file

@ -77,7 +77,7 @@ module Spec
def run(cmd, *args)
opts = args.last.is_a?(Hash) ? args.pop : {}
groups = args.map(&:inspect).join(", ")
setup = "require 'bundler' ; Bundler.setup(#{groups})\n"
setup = "require '#{lib}/bundler' ; Bundler.setup(#{groups})\n"
ruby(setup + cmd, opts)
end
bang :run