This commit is contained in:
Hiroshi SHIBATA 2020-05-15 21:31:12 +09:00
Родитель f4f157fc81
Коммит c7ebeb7eda
54 изменённых файлов: 443 добавлений и 362 удалений

Просмотреть файл

@ -222,7 +222,6 @@ module Bundler
def github(repo, options = {})
raise ArgumentError, "GitHub sources require a block" unless block_given?
raise DeprecatedError, "The #github method has been removed" if Bundler.feature_flag.skip_default_git_sources?
github_uri = @git_sources["github"].call(repo)
git_options = normalize_hash(options).merge("uri" => github_uri)
git_source = @sources.add_git_source(git_options)
@ -283,8 +282,6 @@ module Bundler
private
def add_git_sources
return if Bundler.feature_flag.skip_default_git_sources?
git_source(:github) do |repo_name|
warn_deprecated_git_source(:github, <<-'RUBY'.strip, 'Change any "reponame" :github sources to "username/reponame".')
"https://github.com/#{repo_name}.git"

Просмотреть файл

@ -41,7 +41,6 @@ module Bundler
settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
settings_flag(:print_only_version_number) { bundler_3_mode? }
settings_flag(:setup_makes_kernel_gem_public) { !bundler_3_mode? }
settings_flag(:skip_default_git_sources) { bundler_3_mode? }
settings_flag(:specific_platform) { bundler_3_mode? }
settings_flag(:suppress_install_using_messages) { bundler_3_mode? }
settings_flag(:unlock_source_unlocks_spec) { !bundler_3_mode? }

Просмотреть файл

@ -76,7 +76,7 @@ module Bundler
I tried...
- **Have you read our issues document, https://github.com/rubygems/bundler/blob/master/doc/contributing/ISSUES.md?**
- **Have you read our issues document, https://github.com/rubygems/rubygems/blob/master/doc/contributing/ISSUES.md?**
...
@ -100,7 +100,7 @@ module Bundler
#{issues_url(e)}
If there aren't any reports for this error yet, please create copy and paste the report template above into a new issue. Don't forget to anonymize any private data! The new issue form is located at:
https://github.com/rubygems/bundler/issues/new
https://github.com/rubygems/rubygems/issues/new
EOS
end
@ -108,7 +108,7 @@ module Bundler
message = exception.message.lines.first.tr(":", " ").chomp
message = message.split("-").first if exception.is_a?(Errno)
require "cgi"
"https://github.com/rubygems/bundler/search?q=" \
"https://github.com/rubygems/rubygems/search?q=" \
"#{CGI.escape(message)}&type=Issues"
end
end

Просмотреть файл

@ -42,7 +42,6 @@ module Bundler
setup_makes_kernel_gem_public
silence_deprecations
silence_root_warning
skip_default_git_sources
specific_platform
suppress_install_using_messages
unlock_source_unlocks_spec

Просмотреть файл

@ -262,9 +262,6 @@ The following is a list of all configuration keys and their purpose\. You can le
\fBsilence_root_warning\fR (\fBBUNDLE_SILENCE_ROOT_WARNING\fR): Silence the warning Bundler prints when installing gems as root\.
.
.IP "\(bu" 4
\fBskip_default_git_sources\fR (\fBBUNDLE_SKIP_DEFAULT_GIT_SOURCES\fR): Whether Bundler should skip adding default git source shortcuts to the Gemfile DSL\.
.
.IP "\(bu" 4
\fBspecific_platform\fR (\fBBUNDLE_SPECIFIC_PLATFORM\fR): Allow bundler to resolve for the specific running platform and store it in the lockfile, instead of only using a generic platform\. A specific platform is the exact platform triple reported by \fBGem::Platform\.local\fR, such as \fBx86_64\-darwin\-16\fR or \fBuniversal\-java\-1\.8\fR\. On the other hand, generic platforms are those such as \fBruby\fR, \fBmswin\fR, or \fBjava\fR\. In this example, \fBx86_64\-darwin\-16\fR would map to \fBruby\fR and \fBuniversal\-java\-1\.8\fR to \fBjava\fR\.
.
.IP "\(bu" 4

Просмотреть файл

@ -312,10 +312,6 @@ LIST OF AVAILABLE KEYS
o silence_root_warning (BUNDLE_SILENCE_ROOT_WARNING): Silence the
warning Bundler prints when installing gems as root.
o skip_default_git_sources (BUNDLE_SKIP_DEFAULT_GIT_SOURCES): Whether
Bundler should skip adding default git source shortcuts to the
Gemfile DSL.
o specific_platform (BUNDLE_SPECIFIC_PLATFORM): Allow bundler to
resolve for the specific running platform and store it in the
lockfile, instead of only using a generic platform. A specific

Просмотреть файл

@ -249,9 +249,6 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
be changed in the next major version.
* `silence_root_warning` (`BUNDLE_SILENCE_ROOT_WARNING`):
Silence the warning Bundler prints when installing gems as root.
* `skip_default_git_sources` (`BUNDLE_SKIP_DEFAULT_GIT_SOURCES`):
Whether Bundler should skip adding default git source shortcuts to the
Gemfile DSL.
* `specific_platform` (`BUNDLE_SPECIFIC_PLATFORM`):
Allow bundler to resolve for the specific running platform and store it in
the lockfile, instead of only using a generic platform.

Просмотреть файл

@ -141,17 +141,17 @@ RSpec.describe "bundle executable" do
describe "printing the outdated warning" do
shared_examples_for "no warning" do
it "prints no warning" do
bundle "fail"
bundle "fail", :env => { "BUNDLER_VERSION" => bundler_version }
expect(last_command.stdboth).to eq("Could not find command \"fail\".")
end
end
let(:bundler_version) { "1.1" }
let(:bundler_version) { "2.0" }
let(:latest_version) { nil }
before do
bundle! "config set --global disable_version_check false"
system_gems "bundler-#{bundler_version}"
pristine_system_gems "bundler-#{bundler_version}"
if latest_version
info_path = home(".bundle/cache/compact_index/rubygems.org.443.29b0360b937aa4d161703e6160654e47/info/bundler")
info_path.parent.mkpath
@ -176,7 +176,7 @@ RSpec.describe "bundle executable" do
context "when the latest version is greater than the current version" do
let(:latest_version) { "222.0" }
it "prints the version warning" do
bundle "fail", :system_bundler => true, :env => { "BUNDLER_SPEC_IGNORE_DEFAULT_BUNDLER_GEM" => "true" }
bundle "fail", :env => { "BUNDLER_VERSION" => bundler_version }
expect(err).to start_with(<<-EOS.strip)
The latest bundler is #{latest_version}, but you are currently running #{bundler_version}.
To install the latest version, run `gem install bundler`
@ -184,16 +184,16 @@ To install the latest version, run `gem install bundler`
end
context "and disable_version_check is set" do
before { bundle! "config set disable_version_check true" }
before { bundle! "config set disable_version_check true", :env => { "BUNDLER_VERSION" => bundler_version } }
include_examples "no warning"
end
context "running a parseable command" do
it "prints no warning" do
bundle! "config get --parseable foo"
bundle! "config get --parseable foo", :env => { "BUNDLER_VERSION" => bundler_version }
expect(last_command.stdboth).to eq ""
bundle "platform --ruby"
bundle "platform --ruby", :env => { "BUNDLER_VERSION" => bundler_version }
expect(last_command.stdboth).to eq "Could not locate Gemfile"
end
end
@ -201,7 +201,7 @@ To install the latest version, run `gem install bundler`
context "and is a pre-release" do
let(:latest_version) { "222.0.0.pre.4" }
it "prints the version warning" do
bundle "fail", :system_bundler => true, :env => { "BUNDLER_SPEC_IGNORE_DEFAULT_BUNDLER_GEM" => "true" }
bundle "fail", :env => { "BUNDLER_VERSION" => bundler_version }
expect(err).to start_with(<<-EOS.strip)
The latest bundler is #{latest_version}, but you are currently running #{bundler_version}.
To install the latest version, run `gem install bundler --pre`

Просмотреть файл

@ -63,16 +63,16 @@ RSpec.describe Bundler::Dsl do
end
end
context "default git sources", :bundler => "3" do
it "has none" do
expect(subject.instance_variable_get(:@git_sources)).to eq({})
context "default git sources" do
it "has bitbucket, gist, and github" do
expect(subject.instance_variable_get(:@git_sources).keys.sort).to eq(%w[bitbucket gist github])
end
end
end
describe "#method_missing" do
it "raises an error for unknown DSL methods" do
expect(Bundler).to receive(:read_file).with(root.join("Gemfile").to_s).
expect(Bundler).to receive(:read_file).with(source_root.join("Gemfile").to_s).
and_return("unknown")
error_msg = "There was an error parsing `Gemfile`: Undefined local variable or method `unknown' for Gemfile. Bundler cannot continue."
@ -83,13 +83,13 @@ RSpec.describe Bundler::Dsl do
describe "#eval_gemfile" do
it "handles syntax errors with a useful message" do
expect(Bundler).to receive(:read_file).with(root.join("Gemfile").to_s).and_return("}")
expect(Bundler).to receive(:read_file).with(source_root.join("Gemfile").to_s).and_return("}")
expect { subject.eval_gemfile("Gemfile") }.
to raise_error(Bundler::GemfileError, /There was an error parsing `Gemfile`: (syntax error, unexpected tSTRING_DEND|(compile error - )?syntax error, unexpected '\}'). Bundler cannot continue./)
end
it "distinguishes syntax errors from evaluation errors" do
expect(Bundler).to receive(:read_file).with(root.join("Gemfile").to_s).and_return(
expect(Bundler).to receive(:read_file).with(source_root.join("Gemfile").to_s).and_return(
"ruby '2.1.5', :engine => 'ruby', :engine_version => '1.2.4'"
)
expect { subject.eval_gemfile("Gemfile") }.
@ -208,7 +208,7 @@ RSpec.describe Bundler::Dsl do
end
end
describe "#github", :bundler => "2" do
describe "#github" do
it "from github" do
spree_gems = %w[spree_core spree_api spree_backend]
subject.github "spree" do
@ -220,17 +220,6 @@ RSpec.describe Bundler::Dsl do
end
end
end
describe "#github", :bundler => "3" do
it "from github" do
expect do
spree_gems = %w[spree_core spree_api spree_backend]
subject.github "spree" do
spree_gems.each {|spree_gem| subject.send :gem, spree_gem }
end
end.to raise_error(Bundler::DeprecatedError, /github method has been removed/)
end
end
end
describe "syntax errors" do

Просмотреть файл

@ -215,7 +215,7 @@ RSpec.describe Bundler, "friendly errors" do
it "generates a search URL for the exception message" do
exception = Exception.new("Exception message")
expect(Bundler::FriendlyErrors.issues_url(exception)).to eq("https://github.com/rubygems/bundler/search?q=Exception+message&type=Issues")
expect(Bundler::FriendlyErrors.issues_url(exception)).to eq("https://github.com/rubygems/rubygems/search?q=Exception+message&type=Issues")
end
it "generates a search URL for only the first line of a multi-line exception message" do
@ -224,7 +224,7 @@ First line of the exception message
Second line of the exception message
END
expect(Bundler::FriendlyErrors.issues_url(exception)).to eq("https://github.com/rubygems/bundler/search?q=First+line+of+the+exception+message&type=Issues")
expect(Bundler::FriendlyErrors.issues_url(exception)).to eq("https://github.com/rubygems/rubygems/search?q=First+line+of+the+exception+message&type=Issues")
end
it "generates the url without colons" do
@ -233,7 +233,7 @@ Exception ::: with ::: colons :::
END
issues_url = Bundler::FriendlyErrors.issues_url(exception)
expect(issues_url).not_to include("%3A")
expect(issues_url).to eq("https://github.com/rubygems/bundler/search?q=#{CGI.escape("Exception with colons ")}&type=Issues")
expect(issues_url).to eq("https://github.com/rubygems/rubygems/search?q=#{CGI.escape("Exception with colons ")}&type=Issues")
end
it "removes information after - for Errono::EACCES" do
@ -243,7 +243,7 @@ END
allow(exception).to receive(:is_a?).with(Errno).and_return(true)
issues_url = Bundler::FriendlyErrors.issues_url(exception)
expect(issues_url).not_to include("/Users/foo/bar")
expect(issues_url).to eq("https://github.com/rubygems/bundler/search?q=#{CGI.escape("Errno EACCES Permission denied @ dir_s_mkdir ")}&type=Issues")
expect(issues_url).to eq("https://github.com/rubygems/rubygems/search?q=#{CGI.escape("Errno EACCES Permission denied @ dir_s_mkdir ")}&type=Issues")
end
end
end

Просмотреть файл

@ -163,7 +163,7 @@ RSpec.describe Bundler::SharedHelpers do
let(:pwd_stub) { nil }
it "returns the current absolute path" do
expect(subject.pwd).to eq(root)
expect(subject.pwd).to eq(source_root)
end
end
@ -242,7 +242,7 @@ RSpec.describe Bundler::SharedHelpers do
shared_examples_for "ENV['RUBYOPT'] gets set correctly" do
it "ensures -rbundler/setup is at the beginning of ENV['RUBYOPT']" do
subject.set_bundle_environment
expect(ENV["RUBYOPT"].split(" ")).to start_with("-r#{lib_dir}/bundler/setup")
expect(ENV["RUBYOPT"].split(" ")).to start_with("-r#{source_lib_dir}/bundler/setup")
end
end

Просмотреть файл

@ -1,15 +1,13 @@
# frozen_string_literal: true
RSpec.describe Bundler::StubSpecification do
let(:gemspec) do
Gem::Specification.new do |s|
let(:with_bundler_stub_spec) do
gemspec = Gem::Specification.new do |s|
s.name = "gemname"
s.version = "1.0.0"
s.loaded_from = __FILE__
end
end
let(:with_bundler_stub_spec) do
described_class.from_stub(gemspec)
end

Просмотреть файл

@ -98,7 +98,7 @@ RSpec.describe "bundle binstubs <gem>" do
context "the bundle binstub" do
before do
system_gems "bundler-#{system_bundler_version}"
pristine_system_gems "bundler-#{system_bundler_version}"
build_repo2 do
build_gem "prints_loaded_gems", "1.0" do |s|
s.executables = "print_loaded_gems"

Просмотреть файл

@ -765,7 +765,7 @@ RSpec.describe "bundle clean" do
should_not_have_gems "foo-1.0"
end
it "doesn't remove extensions artifacts from bundled git gems after clean", :ruby_repo do
it "doesn't remove extensions artifacts from bundled git gems after clean" do
build_git "very_simple_git_binary", &:add_c_extension
revision = revision_for(lib_path("very_simple_git_binary-1.0"))
@ -788,7 +788,7 @@ RSpec.describe "bundle clean" do
expect(vendored_gems("bundler/gems/very_simple_git_binary-1.0-#{revision[0..11]}")).to exist
end
it "removes extension directories", :ruby_repo do
it "removes extension directories" do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
@ -824,7 +824,7 @@ RSpec.describe "bundle clean" do
expect(simple_binary_extensions_dir).to exist
end
it "removes git extension directories", :ruby_repo do
it "removes git extension directories" do
build_git "very_simple_git_binary", &:add_c_extension
revision = revision_for(lib_path("very_simple_git_binary-1.0"))

Просмотреть файл

@ -6,7 +6,7 @@ RSpec.describe "bundle exec" do
system_gems(system_gems_to_install, :path => default_bundle_path)
end
it "works with --gemfile flag", :ruby_repo do
it "works with --gemfile flag" do
create_file "CustomGemfile", <<-G
gem "rack", "1.0.0"
G
@ -15,7 +15,7 @@ RSpec.describe "bundle exec" do
expect(out).to eq("1.0.0")
end
it "activates the correct gem", :ruby_repo do
it "activates the correct gem" do
gemfile <<-G
gem "rack", "0.9.1"
G
@ -24,7 +24,7 @@ RSpec.describe "bundle exec" do
expect(out).to eq("0.9.1")
end
it "works when the bins are in ~/.bundle", :ruby_repo do
it "works when the bins are in ~/.bundle" do
install_gemfile <<-G
gem "rack"
G
@ -33,7 +33,7 @@ RSpec.describe "bundle exec" do
expect(out).to eq("1.0.0")
end
it "works when running from a random directory", :ruby_repo do
it "works when running from a random directory" do
install_gemfile <<-G
gem "rack"
G
@ -269,7 +269,7 @@ RSpec.describe "bundle exec" do
)
end
it "handles gems installed with --without", :ruby_repo do
it "handles gems installed with --without" do
install_gemfile <<-G, forgotten_command_line_options(:without => "middleware")
source "#{file_uri_for(gem_repo1)}"
gem "rack" # rack 0.9.1 and 1.0 exist
@ -353,7 +353,7 @@ RSpec.describe "bundle exec" do
expect(err).to include("bundler: exec needs a command to run")
end
it "raises a helpful error when exec'ing to something outside of the bundle", :ruby_repo do
it "raises a helpful error when exec'ing to something outside of the bundle" do
bundle! "config set clean false" # want to keep the rackup binstub
install_gemfile! <<-G
source "#{file_uri_for(gem_repo1)}"
@ -457,7 +457,7 @@ RSpec.describe "bundle exec" do
end
describe "with gem executables" do
describe "run from a random directory", :ruby_repo do
describe "run from a random directory" do
before(:each) do
install_gemfile <<-G
gem "rack"
@ -598,8 +598,9 @@ RSpec.describe "bundle exec" do
end
Bundler.rubygems.extend(Monkey)
G
bundle "install --deployment"
bundle "exec ruby -e '`#{bindir.join("bundler")} -v`; puts $?.success?'"
bundle! "config set path.system true"
bundle! "install"
bundle "exec ruby -e '`bundle -v`; puts $?.success?'", :env => { "BUNDLER_VERSION" => Bundler::VERSION }
expect(out).to match("true")
end
end
@ -881,7 +882,7 @@ __FILE__: #{path.to_s.inspect}
puts `bundle exec echo foo`
RUBY
file.chmod(0o777)
bundle! "exec #{file}"
bundle! "exec #{file}", :env => { "PATH" => path }
expect(out).to eq("foo")
end
end
@ -904,7 +905,7 @@ __FILE__: #{path.to_s.inspect}
end
end
system_gems(:bundler, "openssl-#{openssl_version}", :gem_repo => gem_repo4)
system_gems("openssl-#{openssl_version}", :gem_repo => gem_repo4)
file = bundled_app("require_openssl.rb")
create_file(file, <<-RUBY)
@ -915,15 +916,17 @@ __FILE__: #{path.to_s.inspect}
RUBY
file.chmod(0o777)
env = { "PATH" => path }
aggregate_failures do
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)
expect(run!(file.read, :artifice => nil)).to eq(expected)
expect(bundle!("exec #{file}", :artifice => nil, :env => env)).to eq(expected)
expect(bundle!("exec bundle exec #{file}", :artifice => nil, :env => env)).to eq(expected)
expect(bundle!("exec ruby #{file}", :artifice => nil, :env => env)).to eq(expected)
expect(run!(file.read, :artifice => nil, :env => env)).to eq(expected)
end
skip "ruby_core has openssl and rubygems in the same folder, and this test needs rubygems require but default openssl not in a directly added entry in $LOAD_PATH" if ruby_core?
# sanity check that we get the newer, custom version without bundler
sys_exec("#{Gem.ruby} #{file}")
sys_exec("#{Gem.ruby} #{file}", :env => env)
expect(err).to include("custom openssl should not be loaded")
end
end

Просмотреть файл

@ -41,7 +41,7 @@ RSpec.describe "bundle info" do
expect(err).to eq("Could not find gem 'missing'.")
end
context "given a default gem shippped in ruby", :ruby_repo do
context "given a default gem shippped in ruby" do
it "prints information about the default gem" do
bundle! "info rdoc"
expect(out).to include("* rdoc")

Просмотреть файл

@ -246,7 +246,7 @@ RSpec.describe "bundle gem" do
end
end
it "generates a valid gemspec", :readline, :ruby_repo do
it "generates a valid gemspec", :readline do
bundle! "gem newgem --bin"
prepare_gemspec(bundled_app("newgem", "newgem.gemspec"))

Просмотреть файл

@ -2,7 +2,7 @@
require "bundler/vendored_fileutils"
RSpec.describe "bundle pristine", :ruby_repo do
RSpec.describe "bundle pristine" do
before :each do
build_lib "baz", :path => bundled_app do |s|
s.version = "1.0.0"
@ -34,7 +34,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
context "when sourced from RubyGems" do
it "reverts using cached .gem file" do
spec = Bundler.definition.specs["weakling"].first
spec = find_spec("weakling")
changes_txt = Pathname.new(spec.full_gem_path).join("lib/changes.txt")
FileUtils.touch(changes_txt)
@ -45,10 +45,9 @@ RSpec.describe "bundle pristine", :ruby_repo do
end
it "does not delete the bundler gem" do
system_gems :bundler
bundle! "install"
bundle! "pristine", :system_bundler => true
bundle! "-v", :system_bundler => true
bundle! "pristine"
bundle! "-v"
expected = if Bundler::VERSION < "3.0"
"Bundler version"
@ -62,7 +61,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
context "when sourced from git repo" do
it "reverts by resetting to current revision`" do
spec = Bundler.definition.specs["foo"].first
spec = find_spec("foo")
changed_file = Pathname.new(spec.full_gem_path).join("lib/foo.rb")
diff = "#Pristine spec changes"
@ -74,7 +73,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
end
it "removes added files" do
spec = Bundler.definition.specs["foo"].first
spec = find_spec("foo")
changes_txt = Pathname.new(spec.full_gem_path).join("lib/changes.txt")
FileUtils.touch(changes_txt)
@ -85,7 +84,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
end
it "displays warning and ignores changes when a local config exists" do
spec = Bundler.definition.specs["foo"].first
spec = find_spec("foo")
bundle "config set local.#{spec.name} #{lib_path(spec.name)}"
changes_txt = Pathname.new(spec.full_gem_path).join("lib/changes.txt")
@ -100,7 +99,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
context "when sourced from gemspec" do
it "displays warning and ignores changes when sourced from gemspec" do
spec = Bundler.definition.specs["baz"].first
spec = find_spec("baz")
changed_file = Pathname.new(spec.full_gem_path).join("lib/baz.rb")
diff = "#Pristine spec changes"
@ -113,7 +112,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
end
it "reinstall gemspec dependency" do
spec = Bundler.definition.specs["baz-dev"].first
spec = find_spec("baz-dev")
changed_file = Pathname.new(spec.full_gem_path).join("lib/baz/dev.rb")
diff = "#Pristine spec changes"
@ -127,7 +126,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
context "when sourced from path" do
it "displays warning and ignores changes when sourced from local path" do
spec = Bundler.definition.specs["bar"].first
spec = find_spec("bar")
changes_txt = Pathname.new(spec.full_gem_path).join("lib/changes.txt")
FileUtils.touch(changes_txt)
expect(changes_txt).to be_file
@ -139,17 +138,17 @@ RSpec.describe "bundle pristine", :ruby_repo do
context "when passing a list of gems to pristine" do
it "resets them" do
foo = Bundler.definition.specs["foo"].first
foo = find_spec("foo")
foo_changes_txt = Pathname.new(foo.full_gem_path).join("lib/changes.txt")
FileUtils.touch(foo_changes_txt)
expect(foo_changes_txt).to be_file
bar = Bundler.definition.specs["bar"].first
bar = find_spec("bar")
bar_changes_txt = Pathname.new(bar.full_gem_path).join("lib/changes.txt")
FileUtils.touch(bar_changes_txt)
expect(bar_changes_txt).to be_file
weakling = Bundler.definition.specs["weakling"].first
weakling = find_spec("weakling")
weakling_changes_txt = Pathname.new(weakling.full_gem_path).join("lib/changes.txt")
FileUtils.touch(weakling_changes_txt)
expect(weakling_changes_txt).to be_file
@ -171,7 +170,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
end
context "when a build config exists for one of the gems" do
let(:very_simple_binary) { Bundler.definition.specs["very_simple_binary"].first }
let(:very_simple_binary) { find_spec("very_simple_binary") }
let(:c_ext_dir) { Pathname.new(very_simple_binary.full_gem_path).join("ext") }
let(:build_opt) { "--with-ext-lib=#{c_ext_dir}" }
before { bundle "config set build.very_simple_binary -- #{build_opt}" }
@ -188,7 +187,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
end
context "when a build config exists for a git sourced gem" do
let(:git_with_ext) { Bundler.definition.specs["git_with_ext"].first }
let(:git_with_ext) { find_spec("git_with_ext") }
let(:c_ext_dir) { Pathname.new(git_with_ext.full_gem_path).join("ext") }
let(:build_opt) { "--with-ext-lib=#{c_ext_dir}" }
before { bundle "config set build.git_with_ext -- #{build_opt}" }
@ -203,4 +202,10 @@ RSpec.describe "bundle pristine", :ruby_repo do
expect(makefile_contents).to match(/LIBPATH =.*-L#{c_ext_dir}/)
end
end
def find_spec(name)
without_env_side_effects do
Bundler.definition.specs[name].first
end
end
end

Просмотреть файл

@ -964,7 +964,7 @@ RSpec.describe "bundle update conservative" do
isolated_owner
BUNDLED WITH
1.13.0
#{Bundler::VERSION}
L
end

Просмотреть файл

@ -1,13 +1,10 @@
# frozen_string_literal: true
RSpec.describe "bundle viz", :bundler => "< 3", :if => Bundler.which("dot") do
let(:ruby_graphviz) do
graphviz_glob = base_system_gems.join("cache/ruby-graphviz*")
Pathname.glob(graphviz_glob).first
end
before do
system_gems ruby_graphviz
graphviz_version = RUBY_VERSION >= "2.4" ? "1.2.5" : "1.2.4"
realworld_system_gems "ruby-graphviz --version #{graphviz_version}"
end
it "graphs gems from the Gemfile" do
@ -82,7 +79,7 @@ RSpec.describe "bundle viz", :bundler => "< 3", :if => Bundler.which("dot") do
end
end
system_gems ruby_graphviz, "graphviz-999", :gem_repo => gem_repo4
system_gems "graphviz-999", :gem_repo => gem_repo4
end
it "loads the correct ruby-graphviz gem" do

Просмотреть файл

@ -136,12 +136,12 @@ RSpec.describe "bundle install" do
system_gems "bundler-99999999.99.1"
install_gemfile! <<-G, :system_bundler => true
install_gemfile! <<-G
source "#{file_uri_for(gem_repo2)}"
gem "rails", "3.0"
G
bundle! "check", :system_bundler => true
bundle! "check"
expect(out).to include("The Gemfile's dependencies are satisfied")
end
@ -150,12 +150,12 @@ RSpec.describe "bundle install" do
system_gems "bundler-99999999.99.1"
install_gemfile! <<-G, :system_bundler => true
install_gemfile! <<-G
source "#{file_uri_for(gem_repo2)}"
gem "rails", "3.0"
G
bundle! "check", :system_bundler => true
bundle! "check"
expect(out).to include("The Gemfile's dependencies are satisfied")
end

Просмотреть файл

@ -68,7 +68,7 @@ RSpec.describe "install with --deployment or --frozen" do
bundle! :install
bundle "install --deployment"
bundle! "exec bundle check"
bundle! "exec bundle check", :env => { "PATH" => path }
end
it "works when using path gems from the same path and the version is specified" do

Просмотреть файл

@ -172,7 +172,7 @@ RSpec.describe "bundle install from an existing gemspec" do
s.add_dependency "platform_specific"
end
system_gems "platform_specific-1.0-java", :path => default_bundle_path, :keep_path => true
system_gems "platform_specific-1.0-java", :path => default_bundle_path
install_gemfile! <<-G
gemspec :path => '#{tmp.join("foo")}'
@ -420,6 +420,8 @@ RSpec.describe "bundle install from an existing gemspec" do
end
end
bundle "config specific_platform false"
%w[ruby jruby].each do |platform|
simulate_platform(platform) do
install_gemfile <<-G

Просмотреть файл

@ -1139,7 +1139,7 @@ RSpec.describe "bundle install with git sources" do
expect(out).to include(Pathname.glob(default_bundle_path("bundler/gems/extensions/**/foo-1.0-*")).first.to_s)
end
it "does not use old extension after ref changes", :ruby_repo do
it "does not use old extension after ref changes" do
git_reader = build_git "foo", :no_default => true do |s|
s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-RUBY

Просмотреть файл

@ -352,16 +352,17 @@ RSpec.describe "bundle install with groups" do
describe "when locked and installed with --without" do
before(:each) do
build_repo2
system_gems "rack-0.9.1" do
install_gemfile <<-G, forgotten_command_line_options(:without => "rack")
source "#{file_uri_for(gem_repo2)}"
gem "rack"
group :rack do
gem "rack_middleware"
end
G
end
system_gems "rack-0.9.1"
install_gemfile <<-G, forgotten_command_line_options(:without => "rack")
source "#{file_uri_for(gem_repo2)}"
gem "rack"
group :rack do
gem "rack_middleware"
end
G
end
it "uses the correct versions even if --without was used on the original" do

Просмотреть файл

@ -410,7 +410,7 @@ The checksum of /versions does not match the checksum provided by the server! So
api_request_limit = low_api_request_limit_for(gem_repo2)
install_gemfile! <<-G, :artifice => "compact_index_extra_missing", :env => { "BUNDLER_SPEC_API_REQUEST_LIMIT" => api_request_limit.to_s }
install_gemfile! <<-G, :artifice => "compact_index_extra_missing", :env => { "BUNDLER_SPEC_API_REQUEST_LIMIT" => api_request_limit.to_s }.merge(env_for_missing_prerelease_default_gem_activation)
source "#{source_uri}"
source "#{source_uri}/extra" do
gem "back_deps"
@ -432,7 +432,7 @@ The checksum of /versions does not match the checksum provided by the server! So
api_request_limit = low_api_request_limit_for(gem_repo4)
install_gemfile! <<-G, :artifice => "compact_index_extra_api_missing", :env => { "BUNDLER_SPEC_API_REQUEST_LIMIT" => api_request_limit.to_s }
install_gemfile! <<-G, :artifice => "compact_index_extra_api_missing", :env => { "BUNDLER_SPEC_API_REQUEST_LIMIT" => api_request_limit.to_s }.merge(env_for_missing_prerelease_default_gem_activation)
source "#{source_uri}"
source "#{source_uri}/extra" do
gem "back_deps"

Просмотреть файл

@ -384,7 +384,7 @@ RSpec.describe "gemcutter's dependency API" do
api_request_limit = low_api_request_limit_for(gem_repo2)
install_gemfile! <<-G, :artifice => "endpoint_extra_missing", :env => { "BUNDLER_SPEC_API_REQUEST_LIMIT" => api_request_limit.to_s }
install_gemfile! <<-G, :artifice => "endpoint_extra_missing", :env => { "BUNDLER_SPEC_API_REQUEST_LIMIT" => api_request_limit.to_s }.merge(env_for_missing_prerelease_default_gem_activation)
source "#{source_uri}"
source "#{source_uri}/extra"
gem "back_deps"
@ -405,7 +405,7 @@ RSpec.describe "gemcutter's dependency API" do
api_request_limit = low_api_request_limit_for(gem_repo2)
install_gemfile! <<-G, :artifice => "endpoint_extra_missing", :env => { "BUNDLER_SPEC_API_REQUEST_LIMIT" => api_request_limit.to_s }
install_gemfile! <<-G, :artifice => "endpoint_extra_missing", :env => { "BUNDLER_SPEC_API_REQUEST_LIMIT" => api_request_limit.to_s }.merge(env_for_missing_prerelease_default_gem_activation)
source "#{source_uri}"
source "#{source_uri}/extra" do
gem "back_deps"

Просмотреть файл

@ -1,6 +1,6 @@
# frozen_string_literal: true
RSpec.describe "installing a gem with native extensions", :ruby_repo do
RSpec.describe "installing a gem with native extensions" do
it "installs" do
build_repo2 do
build_gem "c_extension" do |s|

Просмотреть файл

@ -21,7 +21,7 @@ RSpec.shared_examples "bundle install --standalone" do
testrb << "\nrequire \"#{k}\""
testrb << "\nputs #{k.upcase}"
end
ruby testrb, :no_lib => true
ruby testrb
expect(out).to eq(expected_gems.values.join("\n"))
end
@ -43,7 +43,7 @@ RSpec.shared_examples "bundle install --standalone" do
testrb << "\nrequire \"#{k}\""
testrb << "\nputs #{k.upcase}"
end
ruby testrb, :no_lib => true, :dir => "#{bundled_app}2"
ruby testrb, :dir => "#{bundled_app}2"
expect(out).to eq(expected_gems.values.join("\n"))
end
@ -68,7 +68,7 @@ RSpec.shared_examples "bundle install --standalone" do
include_examples "common functionality"
end
describe "with gems with native extension", :ruby_repo do
describe "with gems with native extension" do
before do
install_gemfile <<-G, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true, :dir => cwd)
source "#{file_uri_for(gem_repo1)}"
@ -165,7 +165,7 @@ RSpec.shared_examples "bundle install --standalone" do
it "allows creating a standalone file with limited groups" do
bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => "default", :dir => cwd)
load_error_ruby <<-RUBY, "spec", :no_lib => true
load_error_ruby <<-RUBY, "spec"
$:.unshift File.expand_path("bundle")
require "bundler/setup"
@ -181,7 +181,7 @@ RSpec.shared_examples "bundle install --standalone" do
it "allows --without to limit the groups used in a standalone" do
bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle"), :without => "test").merge(:standalone => true, :dir => cwd)
load_error_ruby <<-RUBY, "spec", :no_lib => true
load_error_ruby <<-RUBY, "spec"
$:.unshift File.expand_path("bundle")
require "bundler/setup"
@ -197,7 +197,7 @@ RSpec.shared_examples "bundle install --standalone" do
it "allows --path to change the location of the standalone bundle" do
bundle! "install", forgotten_command_line_options(:path => "path/to/bundle").merge(:standalone => true, :dir => cwd)
ruby <<-RUBY, :no_lib => true
ruby <<-RUBY
$:.unshift File.expand_path("path/to/bundle")
require "bundler/setup"
@ -212,7 +212,7 @@ RSpec.shared_examples "bundle install --standalone" do
bundle! :install, forgotten_command_line_options(:without => "test").merge(:dir => cwd)
bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true, :dir => cwd)
load_error_ruby <<-RUBY, "spec", :no_lib => true
load_error_ruby <<-RUBY, "spec"
$:.unshift File.expand_path("bundle")
require "bundler/setup"

Просмотреть файл

@ -145,6 +145,8 @@ RSpec.describe "when using sudo", :sudo => true do
sudo "mkdir -p #{gem_home}"
sudo "chmod ugo-w #{gem_home}"
system_gems :bundler, :path => gem_home
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack", '1.0'

Просмотреть файл

@ -44,7 +44,7 @@ RSpec.describe "global gem caching" do
gem "rack"
G
FileUtils.rm_r(default_bundle_path)
simulate_new_machine
expect(the_bundle).not_to include_gems "rack 1.0.0"
expect(source_global_cache("rack-1.0.0.gem")).to exist
# rack 1.0.0 is not installed and it is in the global cache
@ -54,7 +54,7 @@ RSpec.describe "global gem caching" do
gem "rack", "0.9.1"
G
FileUtils.rm_r(default_bundle_path)
simulate_new_machine
expect(the_bundle).not_to include_gems "rack 0.9.1"
expect(source2_global_cache("rack-0.9.1.gem")).to exist
# rack 0.9.1 is not installed and it is in the global cache
@ -68,7 +68,7 @@ RSpec.describe "global gem caching" do
# rack 1.0.0 is installed and rack 0.9.1 is not
expect(the_bundle).to include_gems "rack 1.0.0"
expect(the_bundle).not_to include_gems "rack 0.9.1"
FileUtils.rm_r(default_bundle_path)
simulate_new_machine
gemfile <<-G
source "#{source2}"
@ -88,7 +88,7 @@ RSpec.describe "global gem caching" do
G
bundle! :install, :artifice => "compact_index"
FileUtils.rm_r(default_bundle_path)
simulate_new_machine
expect(the_bundle).not_to include_gems "rack 1.0.0"
expect(source_global_cache("rack-1.0.0.gem")).to exist
# rack 1.0.0 is not installed and it is in the global cache
@ -99,7 +99,7 @@ RSpec.describe "global gem caching" do
G
bundle! :install, :artifice => "compact_index"
FileUtils.rm_r(default_bundle_path)
simulate_new_machine
expect(the_bundle).not_to include_gems "rack 0.9.1"
expect(source2_global_cache("rack-0.9.1.gem")).to exist
# rack 0.9.1 is not installed and it is in the global cache
@ -145,7 +145,7 @@ RSpec.describe "global gem caching" do
expect(the_bundle).to include_gems "activesupport 2.3.5"
expect(source_global_cache("rack-1.0.0.gem")).to exist
expect(source_global_cache("activesupport-2.3.5.gem")).to exist
FileUtils.rm_r(default_bundle_path)
simulate_new_machine
# Both gems are now only in the global cache
expect(the_bundle).not_to include_gems "rack 1.0.0"
expect(the_bundle).not_to include_gems "activesupport 2.3.5"
@ -185,7 +185,7 @@ RSpec.describe "global gem caching" do
end
end
describe "extension caching", :ruby_repo do
describe "extension caching" do
it "works" do
skip "gets incorrect ref in path" if Gem.win_platform?

Просмотреть файл

@ -162,7 +162,7 @@ RSpec.describe "bundle install" do
expect(the_bundle).to include_gems "rack 1.0.0"
end
it "re-installs gems whose extensions have been deleted", :ruby_repo do
it "re-installs gems whose extensions have been deleted" do
build_lib "very_simple_binary", "1.0.0", :to_system => true do |s|
s.write "lib/very_simple_binary.rb", "raise 'FAIL'"
end

Просмотреть файл

@ -28,6 +28,8 @@ RSpec.describe "the lockfile format" do
end
it "updates the lockfile's bundler version if current ver. is newer" do
system_gems "bundler-1.8.2"
lockfile <<-L
GIT
remote: git://github.com/nex3/haml.git
@ -50,7 +52,7 @@ RSpec.describe "the lockfile format" do
1.8.2
L
install_gemfile <<-G
install_gemfile <<-G, :env => { "BUNDLER_VERSION" => Bundler::VERSION }
source "#{file_uri_for(gem_repo1)}"
gem "rack"
@ -206,6 +208,8 @@ RSpec.describe "the lockfile format" do
current_version = Bundler::VERSION
older_major = previous_major(current_version)
system_gems "bundler-#{older_major}"
lockfile <<-L
GEM
remote: #{file_uri_for(gem_repo1)}/
@ -222,7 +226,7 @@ RSpec.describe "the lockfile format" do
#{older_major}
L
install_gemfile <<-G
install_gemfile <<-G, :env => { "BUNDLER_VERSION" => Bundler::VERSION }
source "#{file_uri_for(gem_repo1)}/"
gem "rack"

Просмотреть файл

@ -394,7 +394,7 @@ RSpec.describe "major deprecations" do
context "when `bundler/deployment` is required in a ruby script" do
before do
ruby(<<-RUBY)
ruby(<<-RUBY, :env => env_for_missing_prerelease_default_gem_activation)
require 'bundler/deployment'
RUBY
end
@ -416,25 +416,34 @@ RSpec.describe "major deprecations" do
end
context "with github gems" do
it "warns about removal", :bundler => "2" do
it "does not warn about removal", :bundler => "2" do
expect(Bundler.ui).not_to receive(:warn)
subject.gem("sparks", :github => "indirect/sparks")
github_uri = "https://github.com/indirect/sparks.git"
expect(subject.dependencies.first.source.uri).to eq(github_uri)
end
it "warns about removal", :bundler => "3" do
msg = <<-EOS
The :github git source is deprecated, and will be removed in the future. Change any "reponame" :github sources to "username/reponame". Add this code to the top of your Gemfile to ensure it continues to work:
git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" }
EOS
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg)
expect(Bundler.ui).to receive(:warn).with("[DEPRECATED] #{msg}")
subject.gem("sparks", :github => "indirect/sparks")
github_uri = "https://github.com/indirect/sparks.git"
expect(subject.dependencies.first.source.uri).to eq(github_uri)
end
pending "should fail with a helpful error", :bundler => "3"
end
context "with bitbucket gems" do
it "warns about removal", :bundler => "2" do
allow(Bundler.ui).to receive(:deprecate)
it "does not warn about removal", :bundler => "2" do
expect(Bundler.ui).not_to receive(:warn)
subject.gem("not-really-a-gem", :bitbucket => "mcorp/flatlab-rails")
end
it "warns about removal", :bundler => "3" do
msg = <<-EOS
The :bitbucket git source is deprecated, and will be removed in the future. Add this code to the top of your Gemfile to ensure it continues to work:
@ -445,27 +454,27 @@ The :bitbucket git source is deprecated, and will be removed in the future. Add
end
EOS
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg)
expect(Bundler.ui).to receive(:warn).with("[DEPRECATED] #{msg}")
subject.gem("not-really-a-gem", :bitbucket => "mcorp/flatlab-rails")
end
pending "should fail with a helpful error", :bundler => "3"
end
context "with gist gems" do
it "warns about removal", :bundler => "2" do
allow(Bundler.ui).to receive(:deprecate)
it "does not warn about removal", :bundler => "2" do
expect(Bundler.ui).not_to receive(:warn)
subject.gem("not-really-a-gem", :gist => "1234")
end
it "warns about removal", :bundler => "3" do
msg = <<-EOS
The :gist git source is deprecated, and will be removed in the future. Add this code to the top of your Gemfile to ensure it continues to work:
git_source(:gist) {|repo_name| "https://gist.github.com/\#{repo_name}.git" }
EOS
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg)
expect(Bundler.ui).to receive(:warn).with("[DEPRECATED] #{msg}")
subject.gem("not-really-a-gem", :gist => "1234")
end
pending "should fail with a helpful error", :bundler => "3"
end
end
@ -564,13 +573,9 @@ The :gist git source is deprecated, and will be removed in the future. Add this
end
context "bundle viz" do
let(:ruby_graphviz) do
graphviz_glob = base_system_gems.join("cache/ruby-graphviz*")
Pathname.glob(graphviz_glob).first
end
before do
system_gems ruby_graphviz
graphviz_version = RUBY_VERSION >= "2.4" ? "1.2.5" : "1.2.4"
realworld_system_gems "ruby-graphviz --version #{graphviz_version}"
create_file "gems.rb"
bundle "viz"
end

Просмотреть файл

@ -823,7 +823,7 @@ G
end
end
context "bundle exec", :ruby_repo do
context "bundle exec" do
before do
ENV["BUNDLER_FORCE_TTY"] = "true"
system_gems "rack-1.0.0", "rack-0.9.1", :path => default_bundle_path
@ -1051,7 +1051,7 @@ G
FileUtils.rm(bundled_app_lock)
ruby "require 'bundler/setup'"
ruby "require 'bundler/setup'", :env => { "BUNDLER_VERSION" => Bundler::VERSION }
expect(bundled_app_lock).not_to exist
should_be_ruby_version_incorrect
@ -1068,7 +1068,7 @@ G
FileUtils.rm(bundled_app_lock)
ruby "require 'bundler/setup'"
ruby "require 'bundler/setup'", :env => { "BUNDLER_VERSION" => Bundler::VERSION }
expect(bundled_app_lock).not_to exist
should_be_engine_incorrect
@ -1085,7 +1085,7 @@ G
FileUtils.rm(bundled_app_lock)
ruby "require 'bundler/setup'"
ruby "require 'bundler/setup'", :env => { "BUNDLER_VERSION" => Bundler::VERSION }
expect(bundled_app_lock).not_to exist
should_be_engine_version_incorrect
@ -1102,7 +1102,7 @@ G
FileUtils.rm(bundled_app_lock)
ruby "require 'bundler/setup'"
ruby "require 'bundler/setup'", :env => { "BUNDLER_VERSION" => Bundler::VERSION }
expect(bundled_app_lock).not_to exist
should_be_patchlevel_incorrect

Просмотреть файл

@ -242,7 +242,7 @@ RSpec.describe "bundler plugin install" do
end
RUBY
ruby code
ruby code, :env => { "BUNDLER_VERSION" => Bundler::VERSION }
expect(local_plugin_gem("foo-1.0", "plugins.rb")).to exist
end
end

Просмотреть файл

@ -218,7 +218,7 @@ RSpec.describe "The library itself" do
it "ships the correct set of files" do
git_list = shipped_files
gem_list = Gem::Specification.load(gemspec.to_s).files
gem_list = loaded_gemspec.files
expect(git_list.to_set).to eq(gem_list.to_set)
end
@ -233,7 +233,7 @@ RSpec.describe "The library itself" do
]
files_to_require = lib_tracked_files.grep(/\.rb$/) - exclusions
files_to_require.reject! {|f| f.start_with?("lib/bundler/vendor") }
files_to_require.map! {|f| File.expand_path(root.join("#{f}"), __dir__) }
files_to_require.map! {|f| File.expand_path(f, source_root) }
sys_exec!("ruby -w") do |input, _, _|
files_to_require.each do |f|
input.puts "require '#{f}'"

Просмотреть файл

@ -53,7 +53,7 @@ RSpec.describe "parallel", :realworld => true, :sometimes => true do
bundle :install, :standalone => true, :jobs => 4
ruby <<-RUBY, :no_lib => true
ruby <<-RUBY
$:.unshift File.expand_path("bundle")
require "bundler/setup"

Просмотреть файл

@ -89,10 +89,6 @@ RSpec.describe "Running bin/* commands" do
end
it "creates a bundle binstub" do
build_gem "bundler", Bundler::VERSION, :to_system => true do |s|
s.executables = "bundle"
end
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "bundler"

Просмотреть файл

@ -112,7 +112,7 @@ RSpec.describe "Bundler.setup" do
lp.map! {|p| p.sub(/^#{Regexp.union system_gem_path.to_s, default_bundle_path.to_s, lib_dir.to_s}/i, "") }
end
it "puts loaded gems after -I and RUBYLIB", :ruby_repo do
it "puts loaded gems after -I and RUBYLIB" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack"
@ -136,7 +136,7 @@ RSpec.describe "Bundler.setup" do
end
it "orders the load path correctly when there are dependencies" do
system_gems :bundler
bundle "config set path.system true"
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
@ -755,7 +755,7 @@ end
expect(out).to eq("yay")
end
it "should clean $LOAD_PATH properly", :ruby_repo do
it "should clean $LOAD_PATH properly" do
gem_name = "very_simple_binary"
full_gem_name = gem_name + "-1.0"
ext_dir = File.join(tmp("extensions", full_gem_name))
@ -802,7 +802,7 @@ end
Dir.mkdir(gems_dir)
Dir.mkdir(specifications_dir)
FileUtils.ln_s(root, File.join(gems_dir, full_name))
FileUtils.ln_s(source_root, File.join(gems_dir, full_name))
gemspec_content = File.binread(gemspec).
sub("Bundler::VERSION", %("#{Bundler::VERSION}")).
@ -816,9 +816,9 @@ end
it "should not remove itself from the LOAD_PATH and require a different copy of 'bundler/setup'" do
install_gemfile ""
ruby <<-R, :env => { "GEM_PATH" => symlinked_gem_home }, :no_lib => true
ruby <<-R, :env => { "GEM_PATH" => symlinked_gem_home }
TracePoint.trace(:class) do |tp|
if tp.path.include?("bundler") && !tp.path.start_with?("#{root}")
if tp.path.include?("bundler") && !tp.path.start_with?("#{source_root}")
puts "OMG. Defining a class from another bundler at \#{tp.path}:\#{tp.lineno}"
end
end
@ -1209,6 +1209,7 @@ end
%w[io-console openssl]
end << "bundler"
exempts << "fiddle" if Gem.win_platform? && Gem::Version.new(Gem::VERSION) >= Gem::Version.new("2.7")
exempts << "uri" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7")
exempts
end
@ -1273,19 +1274,42 @@ end
build_gem "net-http-pipeline", "1.0.1"
end
system_gems "net-http-pipeline-1.0.1", :gem_repo => gem_repo4 do
gemfile <<-G
source "#{file_uri_for(gem_repo4)}"
gem "net-http-pipeline", "1.0.1"
G
system_gems "net-http-pipeline-1.0.1", :gem_repo => gem_repo4
bundle "config set --local path vendor/bundle"
gemfile <<-G
source "#{file_uri_for(gem_repo4)}"
gem "net-http-pipeline", "1.0.1"
G
bundle! :install
bundle "config set --local path vendor/bundle"
bundle! :check
bundle! :install
expect(out).to eq("The Gemfile's dependencies are satisfied")
bundle! :check
expect(out).to eq("The Gemfile's dependencies are satisfied")
end
# bundler respects paths specified direclty in RUBYLIB or RUBYOPT, and
# that happens when running ruby from the ruby-core setup. To
# workaround, we manually remove those for these tests when they would
# override the default gem.
def load_path_exclusions_hack_for(name)
if ruby_core?
ext_folder = source_root.join(".ext/common")
require_name = name.tr("-", "/")
if File.exist?(ext_folder.join("#{require_name}.rb"))
{ :exclude_from_load_path => ext_folder.to_s }
else
lib_folder = source_root.join("lib")
if File.exist?(lib_folder.join("#{require_name}.rb"))
{ :exclude_from_load_path => lib_folder.to_s }
else
{}
end
end
else
{}
end
end
@ -1302,7 +1326,8 @@ end
gem "#{g}", "999999"
G
expect(the_bundle).to include_gem("#{g} 999999", :env => { "RUBYOPT" => activation_warning_hack_rubyopt })
opts = { :env => { "RUBYOPT" => activation_warning_hack_rubyopt } }
expect(the_bundle).to include_gem("#{g} 999999", opts.merge(load_path_exclusions_hack_for(g)))
end
it "activates older versions of #{g}" do
@ -1317,7 +1342,8 @@ end
gem "#{g}", "0.0.0.a"
G
expect(the_bundle).to include_gem("#{g} 0.0.0.a", :env => { "RUBYOPT" => activation_warning_hack_rubyopt })
opts = { :env => { "RUBYOPT" => activation_warning_hack_rubyopt } }
expect(the_bundle).to include_gem("#{g} 0.0.0.a", opts.merge(load_path_exclusions_hack_for(g)))
end
end
end

Просмотреть файл

@ -39,7 +39,7 @@ RSpec.describe "Bundler.with_env helpers" do
end
end
it "works with nested bundle exec invocations", :ruby_repo do
it "works with nested bundle exec invocations" do
create_file("exe.rb", <<-'RUBY')
count = ARGV.first.to_i
exit if count < 0
@ -61,7 +61,7 @@ RSpec.describe "Bundler.with_env helpers" do
EOS
end
it "removes variables that bundler added", :ruby_repo do
it "removes variables that bundler added" do
# Simulate bundler has not yet been loaded
ENV.replace(ENV.to_hash.delete_if {|k, _v| k.start_with?(Bundler::EnvironmentPreserver::BUNDLER_PREFIX) })
@ -89,11 +89,13 @@ RSpec.describe "Bundler.with_env helpers" do
print #{modified_env}['RUBYOPT']
RUBY
ENV["RUBYOPT"] = "-W2 -rbundler/setup #{ENV["RUBYOPT"]}"
bundle_exec_ruby! bundled_app("source.rb"), :env => { "BUNDLER_SPEC_DISABLE_DEFAULT_BUNDLER_GEM" => "true" }
simulate_bundler_version_when_missing_prerelease_default_gem_activation do
bundle_exec_ruby! bundled_app("source.rb")
end
expect(last_command.stdboth).not_to include("-rbundler/setup")
end
it "should restore RUBYLIB", :ruby_repo do
it "should restore RUBYLIB" do
create_file("source.rb", <<-RUBY)
print #{modified_env}['RUBYLIB']
RUBY
@ -202,7 +204,7 @@ RSpec.describe "Bundler.with_env helpers" do
RUBY
end
it "runs system inside with_clean_env", :ruby_repo do
it "runs system inside with_clean_env" do
run_bundler_script({ "BUNDLE_FOO" => "bar" }, bundled_app("source.rb"))
expect($?.exitstatus).to eq(42)
end
@ -217,7 +219,7 @@ RSpec.describe "Bundler.with_env helpers" do
RUBY
end
it "runs system inside with_unbundled_env", :ruby_repo do
it "runs system inside with_unbundled_env" do
run_bundler_script({ "BUNDLE_FOO" => "bar" }, bundled_app("source.rb"))
expect($?.exitstatus).to eq(42)
end

Просмотреть файл

@ -1,9 +1,5 @@
# frozen_string_literal: true
require_relative "support/path"
$:.unshift Spec::Path.lib_dir.to_s
require "bundler/psyched_yaml"
require "bundler/vendored_fileutils"
require "bundler/vendored_uri"
@ -61,8 +57,6 @@ RSpec.configure do |config|
config.bisect_runner = :shell
original_env = ENV.to_hash
config.expect_with :rspec do |c|
c.syntax = :expect
end
@ -90,39 +84,40 @@ RSpec.configure do |config|
# Don't wrap output in tests
ENV["THOR_COLUMNS"] = "10000"
original_env = ENV.to_hash
if ENV["RUBY"]
FileUtils.cp_r Spec::Path.bindir, File.join(Spec::Path.root, "lib", "exe")
end
extend(Spec::Helpers)
system_gems :bundler, :path => pristine_system_gem_path
end
config.before :all do
build_repo1
reset_paths!
end
config.around :each do |example|
ENV.replace(original_env)
reset!
system_gems []
begin
FileUtils.cp_r pristine_system_gem_path, system_gem_path
@command_executions = []
with_gem_path_as(system_gem_path) do
@command_executions = []
Bundler.ui.silence { example.run }
Bundler.ui.silence { example.run }
all_output = @command_executions.map(&:to_s_verbose).join("\n\n")
if example.exception && !all_output.empty?
warn all_output unless config.formatters.grep(RSpec::Core::Formatters::DocumentationFormatter).empty?
message = example.exception.message + "\n\nCommands:\n#{all_output}"
(class << example.exception; self; end).send(:define_method, :message) do
message
all_output = @command_executions.map(&:to_s_verbose).join("\n\n")
if example.exception && !all_output.empty?
warn all_output unless config.formatters.grep(RSpec::Core::Formatters::DocumentationFormatter).empty?
message = example.exception.message + "\n\nCommands:\n#{all_output}"
(class << example.exception; self; end).send(:define_method, :message) do
message
end
end
end
ensure
reset!
end
end
config.after :suite do
if ENV["RUBY"]
FileUtils.rm_rf File.join(Spec::Path.root, "lib", "exe")
end
FileUtils.rm_r Spec::Path.pristine_system_gem_path
end
end

Просмотреть файл

@ -2,11 +2,13 @@
require_relative "endpoint"
$LOAD_PATH.unshift Dir[base_system_gems.join("gems/compact_index*/lib")].first.to_s
$LOAD_PATH.unshift Dir[Spec::Path.base_system_gems.join("gems/compact_index*/lib")].first.to_s
require "compact_index"
class CompactIndexAPI < Endpoint
helpers do
include Spec::Path
def load_spec(name, version, platform, gem_repo)
full_name = "#{name}-#{version}"
full_name += "-#{platform}" if platform != "ruby"
@ -83,7 +85,7 @@ class CompactIndexAPI < Endpoint
nil
end
CompactIndex::GemVersion.new(spec.version.version, spec.platform.to_s, checksum, nil,
deps, spec.required_ruby_version, spec.required_rubygems_version)
deps, spec.required_ruby_version.to_s, spec.required_rubygems_version.to_s)
end
CompactIndex::Gem.new(name, gem_versions)
end

Просмотреть файл

@ -1,8 +1,6 @@
# frozen_string_literal: true
require_relative "../path"
require Spec::Path.lib_dir.join("bundler/deprecate")
include Spec::Path
$LOAD_PATH.unshift(*Dir[Spec::Path.base_system_gems.join("gems/{artifice,mustermann,rack,tilt,sinatra,ruby2_keywords}-*/lib")].map(&:to_s))
@ -41,28 +39,27 @@ class Endpoint < Sinatra::Base
end
helpers do
include Spec::Path
def dependencies_for(gem_names, gem_repo = GEM_REPO)
return [] if gem_names.nil? || gem_names.empty?
require "#{Spec::Path.lib_dir}/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)
end.inject(:+)
all_specs = %w[specs.4.8 prerelease_specs.4.8].map do |filename|
Marshal.load(File.open(gem_repo.join(filename)).read)
end.inject(:+)
all_specs.map do |name, version, platform|
spec = load_spec(name, version, platform, gem_repo)
next unless gem_names.include?(spec.name)
{
:name => spec.name,
:number => spec.version.version,
:platform => spec.platform.to_s,
:dependencies => spec.dependencies.select {|dep| dep.type == :runtime }.map do |dep|
[dep.name, dep.requirement.requirements.map {|a| a.join(" ") }.join(", ")]
end,
}
end.compact
end
all_specs.map do |name, version, platform|
spec = load_spec(name, version, platform, gem_repo)
next unless gem_names.include?(spec.name)
{
:name => spec.name,
:number => spec.version.version,
:platform => spec.platform.to_s,
:dependencies => spec.dependencies.select {|dep| dep.type == :runtime }.map do |dep|
[dep.name, dep.requirement.requirements.map {|a| a.join(" ") }.join(", ")]
end,
}
end.compact
end
def load_spec(name, version, platform, gem_repo)

Просмотреть файл

@ -1,7 +1,6 @@
# frozen_string_literal: true
require_relative "../path"
include Spec::Path
$LOAD_PATH.unshift(*Dir[Spec::Path.base_system_gems.join("gems/{artifice,mustermann,rack,tilt,sinatra,ruby2_keywords}-*/lib")].map(&:to_s))

Просмотреть файл

@ -1,7 +1,6 @@
# frozen_string_literal: true
require_relative "../path"
include Spec::Path
$LOAD_PATH.unshift(*Dir[Spec::Path.base_system_gems.join("gems/{artifice,mustermann,rack,tilt,sinatra,ruby2_keywords}-*/lib")].map(&:to_s))

Просмотреть файл

@ -758,9 +758,9 @@ module Spec
gem_path = File.expand_path("#{@spec.full_name}.gem", lib_path)
if opts[:to_system]
@context.system_gems gem_path, :keep_path => true
@context.system_gems gem_path
elsif opts[:to_bundle]
@context.system_gems gem_path, :path => @context.default_bundle_path, :keep_path => true
@context.system_gems gem_path, :path => @context.default_bundle_path
else
FileUtils.mv(gem_path, destination)
end

Просмотреть файл

@ -9,13 +9,25 @@ module Gem
Gem.ruby = ENV["RUBY"]
end
class Platform
@local = new(ENV["BUNDLER_SPEC_PLATFORM"]) if ENV["BUNDLER_SPEC_PLATFORM"]
if ENV["BUNDLER_SPEC_PLATFORM"]
class Platform
@local = new(ENV["BUNDLER_SPEC_PLATFORM"])
end
@platforms = [Gem::Platform::RUBY, Gem::Platform.local]
if ENV["BUNDLER_SPEC_PLATFORM"] == "ruby"
class << self
remove_method :finish_resolve
def finish_resolve
[]
end
end
end
end
@platforms = [Gem::Platform::RUBY, Gem::Platform.local]
# 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"]
if Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
@path_to_default_spec_map.delete_if do |_path, spec|
spec.name == "bundler"
end
@ -24,7 +36,7 @@ end
if ENV["BUNDLER_SPEC_WINDOWS"] == "true"
require_relative "path"
require "#{Spec::Path.lib_dir}/bundler/constants"
require "bundler/constants"
module Bundler
remove_const :WINDOWS if defined?(WINDOWS)
@ -34,8 +46,8 @@ end
if ENV["BUNDLER_SPEC_API_REQUEST_LIMIT"]
require_relative "path"
require "#{Spec::Path.lib_dir}/bundler/source"
require "#{Spec::Path.lib_dir}/bundler/source/rubygems"
require "bundler/source"
require "bundler/source/rubygems"
module Bundler
class Source

Просмотреть файл

@ -2,17 +2,25 @@
require_relative "command_execution"
require_relative "the_bundle"
require_relative "path"
module Spec
module Helpers
include Spec::Path
def reset!
Dir.glob("#{tmp}/{gems/*,*}", File::FNM_DOTMATCH).each do |dir|
next if %w[base remote1 gems rubygems . ..].include?(File.basename(dir))
next if %w[base base_system remote1 gems rubygems . ..].include?(File.basename(dir))
FileUtils.rm_rf(dir)
end
FileUtils.mkdir_p(home)
FileUtils.mkdir_p(tmpdir)
reset_paths!
end
def reset_paths!
Bundler.reset!
Gem.clear_paths
end
def self.bang(method)
@ -80,14 +88,10 @@ module Spec
with_sudo = options.delete(:sudo)
sudo = with_sudo == :preserve_env ? "sudo -E --preserve-env=RUBYOPT" : "sudo" if with_sudo
bundle_bin = options.delete("bundle_bin") || bindir.join("bundle")
if system_bundler = options.delete(:system_bundler)
bundle_bin = system_gem_path.join("bin/bundler")
end
bundle_bin = options.delete(:bundle_bin)
bundle_bin ||= installed_bindir.join("bundle")
env = options.delete(:env) || {}
env["PATH"].gsub!("#{Path.root}/exe", "") if env["PATH"] && system_bundler
requires = options.delete(:requires) || []
@ -103,7 +107,6 @@ module Spec
end
load_path = []
load_path << lib_dir unless system_bundler
load_path << spec_dir
dir = options.delete(:dir) || bundled_app
@ -145,12 +148,12 @@ module Spec
end
def bundler(cmd, options = {})
options["bundle_bin"] = bindir.join("bundler")
options[:bundle_bin] = system_gem_path.join("bin/bundler")
bundle(cmd, options)
end
def ruby(ruby, options = {})
ruby_cmd = build_ruby_cmd({ :load_path => options[:no_lib] ? [] : [lib_dir] })
ruby_cmd = build_ruby_cmd
escaped_ruby = RUBY_PLATFORM == "java" ? ruby.shellescape.dump : ruby.shellescape
sys_exec(%(#{ruby_cmd} -w -e #{escaped_ruby}), options)
end
@ -169,8 +172,8 @@ module Spec
def build_ruby_cmd(options = {})
sudo = options.delete(:sudo)
libs = options.delete(:load_path) || []
lib_option = "-I#{libs.join(File::PATH_SEPARATOR)}"
libs = options.delete(:load_path)
lib_option = libs ? "-I#{libs.join(File::PATH_SEPARATOR)}" : []
requires = options.delete(:requires) || []
requires << "#{Path.spec_dir}/support/hax.rb"
@ -180,12 +183,8 @@ module Spec
end
def gembin(cmd, options = {})
old = ENV["RUBYOPT"]
ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -I#{lib_dir}"
cmd = bundled_app("bin/#{cmd}") unless cmd.to_s.include?("/")
sys_exec(cmd.to_s, options)
ensure
ENV["RUBYOPT"] = old
end
def gem_command(command, options = {})
@ -328,14 +327,16 @@ module Spec
FileUtils.cp shipped_file, target_shipped_file, :preserve => true
end
# for Ruby core repository
if File.exist? File.join(build_path, "lib/bundler/bundler.gemspec")
FileUtils.mv File.join(build_path, "lib/bundler/bundler.gemspec"), build_path
end
replace_version_file(version, dir: build_path) # rubocop:disable Style/HashSyntax
gem_command! "build bundler.gemspec", :dir => build_path
build_metadata = {
:built_at => loaded_gemspec.date.utc.strftime("%Y-%m-%d"),
:git_commit_sha => sys_exec("git rev-parse --short HEAD", :dir => source_root).strip,
}
replace_build_metadata(build_metadata, dir: build_path) # rubocop:disable Style/HashSyntax
gem_command! "build #{relative_gemspec}", :dir => build_path
yield(bundler_path)
ensure
@ -344,19 +345,24 @@ module Spec
end
def with_gem_path_as(path)
backup = ENV.to_hash
ENV["GEM_HOME"] = path.to_s
ENV["GEM_PATH"] = path.to_s
ENV["BUNDLER_ORIG_GEM_PATH"] = nil
yield
ensure
ENV.replace(backup)
without_env_side_effects do
ENV["GEM_HOME"] = path.to_s
ENV["GEM_PATH"] = path.to_s
ENV["BUNDLER_ORIG_GEM_PATH"] = nil
yield
end
end
def with_path_as(path)
without_env_side_effects do
ENV["PATH"] = path.to_s
ENV["BUNDLER_ORIG_PATH"] = nil
yield
end
end
def without_env_side_effects
backup = ENV.to_hash
ENV["PATH"] = path.to_s
ENV["BUNDLER_ORIG_PATH"] = nil
yield
ensure
ENV.replace(backup)
@ -397,56 +403,29 @@ module Spec
with_path_added(tmp("fake_man")) { yield }
end
def pristine_system_gems(*gems)
FileUtils.rm_rf(system_gem_path)
system_gems(*gems)
end
def system_gems(*gems)
opts = gems.last.is_a?(Hash) ? gems.last : {}
path = opts.fetch(:path, system_gem_path)
gems = gems.flatten
unless opts[:keep_path]
FileUtils.rm_rf(path)
FileUtils.mkdir_p(path)
end
Gem.clear_paths
env_backup = ENV.to_hash
ENV["GEM_HOME"] = path.to_s
ENV["GEM_PATH"] = path.to_s
ENV["BUNDLER_ORIG_GEM_PATH"] = nil
install_gems(*gems)
return unless block_given?
begin
yield
ensure
ENV.replace(env_backup)
with_gem_path_as(path) do
install_gems(*gems)
end
end
def realworld_system_gems(*gems)
gems = gems.flatten
FileUtils.rm_rf(system_gem_path)
FileUtils.mkdir_p(system_gem_path)
Gem.clear_paths
gem_home = ENV["GEM_HOME"]
gem_path = ENV["GEM_PATH"]
path = ENV["PATH"]
ENV["GEM_HOME"] = system_gem_path.to_s
ENV["GEM_PATH"] = system_gem_path.to_s
gems.each do |gem|
gem_command! "install --no-document #{gem}"
end
return unless block_given?
begin
yield
ensure
ENV["GEM_HOME"] = gem_home
ENV["GEM_PATH"] = gem_path
ENV["PATH"] = path
with_gem_path_as(system_gem_path) do
gems.each do |gem|
gem_command! "install --no-document #{gem}"
end
end
end
@ -464,9 +443,8 @@ module Spec
end
def simulate_new_machine
system_gems []
FileUtils.rm_rf system_gem_path
FileUtils.rm_rf bundled_app(".bundle")
pristine_system_gems :bundler
end
def simulate_platform(platform)
@ -490,12 +468,34 @@ module Spec
old = ENV["BUNDLER_SPEC_WINDOWS"]
ENV["BUNDLER_SPEC_WINDOWS"] = "true"
simulate_platform platform do
yield
simulate_bundler_version_when_missing_prerelease_default_gem_activation do
yield
end
end
ensure
ENV["BUNDLER_SPEC_WINDOWS"] = old
end
# workaround for missing https://github.com/rubygems/rubygems/commit/929e92d752baad3a08f3ac92eaec162cb96aedd1
def simulate_bundler_version_when_missing_prerelease_default_gem_activation
return yield unless Gem.rubygems_version < Gem::Version.new("3.1.0.pre.1")
old = ENV["BUNDLER_VERSION"]
ENV["BUNDLER_VERSION"] = Bundler::VERSION
yield
ensure
ENV["BUNDLER_VERSION"] = old
end
# workaround for missing https://github.com/rubygems/rubygems/commit/929e92d752baad3a08f3ac92eaec162cb96aedd1
def env_for_missing_prerelease_default_gem_activation
if Gem.rubygems_version < Gem::Version.new("3.1.0.pre.1")
{ "BUNDLER_VERSION" => Bundler::VERSION }
else
{}
end
end
def revision_for(path)
sys_exec("git rev-parse HEAD", :dir => path).strip
end

Просмотреть файл

@ -115,13 +115,18 @@ module Spec
opts = names.last.is_a?(Hash) ? names.pop : {}
source = opts.delete(:source)
groups = Array(opts[:groups])
exclude_from_load_path = opts.delete(:exclude_from_load_path)
groups << opts
@errors = names.map do |name|
name, version, platform = name.split(/\s+/)
require_path = name == "bundler" ? "#{lib_dir}/bundler" : name.tr("-", "/")
version_const = name == "bundler" ? "Bundler::VERSION" : Spec::Builders.constantize(name)
begin
run! "require '#{require_path}.rb'; puts #{version_const}", *groups
code = []
code << "$LOAD_PATH.delete '#{exclude_from_load_path}'" if exclude_from_load_path
code << "require '#{require_path}.rb'"
code << "puts #{version_const}"
run! code.join("; "), *groups
rescue StandardError => e
next "#{name} is not installed:\n#{indent(e)}"
end

Просмотреть файл

@ -5,56 +5,82 @@ require "rbconfig"
module Spec
module Path
def source_root
@source_root ||= Pathname.new(ruby_core? ? "../../../.." : "../../..").expand_path(__FILE__)
end
def root
@root ||= Pathname.new(ruby_core? ? "../../../.." : "../../..").expand_path(__FILE__)
@root ||= system_gem_path("gems/bundler-#{Bundler::VERSION}")
end
def gemspec
@gemspec ||= root.join(ruby_core? ? "lib/bundler/bundler.gemspec" : "bundler.gemspec")
@gemspec ||= source_root.join(relative_gemspec)
end
def relative_gemspec
@relative_gemspec ||= ruby_core? ? "lib/bundler/bundler.gemspec" : "bundler.gemspec"
end
def gemspec_dir
@gemspec_dir ||= gemspec.parent
end
def loaded_gemspec
@loaded_gemspec ||= Gem::Specification.load(gemspec.to_s)
end
def test_gemfile
@test_gemfile ||= source_root.join(ruby_core? ? "tool/bundler/test_gems.rb" : "test_gems.rb")
end
def dev_gemfile
@dev_gemfile ||= source_root.join("dev_gems.rb")
end
def bindir
@bindir ||= root.join(ruby_core? ? "libexec" : "exe")
@bindir ||= source_root.join(ruby_core? ? "libexec" : "exe")
end
def installed_bindir
@installed_bindir ||= system_gem_path("bin")
end
def gem_cmd
@gem_cmd ||= ruby_core? ? root.join("bin/gem") : "gem"
@gem_cmd ||= ruby_core? ? source_root.join("bin/gem") : "gem"
end
def gem_bin
@gem_bin ||= ruby_core? ? ENV["GEM_COMMAND"] : "gem"
end
def path
env_path = ENV["PATH"]
env_path = env_path.split(File::PATH_SEPARATOR).reject {|path| path == bindir.to_s }.join(File::PATH_SEPARATOR) if ruby_core?
env_path
end
def spec_dir
@spec_dir ||= root.join(ruby_core? ? "spec/bundler" : "spec")
@spec_dir ||= source_root.join(ruby_core? ? "spec/bundler" : "spec")
end
def tracked_files
skip "not in git working directory" unless git_root_dir?
@tracked_files ||= sys_exec(ruby_core? ? "git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler man/bundler*" : "git ls-files -z", :dir => root).split("\x0")
@tracked_files ||= git_ls_files(tracked_files_glob)
end
def shipped_files
skip "not in git working directory" unless git_root_dir?
@shipped_files ||= sys_exec(ruby_core? ? "git ls-files -z -- lib/bundler lib/bundler.rb man/bundler* libexec/bundle*" : "git ls-files -z -- lib man exe CHANGELOG.md LICENSE.md README.md bundler.gemspec", :dir => root).split("\x0")
@shipped_files ||= git_ls_files(shipped_files_glob)
end
def lib_tracked_files
skip "not in git working directory" unless git_root_dir?
@lib_tracked_files ||= sys_exec(ruby_core? ? "git ls-files -z -- lib/bundler lib/bundler.rb" : "git ls-files -z -- lib", :dir => root).split("\x0")
@lib_tracked_files ||= git_ls_files(lib_tracked_files_glob)
end
def man_tracked_files
skip "not in git working directory" unless git_root_dir?
@man_tracked_files ||= sys_exec(ruby_core? ? "git ls-files -z -- man/bundler*" : "git ls-files -z -- man", :dir => root).split("\x0")
@man_tracked_files ||= git_ls_files(man_tracked_files_glob)
end
def tmp(*path)
root.join("tmp", scope, *path)
source_root.join("tmp", scope, *path)
end
def scope
@ -143,6 +169,10 @@ module Spec
tmp("gems/system", *path)
end
def pristine_system_gem_path
tmp("gems/base_system")
end
def local_gem_path(*path, base: bundled_app)
base.join(*[".bundle", Gem.ruby_engine, RbConfig::CONFIG["ruby_version"], *path].compact)
end
@ -151,6 +181,10 @@ module Spec
tmp("libs", *args)
end
def source_lib_dir
source_root.join("lib")
end
def lib_dir
root.join("lib")
end
@ -167,13 +201,25 @@ module Spec
tmp "tmpdir", *args
end
def replace_version_file(version, dir: root)
def replace_version_file(version, dir: source_root)
version_file = File.expand_path("lib/bundler/version.rb", dir)
contents = File.read(version_file)
contents.sub!(/(^\s+VERSION\s*=\s*)"#{Gem::Version::VERSION_PATTERN}"/, %(\\1"#{version}"))
File.open(version_file, "w") {|f| f << contents }
end
def replace_build_metadata(build_metadata, dir: source_root)
build_metadata_file = File.expand_path("lib/bundler/build_metadata.rb", dir)
ivars = build_metadata.sort.map do |k, v|
" @#{k} = #{loaded_gemspec.send(:ruby_code, v)}"
end.join("\n")
contents = File.read(build_metadata_file)
contents.sub!(/^(\s+# begin ivars).+(^\s+# end ivars)/m, "\\1\n#{ivars}\n\\2")
File.open(build_metadata_file, "w") {|f| f << contents }
end
def ruby_core?
# avoid to warnings
@ruby_core ||= nil
@ -185,6 +231,29 @@ module Spec
end
end
private
def git_ls_files(glob)
skip "not in git working directory" unless git_root_dir?
sys_exec("git ls-files -z -- #{glob}", :dir => source_root).split("\x0")
end
def tracked_files_glob
ruby_core? ? "lib/bundler lib/bundler.rb spec/bundler man/bundle*" : ""
end
def shipped_files_glob
ruby_core? ? "lib/bundler lib/bundler.rb man/bundle* man/gemfile* libexec/bundle*" : "lib man exe CHANGELOG.md LICENSE.md README.md bundler.gemspec"
end
def lib_tracked_files_glob
ruby_core? ? "lib/bundler lib/bundler.rb" : "lib"
end
def man_tracked_files_glob
ruby_core? ? "man/bundle* man/gemfile*" : "man"
end
extend self
end
end

Просмотреть файл

@ -2,7 +2,7 @@
require_relative "path"
$LOAD_PATH.unshift(Spec::Path.lib_dir.to_s)
$LOAD_PATH.unshift(Spec::Path.source_lib_dir.to_s)
module Spec
module Rubygems
@ -59,7 +59,8 @@ module Spec
ENV["BUNDLE_PATH"] = nil
ENV["GEM_HOME"] = ENV["GEM_PATH"] = Path.base_system_gems.to_s
ENV["PATH"] = [Path.bindir, Path.system_gem_path.join("bin"), ENV["PATH"]].join(File::PATH_SEPARATOR)
ENV["PATH"] = [Path.system_gem_path.join("bin"), ENV["PATH"]].join(File::PATH_SEPARATOR)
ENV["PATH"] = [Path.bindir, ENV["PATH"]].join(File::PATH_SEPARATOR) if Path.ruby_core?
end
def install_test_deps
@ -103,16 +104,13 @@ module Spec
require "bundler"
definition = Bundler::Definition.build(gemfile, lockfile, nil)
definition.validate_runtime!
Bundler::Installer.install(Path.root, definition, :path => ENV["GEM_HOME"])
Bundler::Installer.install(Path.source_root, definition, :path => ENV["GEM_HOME"])
ensure
ENV["BUNDLE_GEMFILE"] = old_gemfile
end
def test_gemfile
gemfile = Path.root.join("test_gems.rb")
# for Ruby core repository
gemfile = Path.root.join("tool/bundler/test_gems.rb") unless File.exist?(gemfile)
gemfile
Path.test_gemfile
end
def test_lockfile
@ -120,7 +118,7 @@ module Spec
end
def dev_gemfile
Path.root.join("dev_gems.rb")
Path.dev_gemfile
end
def dev_lockfile

Просмотреть файл

@ -96,7 +96,7 @@ private
def resolve_local_copy_path
return expanded_source if source_is_path?
rubygems_path = root.join("tmp/rubygems")
rubygems_path = source_root.join("tmp/rubygems")
unless rubygems_path.directory?
rubygems_path.parent.mkpath
@ -111,7 +111,7 @@ private
end
def expanded_source
@expanded_source ||= Pathname.new(@source).expand_path(root)
@expanded_source ||= Pathname.new(@source).expand_path(source_root)
end
def resolve_target_tag

Просмотреть файл

@ -2,13 +2,3 @@
require_relative "rubygems_version_manager"
RubygemsVersionManager.new(ENV["RGV"]).switch
if ENV["BUNDLER_SPEC_IGNORE_DEFAULT_BUNDLER_GEM"]
module NoBundlerStubs
def default_stubs(pattern = "*.gemspec")
super(pattern).reject {|s| s.name == "bundler" }
end
end
Gem::Specification.singleton_class.prepend(NoBundlerStubs)
end