Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion bundler.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# coding: utf-8
# frozen_string_literal: true

require File.expand_path("../lib/bundler/version", __FILE__)
begin
require File.expand_path("../lib/bundler/version", __FILE__)
rescue LoadError
# for Ruby core repository
require File.expand_path("../bundler/version", __FILE__)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to avoid this? Using a rescue to support Ruby core does not seem nice.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no solution yet.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could use File.file?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lib/bundler/version string was used the other example directory. This string can be only once in gemspec.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end

require "shellwords"

Gem::Specification.new do |s|
Expand Down
16 changes: 13 additions & 3 deletions lib/bundler/shared_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,15 @@ def search_up(*names)
until !File.directory?(current) || current == previous
if ENV["BUNDLE_SPEC_RUN"]
# avoid stepping above the tmp directory when testing
return nil if File.file?(File.join(current, "bundler.gemspec"))
gemspec = if ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]
# for Ruby Core
"lib/bundler.gemspec"
else
"bundler.gemspec"
end

# avoid stepping above the tmp directory when testing
return nil if File.file?(File.join(current, gemspec))
end

names.each do |name|
Expand Down Expand Up @@ -304,10 +312,12 @@ def set_bundle_variables
unless File.exist?(exe_file)
exe_file = File.expand_path("../../../exe/bundle", __FILE__)
end

Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
rescue Gem::GemNotFoundException
Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", File.expand_path("../../../exe/bundle", __FILE__)
exe_file = File.expand_path("../../../exe/bundle", __FILE__)
# for Ruby core repository
exe_file = File.expand_path("../../../../bin/bundle", __FILE__) unless File.exist?(exe_file)
Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
end

# Set BUNDLE_GEMFILE
Expand Down
3 changes: 2 additions & 1 deletion spec/bundler/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

it "looks for a binary and executes it if it's named bundler-<task>" do
File.open(tmp("bundler-testtasks"), "w", 0o755) do |f|
f.puts "#!/usr/bin/env ruby\nputs 'Hello, world'\n"
ruby = ENV["BUNDLE_RUBY"] || "/usr/bin/env ruby"
f.puts "#!#{ruby}\nputs 'Hello, world'\n"
end

with_path_added(tmp) do
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/env_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
end
end

describe ".version_of" do
describe ".version_of", :ruby_repo do
let(:parsed_version) { described_class.send(:version_of, "ruby") }

it "strips version of new line characters" do
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/mirror_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def with_server_and_mirror
server.close unless server.closed?
end

it "probes the server correctly" do
it "probes the server correctly", :ruby_repo do
with_server_and_mirror do |server, mirror|
expect(server.closed?).to be_falsey
expect(probe.replies?(mirror)).to be_truthy
Expand Down
3 changes: 2 additions & 1 deletion spec/bundler/shared_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@

it "sets BUNDLE_BIN_PATH to the bundle executable file" do
subject.set_bundle_environment
expect(ENV["BUNDLE_BIN_PATH"]).to eq(File.expand_path("../../../exe/bundle", __FILE__))
bundle_exe = ruby_core? ? "../../../../exe/bundle" : "../../../exe/bundle"
expect(ENV["BUNDLE_BIN_PATH"]).to eq(File.expand_path(bundle_exe, __FILE__))
end
end

Expand Down
9 changes: 7 additions & 2 deletions spec/bundler/ssl_certs/certificate_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@

# Pretend bundler root is rubygems root
before do
# Backing up rubygems ceriticates
FileUtils.mv(rubygems_certs_dir, rubygems_certs_dir + ".back") if ruby_core?

FileUtils.mkdir_p(rubygems_certs_dir)
FileUtils.touch(stub_cert)
end

after do
rubygems_dir = File.join(root.to_s, "lib", "rubygems")
FileUtils.rm_rf(rubygems_dir)
FileUtils.rm_rf(rubygems_certs_dir)

# Restore rubygems certificates
FileUtils.mv(rubygems_certs_dir + ".back", rubygems_certs_dir) if ruby_core?
end

describe "#update_from" do
Expand Down
2 changes: 1 addition & 1 deletion spec/commands/binstubs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
context "when requesting a different bundler version" do
before { lockfile lockfile.gsub(Bundler::VERSION, "999.999.999") }

it "attempts to load that version" do
it "attempts to load that version", :ruby_repo do
sys_exec bundled_app("bin/rackup").to_s
expect(exitstatus).to eq(42) if exitstatus
expect(last_command.stderr).to include("Activating bundler (999.999.999) failed:").
Expand Down
4 changes: 2 additions & 2 deletions spec/commands/clean_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ def should_not_have_gems(*gems)
should_not_have_gems "foo-1.0"
end

it "doesn't remove extensions artifacts from bundled git gems after clean", :rubygems => "2.2" do
it "doesn't remove extensions artifacts from bundled git gems after clean", :ruby_repo, :rubygems => "2.2" do
build_git "very_simple_git_binary", &:add_c_extension

revision = revision_for(lib_path("very_simple_git_binary-1.0"))
Expand All @@ -734,7 +734,7 @@ def should_not_have_gems(*gems)
expect(vendored_gems("bundler/gems/very_simple_git_binary-1.0-#{revision[0..11]}")).to exist
end

it "removes extension directories", :rubygems => "2.2" do
it "removes extension directories", :ruby_repo, :rubygems => "2.2" do
gemfile <<-G
source "file://#{gem_repo1}"

Expand Down
10 changes: 5 additions & 5 deletions spec/commands/exec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
expect(out).to eq("1.0.0")
end

it "works when running from a random directory" do
it "works when running from a random directory", :ruby_repo do
install_gemfile <<-G
gem "rack"
G
Expand Down Expand Up @@ -226,7 +226,7 @@
expect(out).to include("bundler: exec needs a command to run")
end

it "raises a helpful error when exec'ing to something outside of the bundle", :rubygems => ">= 2.5.2" do
it "raises a helpful error when exec'ing to something outside of the bundle", :ruby_repo, :rubygems => ">= 2.5.2" do
bundle! "config clean false" # want to keep the rackup binstub
install_gemfile! <<-G
source "file://#{gem_repo1}"
Expand Down Expand Up @@ -342,7 +342,7 @@
end

describe "with gem executables" do
describe "run from a random directory" do
describe "run from a random directory", :ruby_repo do
before(:each) do
install_gemfile <<-G
gem "rack"
Expand Down Expand Up @@ -445,7 +445,7 @@
expect(out).to include("Installing foo 1.0")
end

describe "with gems bundled via :path with invalid gemspecs" do
describe "with gems bundled via :path with invalid gemspecs", :ruby_repo do
it "outputs the gemspec validation errors", :rubygems => ">= 1.7.2" do
build_lib "foo"

Expand Down Expand Up @@ -633,7 +633,7 @@ def bin_path(a,b,c)
it_behaves_like "it runs"
end

context "when the file uses the current ruby shebang" do
context "when the file uses the current ruby shebang", :ruby_repo do
let(:shebang) { "#!#{Gem.ruby}" }
it_behaves_like "it runs"
end
Expand Down
2 changes: 1 addition & 1 deletion spec/commands/info_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
end
end

context "given a default gem shippped in ruby" do
context "given a default gem shippped in ruby", :ruby_repo do
it "prints information about the default gem", :if => (RUBY_VERSION >= "2.0") do
bundle "info rdoc"
expect(out).to include("* rdoc")
Expand Down
5 changes: 4 additions & 1 deletion spec/commands/newgem_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ def gem_skeleton_assertions(gem_name)
end

Dir.chdir(bundled_app("newgem")) do
system_gems ["rake-10.0.2", :bundler], :path => :bundle_path
gems = ["rake-10.0.2", :bundler]
# for Ruby core repository, Ruby 2.6+ has bundler as standard library.
gems.delete(:bundler) if ruby_core?
system_gems gems, :path => :bundle_path
bundle! "exec rake build"
end

Expand Down
2 changes: 1 addition & 1 deletion spec/commands/pristine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "bundler/vendored_fileutils"

RSpec.describe "bundle pristine" do
RSpec.describe "bundle pristine", :ruby_repo do
before :each do
build_lib "baz", :path => bundled_app do |s|
s.version = "1.0.0"
Expand Down
4 changes: 2 additions & 2 deletions spec/commands/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@
and include(default_bundle_path("gems", "rails-2.3.2").to_s)
end

it "prints the path to the running bundler", :bundler => "< 2" do
it "prints the path to the running bundler", :ruby_repo, :bundler => "< 2" do
bundle "show bundler"
expect(out).to eq(root.to_s)
end

it "prints the path to the running bundler", :bundler => "2" do
it "prints the path to the running bundler", :ruby_repo, :bundler => "2" do
bundle "show bundler"
expect(out).to eq(
"[DEPRECATED FOR 2.0] use `bundle info bundler` instead of `bundle show bundler`\n" +
Expand Down
2 changes: 1 addition & 1 deletion spec/install/deploy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
bundle! :install, forgotten_command_line_options(:deployment => true, :without => "test")
end

it "works when you bundle exec bundle" do
it "works when you bundle exec bundle", :ruby_repo do
bundle :install
bundle "install --deployment"
bundle! "exec bundle check"
Expand Down
6 changes: 3 additions & 3 deletions spec/install/gemfile/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@
end

context "with an extension" do
it "installs the extension" do
it "installs the extension", :ruby_repo do
build_git "foo" do |s|
s.add_dependency "rake"
s.extensions << "Rakefile"
Expand Down Expand Up @@ -1131,7 +1131,7 @@
expect(out).to eq(Pathname.glob(default_bundle_path("bundler/gems/extensions/**/foo-1.0-*")).first.to_s)
end

it "does not use old extension after ref changes" do
it "does not use old extension after ref changes", :ruby_repo do
git_reader = build_git "foo", :no_default => true do |s|
s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-RUBY
Expand Down Expand Up @@ -1193,7 +1193,7 @@
expect(out).not_to include("gem install foo")
end

it "does not reinstall the extension", :rubygems => ">= 2.3.0" do
it "does not reinstall the extension", :ruby_repo, :rubygems => ">= 2.3.0" do
build_git "foo" do |s|
s.add_dependency "rake"
s.extensions << "Rakefile"
Expand Down
14 changes: 7 additions & 7 deletions spec/install/gemfile/platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
gem "pry"
G

expect(the_bundle.lockfile).to read_as strip_whitespace(<<-L)
expect(the_bundle.lockfile).to read_as normalize_uri_file(strip_whitespace(<<-L))
GEM
remote: file://localhost/#{gem_repo4}/
specs:
Expand Down Expand Up @@ -160,7 +160,7 @@
#{Bundler::VERSION}
L

expect(the_bundle.lockfile).to read_as good_lockfile
expect(the_bundle.lockfile).to read_as normalize_uri_file(good_lockfile)

bad_lockfile = strip_whitespace <<-L
GEM
Expand Down Expand Up @@ -196,23 +196,23 @@
aggregate_failures do
lockfile bad_lockfile
bundle! :install
expect(the_bundle.lockfile).to read_as good_lockfile
expect(the_bundle.lockfile).to read_as normalize_uri_file(good_lockfile)

lockfile bad_lockfile
bundle! :update, :all => true
expect(the_bundle.lockfile).to read_as good_lockfile
expect(the_bundle.lockfile).to read_as normalize_uri_file(good_lockfile)

lockfile bad_lockfile
bundle! "update ffi"
expect(the_bundle.lockfile).to read_as good_lockfile
expect(the_bundle.lockfile).to read_as normalize_uri_file(good_lockfile)

lockfile bad_lockfile
bundle! "update empyrean"
expect(the_bundle.lockfile).to read_as good_lockfile
expect(the_bundle.lockfile).to read_as normalize_uri_file(good_lockfile)

lockfile bad_lockfile
bundle! :lock
expect(the_bundle.lockfile).to read_as good_lockfile
expect(the_bundle.lockfile).to read_as normalize_uri_file(good_lockfile)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/install/gems/native_extensions_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

RSpec.describe "installing a gem with native extensions" do
RSpec.describe "installing a gem with native extensions", :ruby_repo do
it "installs" do
build_repo2 do
build_gem "c_extension" do |s|
Expand Down
6 changes: 3 additions & 3 deletions spec/install/gems/resolving_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

RSpec.describe "bundle install with install-time dependencies" do
it "installs gems with implicit rake dependencies" do
it "installs gems with implicit rake dependencies", :ruby_repo do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "with_implicit_rake_dep"
Expand Down Expand Up @@ -48,7 +48,7 @@
expect(the_bundle).to include_gems "net_b 1.0"
end

it "installs plugins depended on by other plugins" do
it "installs plugins depended on by other plugins", :ruby_repo do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "net_a"
Expand All @@ -57,7 +57,7 @@
expect(the_bundle).to include_gems "net_a 1.0", "net_b 1.0"
end

it "installs multiple levels of dependencies" do
it "installs multiple levels of dependencies", :ruby_repo do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "net_c"
Expand Down
2 changes: 1 addition & 1 deletion spec/install/gems/standalone_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
include_examples "common functionality"
end

describe "with gems with native extension" do
describe "with gems with native extension", :ruby_repo do
before do
install_gemfile <<-G, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true)
source "file://#{gem_repo1}"
Expand Down
2 changes: 1 addition & 1 deletion spec/install/global_cache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def source2_global_cache(*segments)
end
end

describe "extension caching", :rubygems => "2.2" do
describe "extension caching", :ruby_repo, :rubygems => "2.2" do
it "works" do
build_git "very_simple_git_binary", &:add_c_extension
build_lib "very_simple_path_binary", &:add_c_extension
Expand Down
2 changes: 1 addition & 1 deletion spec/install/path_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def set_bundle_path(type, location)
expect(the_bundle).to include_gems "rack 1.0.0"
end

it "re-installs gems whose extensions have been deleted", :rubygems => ">= 2.3" do
it "re-installs gems whose extensions have been deleted", :ruby_repo, :rubygems => ">= 2.3" do
build_lib "very_simple_binary", "1.0.0", :to_system => true do |s|
s.write "lib/very_simple_binary.rb", "raise 'FAIL'"
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lock/lockfile_bundler_1_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
G
end

it "does not update the lockfile's bundler version if nothing changed during bundle install" do
it "does not update the lockfile's bundler version if nothing changed during bundle install", :ruby_repo do
version = "#{Bundler::VERSION.split(".").first}.0.0.0.a"

lockfile <<-L
Expand Down
Loading