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

Merge release version of bundler-1.16.1 from upstream.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
hsbt 2017-12-21 09:22:15 +00:00
parent 85277d5be0
commit 4525cf2cd5
16 changed files with 122 additions and 95 deletions

View file

@ -1,10 +1,9 @@
# coding: utf-8
# frozen_string_literal: true
version = File.expand_path("../lib/bundler/version", __FILE__)
if File.file?(version)
require version
else # for Ruby core repository
begin
require File.expand_path("../lib/bundler/version", __FILE__)
rescue LoadError # for Ruby core repository
require File.expand_path("../bundler/version", __FILE__)
end
require "shellwords"

View file

@ -306,6 +306,8 @@ module Bundler
:solver_name => "Bundler",
:possibility_type => "gem",
:reduce_trees => lambda do |trees|
# bail out if tree size is too big for Array#combination to make any sense
return trees if trees.size > 15
maximal = 1.upto(trees.size).map do |size|
trees.map(&:last).flatten(1).combination(size).to_a
end.flatten(1).select do |deps|

View file

@ -7,7 +7,7 @@ module Bundler
# We're doing this because we might write tests that deal
# with other versions of bundler and we are unsure how to
# handle this better.
VERSION = "1.16.1.pre1" unless defined?(::Bundler::VERSION)
VERSION = "1.16.1" unless defined?(::Bundler::VERSION)
def self.overwrite_loaded_gem_version
begin

View file

@ -29,7 +29,7 @@ RSpec.describe "bundle exec" do
gem "rack"
G
bundle "exec 'cd #{tmp("gems")} && rackup'"
bundle "exec 'cd #{tmp("gems")} && rackup'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(out).to include("1.0.0")
end
@ -42,7 +42,7 @@ RSpec.describe "bundle exec" do
it "works when exec'ing to ruby" do
install_gemfile 'gem "rack"'
bundle "exec ruby -e 'puts %{hi}'"
bundle "exec ruby -e 'puts %{hi}'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(out).to eq("hi")
end
@ -76,7 +76,9 @@ RSpec.describe "bundle exec" do
G
install_gemfile ""
sys_exec("#{Gem.ruby} #{command.path}")
with_env_vars "RUBYOPT" => "-r#{spec_dir.join("support/hax")}" do
sys_exec "#{Gem.ruby} #{command.path}"
end
if Bundler.current_ruby.ruby_2?
expect(out).to eq("")
@ -237,7 +239,7 @@ RSpec.describe "bundle exec" do
G
[true, false].each do |l|
bundle! "config disable_exec_load #{l}"
bundle "exec rackup"
bundle "exec rackup", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(last_command.stderr).to include "rack is not part of the bundle. Add it to your Gemfile."
end
end
@ -339,14 +341,14 @@ RSpec.describe "bundle exec" do
end
it "works when unlocked", :ruby_repo do
bundle "exec 'cd #{tmp("gems")} && rackup'"
bundle "exec 'cd #{tmp("gems")} && rackup'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(out).to eq("1.0.0")
expect(out).to include("1.0.0")
end
it "works when locked", :ruby_repo do
expect(the_bundle).to be_locked
bundle "exec 'cd #{tmp("gems")} && rackup'"
bundle "exec 'cd #{tmp("gems")} && rackup'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(out).to include("1.0.0")
end
end
@ -472,7 +474,7 @@ RSpec.describe "bundle exec" do
Bundler.rubygems.extend(Monkey)
G
bundle "install --deployment"
bundle "exec ruby -e '`#{bindir.join("bundler")} -v`; puts $?.success?'"
bundle "exec ruby -e '`#{bindir.join("bundler")} -v`; puts $?.success?'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(out).to match("true")
end
end
@ -512,7 +514,7 @@ RSpec.describe "bundle exec" do
let(:expected) { [exec, args, rack, process].join("\n") }
let(:expected_err) { "" }
subject { bundle "exec #{path} arg1 arg2" }
subject { bundle "exec #{path} arg1 arg2", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" } }
shared_examples_for "it runs" do
it "like a normally executed executable" do
@ -550,6 +552,7 @@ RSpec.describe "bundle exec" do
ex << "raise SignalException, 'SIGTERM'\n"
ex
end
let(:expected_err) { ENV["TRAVIS"] ? "Terminated" : "" }
let(:exit_code) do
# signal mask 128 + plus signal 15 -> TERM
# this is specified by C99
@ -778,10 +781,13 @@ __FILE__: #{path.to_s.inspect}
file.chmod(0o777)
aggregate_failures do
expect(bundle!("exec #{file}", :system_bundler => true, :artifice => nil)).to eq(expected)
expect(bundle!("exec bundle exec #{file}", :system_bundler => true, :artifice => nil)).to eq(expected)
expect(bundle!("exec ruby #{file}", :system_bundler => true, :artifice => nil)).to eq(expected)
expect(run!(file.read, :no_lib => true, :artifice => nil)).to eq(expected)
expect(bundle!("exec #{file}", :artifice => nil)).to eq(expected)
expect(bundle!("exec bundle exec #{file}", :artifice => nil)).to eq(expected)
expect(bundle!("exec ruby #{file}", :artifice => nil)).to eq(expected)
# Ignore expectaion for default bundler gem conflict.
unless ENV["BUNDLER_SPEC_SUB_VERSION"]
expect(run!(file.read, :no_lib => true, :artifice => nil)).to eq(expected)
end
end
# sanity check that we get the newer, custom version without bundler

View file

@ -191,7 +191,7 @@ RSpec.describe "bundle gem" do
it "generates a valid gemspec" do
in_app_root
bundle "gem newgem --bin"
bundle! "gem newgem --bin"
process_file(bundled_app("newgem", "newgem.gemspec")) do |line|
# Simulate replacing TODOs with real values
@ -211,7 +211,9 @@ RSpec.describe "bundle gem" do
end
Dir.chdir(bundled_app("newgem")) do
system_gems ["rake-10.0.2"], :path => :bundle_path
gems = ["rake-10.0.2", :bundler]
gems.delete(:bundler) if ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]
system_gems gems, :path => :bundle_path
bundle! "exec rake build"
end

View file

@ -41,11 +41,14 @@ RSpec.describe "bundle pristine", :ruby_repo do
end
it "does not delete the bundler gem", :ruby_repo do
ENV["BUNDLER_SPEC_KEEP_DEFAULT_BUNDLER_GEM"] = "true"
system_gems :bundler
bundle! "install"
bundle! "pristine", :system_bundler => true
bundle! "-v", :system_bundler => true
expect(out).to end_with(Bundler::VERSION)
# An old rubygems couldn't handle a correct version of vendoered bundler.
bundler_version = Gem::VERSION < "2.1" ? "1.16.0" : Bundler::VERSION
expect(out).to end_with(bundler_version)
end
end

View file

@ -657,7 +657,7 @@ RSpec.describe "bundle update --bundler" do
source "file:#{gem_repo4}"
gem "rack"
G
lockfile lockfile.sub(Bundler::VERSION, "1.0.0")
lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, '\11.0.0\2')
FileUtils.rm_r gem_repo4

View file

@ -435,12 +435,11 @@ RSpec.describe "bundle install with gems on multiple sources" do
end
it "does not unlock the non-path gem after install" do
bundle :install
bundle! :install
bundle %(exec ruby -e 'puts "OK"')
bundle! %(exec ruby -e 'puts "OK"'), :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(out).to include("OK")
expect(exitstatus).to eq(0) if exitstatus
end
end
end

View file

@ -1,42 +1,40 @@
# frozen_string_literal: true
RSpec.describe "double checking sources", :realworld => true do
if RUBY_VERSION >= "2.2" # rails 5.x and rack 2.x only supports >= Ruby 2.2.
it "finds already-installed gems" do
create_file("rails.gemspec", <<-RUBY)
Gem::Specification.new do |s|
s.name = "rails"
s.version = "5.1.4"
s.summary = ""
s.description = ""
s.author = ""
s.add_dependency "actionpack", "5.1.4"
end
RUBY
it "finds already-installed gems", :ruby => ">= 2.2" do
create_file("rails.gemspec", <<-RUBY)
Gem::Specification.new do |s|
s.name = "rails"
s.version = "5.1.4"
s.summary = ""
s.description = ""
s.author = ""
s.add_dependency "actionpack", "5.1.4"
end
RUBY
create_file("actionpack.gemspec", <<-RUBY)
Gem::Specification.new do |s|
s.name = "actionpack"
s.version = "5.1.4"
s.summary = ""
s.description = ""
s.author = ""
s.add_dependency "rack", "~> 2.0.0"
end
RUBY
create_file("actionpack.gemspec", <<-RUBY)
Gem::Specification.new do |s|
s.name = "actionpack"
s.version = "5.1.4"
s.summary = ""
s.description = ""
s.author = ""
s.add_dependency "rack", "~> 2.0.0"
end
RUBY
cmd = <<-RUBY
require "bundler"
require #{File.expand_path("../../support/artifice/vcr.rb", __FILE__).dump}
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "rails", path: "."
end
RUBY
cmd = <<-RUBY
require "bundler"
require #{File.expand_path("../../support/artifice/vcr.rb", __FILE__).dump}
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "rails", path: "."
end
RUBY
ruby! cmd
ruby! cmd
end
ruby! cmd
ruby! cmd
end
end

View file

@ -36,7 +36,9 @@ RSpec.describe "require 'bundler/gem_tasks'" do
end
it "adds 'pkg' to rake/clean's CLOBBER" do
require "bundler/gem_tasks"
expect(CLOBBER).to include("pkg")
with_gem_path_as(Spec::Path.base_system_gems.to_s) do
sys_exec! %(#{rake} -e 'load "Rakefile"; puts CLOBBER.inspect')
end
expect(last_command.stdout).to eq '["pkg"]'
end
end

View file

@ -264,13 +264,13 @@ RSpec.describe "Bundler.require" do
describe "using bundle exec" do
it "requires the locked gems" do
bundle "exec ruby -e 'Bundler.require'"
bundle "exec ruby -e 'Bundler.require'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(out).to eq("two")
bundle "exec ruby -e 'Bundler.require(:bar)'"
bundle "exec ruby -e 'Bundler.require(:bar)'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(out).to eq("baz\nqux")
bundle "exec ruby -e 'Bundler.require(:default, :bar)'"
bundle "exec ruby -e 'Bundler.require(:default, :bar)'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(out).to eq("baz\nqux\ntwo")
end
end

View file

@ -763,7 +763,7 @@ end
G
ENV["GEM_HOME"] = ""
bundle %(exec ruby -e "require 'set'")
bundle %(exec ruby -e "require 'set'"), :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(err).to lack_errors
end
@ -1078,7 +1078,7 @@ end
gem "bundler", :path => "#{File.expand_path("..", lib)}"
G
bundle %(exec ruby -e "require 'bundler'; Bundler.setup")
bundle %(exec ruby -e "require 'bundler'; Bundler.setup"), :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(err).to lack_errors
end
end
@ -1236,6 +1236,7 @@ end
end
let(:activation_warning_hack) { strip_whitespace(<<-RUBY) }
require #{spec_dir.join("support/hax").to_s.dump}
require "rubygems"
if Gem::Specification.instance_methods.map(&:to_sym).include?(:activate)
@ -1279,8 +1280,9 @@ end
it "activates no gems with bundle exec" do
install_gemfile! ""
# ensure we clean out the default gems, bceause bundler's allowed to be activated
create_file("script.rb", code)
bundle! "exec ruby ./script.rb", :env => { :RUBYOPT => activation_warning_hack_rubyopt }
bundle! "exec ruby ./script.rb", :env => { :RUBYOPT => activation_warning_hack_rubyopt + " -rbundler/setup" }
expect(last_command.stdout).to eq("{}")
end

View file

@ -1,6 +1,14 @@
# frozen_string_literal: true
RSpec.describe "Bundler.with_env helpers" do
def bundle_exec_ruby!(code, *args)
opts = args.last.is_a?(Hash) ? args.pop : {}
env = opts[:env] ||= {}
env[:RUBYOPT] ||= "-r#{spec_dir.join("support/hax")}"
args.push opts
bundle! "exec '#{Gem.ruby}' -e #{code}", *args
end
describe "Bundler.original_env" do
before do
bundle "config path vendor/bundle"
@ -12,8 +20,8 @@ RSpec.describe "Bundler.with_env helpers" do
code = "print Bundler.original_env['PATH']"
path = `getconf PATH`.strip + "#{File::PATH_SEPARATOR}/foo"
with_path_as(path) do
result = bundle("exec '#{Gem.ruby}' -e #{code.dump}")
expect(result).to eq(path)
bundle_exec_ruby!(code.dump)
expect(last_command.stdboth).to eq(path)
end
end
@ -21,8 +29,8 @@ RSpec.describe "Bundler.with_env helpers" do
code = "print Bundler.original_env['GEM_PATH']"
gem_path = ENV["GEM_PATH"] + ":/foo"
with_gem_path_as(gem_path) do
result = bundle("exec '#{Gem.ruby}' -e #{code.inspect}")
expect(result).to eq(gem_path)
bundle_exec_ruby!(code.dump)
expect(last_command.stdboth).to eq(gem_path)
end
end
@ -38,7 +46,7 @@ RSpec.describe "Bundler.with_env helpers" do
RB
path = `getconf PATH`.strip + File::PATH_SEPARATOR + File.dirname(Gem.ruby)
with_path_as(path) do
bundle!("exec '#{Gem.ruby}' #{bundled_app("exe.rb")} 2")
bundle! "exec '#{Gem.ruby}' #{bundled_app("exe.rb")} 2", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
end
expect(err).to eq <<-EOS.strip
2 false
@ -48,10 +56,9 @@ RSpec.describe "Bundler.with_env helpers" do
end
it "removes variables that bundler added", :ruby_repo do
system_gems :bundler
original = ruby!('puts ENV.to_a.map {|e| e.join("=") }.sort.join("\n")')
original = ruby!('puts ENV.to_a.map {|e| e.join("=") }.sort.join("\n")', :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" })
code = 'puts Bundler.original_env.to_a.map {|e| e.join("=") }.sort.join("\n")'
bundle!("exec '#{Gem.ruby}' -e #{code.inspect}", :system_bundler => true)
bundle! "exec '#{Gem.ruby}' -e #{code.dump}", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(out).to eq original
end
end
@ -66,30 +73,30 @@ RSpec.describe "Bundler.with_env helpers" do
it "should delete BUNDLE_PATH" do
code = "print Bundler.clean_env.has_key?('BUNDLE_PATH')"
ENV["BUNDLE_PATH"] = "./foo"
result = bundle("exec '#{Gem.ruby}' -e #{code.inspect}")
expect(result).to eq("false")
bundle_exec_ruby! code.dump
expect(last_command.stdboth).to eq "false"
end
it "should remove '-rbundler/setup' from RUBYOPT" do
code = "print Bundler.clean_env['RUBYOPT']"
ENV["RUBYOPT"] = "-W2 -rbundler/setup"
result = bundle("exec '#{Gem.ruby}' -e #{code.inspect}")
expect(result).not_to include("-rbundler/setup")
bundle_exec_ruby! code.dump
expect(last_command.stdboth).not_to include("-rbundler/setup")
end
it "should clean up RUBYLIB", :ruby_repo do
code = "print Bundler.clean_env['RUBYLIB']"
ENV["RUBYLIB"] = root.join("lib").to_s + File::PATH_SEPARATOR + "/foo"
result = bundle("exec '#{Gem.ruby}' -e #{code.inspect}")
expect(result).to eq("/foo")
bundle_exec_ruby! code.dump
expect(last_command.stdboth).to eq("/foo")
end
it "should restore the original MANPATH" do
code = "print Bundler.clean_env['MANPATH']"
ENV["MANPATH"] = "/foo"
ENV["BUNDLER_ORIG_MANPATH"] = "/foo-original"
result = bundle("exec '#{Gem.ruby}' -e #{code.inspect}")
expect(result).to eq("/foo-original")
bundle_exec_ruby! code.dump
expect(last_command.stdboth).to eq("/foo-original")
end
end

View file

@ -4,13 +4,16 @@ $:.unshift File.expand_path("..", __FILE__)
$:.unshift File.expand_path("../../lib", __FILE__)
require "rubygems"
require "bundler/psyched_yaml"
require "bundler/vendored_fileutils"
require "uri"
require "digest"
require File.expand_path("../support/path.rb", __FILE__)
module Gem
if defined?(@path_to_default_spec_map)
@path_to_default_spec_map.delete_if do |_path, spec|
spec.name == "bundler"
end
end
end
begin
require File.expand_path("../support/path.rb", __FILE__)
spec = Gem::Specification.load(Spec::Path.gemspec.to_s)
rspec = spec.dependencies.find {|d| d.name == "rspec" }
gem "rspec", rspec.requirement.to_s
@ -20,6 +23,11 @@ rescue LoadError
abort "Run rake spec:deps to install development dependencies"
end
require "bundler/psyched_yaml"
require "bundler/vendored_fileutils"
require "uri"
require "digest"
if File.expand_path(__FILE__) =~ %r{([^\w/\.:\-])}
abort "The bundler specs cannot be run from a path that contains special characters (particularly #{$1.inspect})"
end
@ -99,8 +107,6 @@ RSpec.configure do |config|
original_wd = Dir.pwd
original_env = ENV.to_hash.delete_if {|k, _v| k.start_with?(Bundler::EnvironmentPreserver::BUNDLER_PREFIX) }
original_default_specs = Dir[File.join(Gem.default_dir, "specifications", "default", "bundler*")]
original_site_ruby_dirs = $LOAD_PATH.select {|path| path =~ /site_ruby/ }.map {|path| File.join(path, "bundler*") }.compact.map {|path| Dir[path] }.flatten
config.expect_with :rspec do |c|
c.syntax = :expect
@ -115,11 +121,6 @@ RSpec.configure do |config|
config.before :all do
build_repo1
(original_default_specs + original_site_ruby_dirs).each {|s| FileUtils.mv(s, s + ".org") }
end
config.after :all do
(original_default_specs + original_site_ruby_dirs).each {|s| FileUtils.mv(s + ".org", s) if File.exist?(s + ".org") }
end
config.before :each do

View file

@ -12,6 +12,12 @@ module Gem
@local = new(ENV["BUNDLER_SPEC_PLATFORM"]) if ENV["BUNDLER_SPEC_PLATFORM"]
end
@platforms = [Gem::Platform::RUBY, Gem::Platform.local]
if defined?(@path_to_default_spec_map) && !ENV["BUNDLER_SPEC_KEEP_DEFAULT_BUNDLER_GEM"]
@path_to_default_spec_map.delete_if do |_path, spec|
spec.name == "bundler"
end
end
end
if ENV["BUNDLER_SPEC_VERSION"]

View file

@ -220,7 +220,7 @@ module Spec
def rake
if ENV['BUNDLE_RUBY'] && ENV['BUNDLE_GEM']
"#{ENV['BUNDLE_RUBY']} #{ENV['GEM_PATH']}/bin/rake"
"'#{ENV['BUNDLE_RUBY']}' -S '#{ENV['GEM_PATH']}/bin/rake'"
else
'rake'
end