summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2018-11-16 02:44:32 +0000
committerBundlerbot <bot@bundler.io>2018-11-16 02:44:32 +0000
commit172ec59db53ec05a91c0d9eb72e2d715ae82f3c0 (patch)
treed3f48e6c9f4f5c4fd35288c426ed2b3a15e817a2
parent98040394795a8e5fd03d7e893f1a060041cd6777 (diff)
parent2aa84b2372371c4895cab4e096b48a34f88c451a (diff)
downloadbundler-172ec59db53ec05a91c0d9eb72e2d715ae82f3c0.tar.gz
Merge #6743
6743: Support file structure of ruby core repository. r=hsbt a=hsbt ### What was the end-user problem that led to this PR? In the ruby core repository, I put bundler executable and bundler libraries under the `bin` and `lib` directories. It breaks the current behavior. ### What is your fix for the problem, implemented in this PR? Support the structure of ruby core repository. Co-authored-by: SHIBATA Hiroshi <hsbt@ruby-lang.org>
-rw-r--r--bundler.gemspec8
-rw-r--r--lib/bundler/shared_helpers.rb16
-rw-r--r--spec/bundler/cli_spec.rb3
-rw-r--r--spec/bundler/env_spec.rb2
-rw-r--r--spec/bundler/mirror_spec.rb2
-rw-r--r--spec/bundler/shared_helpers_spec.rb3
-rw-r--r--spec/bundler/ssl_certs/certificate_manager_spec.rb9
-rw-r--r--spec/commands/binstubs_spec.rb2
-rw-r--r--spec/commands/clean_spec.rb4
-rw-r--r--spec/commands/exec_spec.rb10
-rw-r--r--spec/commands/info_spec.rb2
-rw-r--r--spec/commands/newgem_spec.rb5
-rw-r--r--spec/commands/pristine_spec.rb2
-rw-r--r--spec/commands/show_spec.rb4
-rw-r--r--spec/install/deploy_spec.rb2
-rw-r--r--spec/install/gemfile/git_spec.rb6
-rw-r--r--spec/install/gemfile/platform_spec.rb14
-rw-r--r--spec/install/gems/native_extensions_spec.rb2
-rw-r--r--spec/install/gems/resolving_spec.rb6
-rw-r--r--spec/install/gems/standalone_spec.rb2
-rw-r--r--spec/install/global_cache_spec.rb2
-rw-r--r--spec/install/path_spec.rb2
-rw-r--r--spec/lock/lockfile_bundler_1_spec.rb2
-rw-r--r--spec/quality_spec.rb23
-rw-r--r--spec/runtime/gem_tasks_spec.rb2
-rw-r--r--spec/runtime/setup_spec.rb11
-rw-r--r--spec/runtime/with_clean_env_spec.rb6
-rw-r--r--spec/spec_helper.rb16
-rw-r--r--spec/support/helpers.rb9
-rw-r--r--spec/support/path.rb19
30 files changed, 131 insertions, 65 deletions
diff --git a/bundler.gemspec b/bundler.gemspec
index d04bf34e7c..c004de0965 100644
--- a/bundler.gemspec
+++ b/bundler.gemspec
@@ -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__)
+end
+
require "shellwords"
Gem::Specification.new do |s|
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index dca17885dd..e09e5e8b74 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -275,7 +275,15 @@ module Bundler
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|
@@ -304,10 +312,12 @@ module Bundler
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
diff --git a/spec/bundler/cli_spec.rb b/spec/bundler/cli_spec.rb
index 73868d10fb..c82d46587e 100644
--- a/spec/bundler/cli_spec.rb
+++ b/spec/bundler/cli_spec.rb
@@ -15,7 +15,8 @@ RSpec.describe "bundle executable" do
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
diff --git a/spec/bundler/env_spec.rb b/spec/bundler/env_spec.rb
index 10762b3cd2..20bd38b021 100644
--- a/spec/bundler/env_spec.rb
+++ b/spec/bundler/env_spec.rb
@@ -141,7 +141,7 @@ RSpec.describe Bundler::Env do
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
diff --git a/spec/bundler/mirror_spec.rb b/spec/bundler/mirror_spec.rb
index 0a8b9f8926..acd0895f2f 100644
--- a/spec/bundler/mirror_spec.rb
+++ b/spec/bundler/mirror_spec.rb
@@ -304,7 +304,7 @@ RSpec.describe Bundler::Settings::TCPSocketProbe do
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
diff --git a/spec/bundler/shared_helpers_spec.rb b/spec/bundler/shared_helpers_spec.rb
index 72b1c2a51f..b66c43fd92 100644
--- a/spec/bundler/shared_helpers_spec.rb
+++ b/spec/bundler/shared_helpers_spec.rb
@@ -384,7 +384,8 @@ RSpec.describe Bundler::SharedHelpers do
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
diff --git a/spec/bundler/ssl_certs/certificate_manager_spec.rb b/spec/bundler/ssl_certs/certificate_manager_spec.rb
index 2e43193359..56606a830f 100644
--- a/spec/bundler/ssl_certs/certificate_manager_spec.rb
+++ b/spec/bundler/ssl_certs/certificate_manager_spec.rb
@@ -11,13 +11,18 @@ RSpec.describe Bundler::SSLCerts::CertificateManager do
# 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
diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb
index ad859a21d5..2f014f2631 100644
--- a/spec/commands/binstubs_spec.rb
+++ b/spec/commands/binstubs_spec.rb
@@ -202,7 +202,7 @@ RSpec.describe "bundle binstubs <gem>" do
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:").
diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb
index ff3317bb1d..37cbeeb4e7 100644
--- a/spec/commands/clean_spec.rb
+++ b/spec/commands/clean_spec.rb
@@ -712,7 +712,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", :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"))
@@ -734,7 +734,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", :rubygems => "2.2" do
+ it "removes extension directories", :ruby_repo, :rubygems => "2.2" do
gemfile <<-G
source "file://#{gem_repo1}"
diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb
index acf12ced79..fdf60cefe7 100644
--- a/spec/commands/exec_spec.rb
+++ b/spec/commands/exec_spec.rb
@@ -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" do
+ it "works when running from a random directory", :ruby_repo do
install_gemfile <<-G
gem "rack"
G
@@ -226,7 +226,7 @@ RSpec.describe "bundle exec" do
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}"
@@ -342,7 +342,7 @@ RSpec.describe "bundle exec" do
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"
@@ -445,7 +445,7 @@ RSpec.describe "bundle exec" do
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"
@@ -633,7 +633,7 @@ RSpec.describe "bundle exec" do
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
diff --git a/spec/commands/info_spec.rb b/spec/commands/info_spec.rb
index a08965ec0e..a9ab8fc210 100644
--- a/spec/commands/info_spec.rb
+++ b/spec/commands/info_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe "bundle info" do
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")
diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb
index 8f033e5b4f..2914ba66c5 100644
--- a/spec/commands/newgem_spec.rb
+++ b/spec/commands/newgem_spec.rb
@@ -197,7 +197,10 @@ RSpec.describe "bundle gem" do
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
diff --git a/spec/commands/pristine_spec.rb b/spec/commands/pristine_spec.rb
index 3ce6636f9f..a868465c03 100644
--- a/spec/commands/pristine_spec.rb
+++ b/spec/commands/pristine_spec.rb
@@ -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"
diff --git a/spec/commands/show_spec.rb b/spec/commands/show_spec.rb
index 102b9534de..369d0d708a 100644
--- a/spec/commands/show_spec.rb
+++ b/spec/commands/show_spec.rb
@@ -60,12 +60,12 @@ RSpec.describe "bundle show" do
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" +
diff --git a/spec/install/deploy_spec.rb b/spec/install/deploy_spec.rb
index 491801e27a..3b9d68982a 100644
--- a/spec/install/deploy_spec.rb
+++ b/spec/install/deploy_spec.rb
@@ -64,7 +64,7 @@ RSpec.describe "install with --deployment or --frozen" do
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"
diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb
index beb5335fe4..08fe21cacf 100644
--- a/spec/install/gemfile/git_spec.rb
+++ b/spec/install/gemfile/git_spec.rb
@@ -1096,7 +1096,7 @@ RSpec.describe "bundle install with git sources" do
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"
@@ -1128,7 +1128,7 @@ RSpec.describe "bundle install with git sources" do
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
@@ -1190,7 +1190,7 @@ In Gemfile:
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"
diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb
index 6c226eb29f..bfdf9b68c8 100644
--- a/spec/install/gemfile/platform_spec.rb
+++ b/spec/install/gemfile/platform_spec.rb
@@ -102,7 +102,7 @@ RSpec.describe "bundle install across platforms" do
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:
@@ -160,7 +160,7 @@ RSpec.describe "bundle install across platforms" do
#{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
@@ -196,23 +196,23 @@ RSpec.describe "bundle install across platforms" do
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
diff --git a/spec/install/gems/native_extensions_spec.rb b/spec/install/gems/native_extensions_spec.rb
index c8252b81f1..ea616f60d3 100644
--- a/spec/install/gems/native_extensions_spec.rb
+++ b/spec/install/gems/native_extensions_spec.rb
@@ -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|
diff --git a/spec/install/gems/resolving_spec.rb b/spec/install/gems/resolving_spec.rb
index f581522c71..ddf803ed7d 100644
--- a/spec/install/gems/resolving_spec.rb
+++ b/spec/install/gems/resolving_spec.rb
@@ -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"
@@ -48,7 +48,7 @@ RSpec.describe "bundle install with install-time dependencies" do
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"
@@ -57,7 +57,7 @@ RSpec.describe "bundle install with install-time dependencies" do
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"
diff --git a/spec/install/gems/standalone_spec.rb b/spec/install/gems/standalone_spec.rb
index b149d9d00b..10ce589eef 100644
--- a/spec/install/gems/standalone_spec.rb
+++ b/spec/install/gems/standalone_spec.rb
@@ -67,7 +67,7 @@ RSpec.shared_examples "bundle install --standalone" do
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}"
diff --git a/spec/install/global_cache_spec.rb b/spec/install/global_cache_spec.rb
index 3664d3963a..e41e7e0157 100644
--- a/spec/install/global_cache_spec.rb
+++ b/spec/install/global_cache_spec.rb
@@ -187,7 +187,7 @@ RSpec.describe "global gem caching" do
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
diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb
index 5f3fedb862..44439c275e 100644
--- a/spec/install/path_spec.rb
+++ b/spec/install/path_spec.rb
@@ -207,7 +207,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", :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
diff --git a/spec/lock/lockfile_bundler_1_spec.rb b/spec/lock/lockfile_bundler_1_spec.rb
index a8615d4c89..fcdf6ebf0d 100644
--- a/spec/lock/lockfile_bundler_1_spec.rb
+++ b/spec/lock/lockfile_bundler_1_spec.rb
@@ -75,7 +75,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
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
diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb
index f8aec009ef..e85d0bfa97 100644
--- a/spec/quality_spec.rb
+++ b/spec/quality_spec.rb
@@ -108,7 +108,8 @@ RSpec.describe "The library itself" do
exempt = /\.gitmodules|\.marshal|fixtures|vendor|ssl_certs|LICENSE|vcr_cassettes/
error_messages = []
Dir.chdir(root) do
- `git ls-files -z`.split("\x0").each do |filename|
+ lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler` : `git ls-files -z -- lib`
+ lib_files.split("\x0").each do |filename|
next if filename =~ exempt
error_messages << check_for_tab_characters(filename)
error_messages << check_for_extra_spaces(filename)
@@ -121,7 +122,8 @@ RSpec.describe "The library itself" do
exempt = %r{quality_spec.rb|support/helpers|vcr_cassettes|\.md|\.ronn}
error_messages = []
Dir.chdir(root) do
- `git ls-files -z`.split("\x0").each do |filename|
+ lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler` : `git ls-files -z -- lib`
+ lib_files.split("\x0").each do |filename|
next if filename =~ exempt
error_messages << check_for_debugging_mechanisms(filename)
end
@@ -133,7 +135,8 @@ RSpec.describe "The library itself" do
error_messages = []
exempt = %r{lock/lockfile_(bundler_1_)?spec|quality_spec|vcr_cassettes|\.ronn|lockfile_parser\.rb}
Dir.chdir(root) do
- `git ls-files -z`.split("\x0").each do |filename|
+ lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler` : `git ls-files -z -- lib`
+ lib_files.split("\x0").each do |filename|
next if filename =~ exempt
error_messages << check_for_git_merge_conflicts(filename)
end
@@ -158,7 +161,8 @@ RSpec.describe "The library itself" do
error_messages = []
exempt = /vendor/
Dir.chdir(root) do
- `git ls-files -z -- lib`.split("\x0").each do |filename|
+ lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb` : `git ls-files -z -- lib`
+ lib_files.split("\x0").each do |filename|
next if filename =~ exempt
error_messages << check_for_expendable_words(filename)
error_messages << check_for_specific_pronouns(filename)
@@ -191,7 +195,8 @@ RSpec.describe "The library itself" do
Dir.chdir(root) do
key_pattern = /([a-z\._-]+)/i
- `git ls-files -z -- lib`.split("\x0").each do |filename|
+ lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb` : `git ls-files -z -- lib`
+ lib_files.split("\x0").each do |filename|
File.readlines(filename).each_with_index do |line, number|
line.scan(/Bundler\.settings\[:#{key_pattern}\]/).flatten.each {|s| all_settings[s] << "referenced at `#{filename}:#{number.succ}`" }
end
@@ -219,7 +224,7 @@ RSpec.describe "The library itself" do
it "can still be built" do
Dir.chdir(root) do
begin
- gem_command! :build, "bundler.gemspec"
+ gem_command! :build, gemspec
if Bundler.rubygems.provides?(">= 2.4")
# there's no way around this warning
last_command.stderr.sub!(/^YAML safe loading.*/, "")
@@ -230,7 +235,8 @@ RSpec.describe "The library itself" do
end
ensure
# clean up the .gem generated
- FileUtils.rm("bundler-#{Bundler::VERSION}.gem")
+ path_prefix = ruby_core? ? "lib/" : "./"
+ FileUtils.rm("#{path_prefix}bundler-#{Bundler::VERSION}.gem")
end
end
end
@@ -244,7 +250,8 @@ RSpec.describe "The library itself" do
lib/bundler/vlad.rb
lib/bundler/templates/gems.rb
]
- lib_files = `git ls-files -z -- lib`.split("\x0").grep(/\.rb$/) - exclusions
+ lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb` : `git ls-files -z -- lib`
+ lib_files = lib_files.split("\x0").grep(/\.rb$/) - exclusions
lib_files.reject! {|f| f.start_with?("lib/bundler/vendor") }
lib_files.map! {|f| f.chomp(".rb") }
sys_exec!("ruby -w -Ilib") do |input, _, _|
diff --git a/spec/runtime/gem_tasks_spec.rb b/spec/runtime/gem_tasks_spec.rb
index 1cf808f35b..de72869dc3 100644
--- a/spec/runtime/gem_tasks_spec.rb
+++ b/spec/runtime/gem_tasks_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.describe "require 'bundler/gem_tasks'" do
+RSpec.describe "require 'bundler/gem_tasks'", :ruby_repo do
before :each do
bundled_app("foo.gemspec").open("w") do |f|
f.write <<-GEMSPEC
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index 93a25b1ea8..7ea7d5ea0b 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -119,7 +119,7 @@ RSpec.describe "Bundler.setup" do
lp.map! {|p| p.sub(/^#{Regexp.union system_gem_path.to_s, default_bundle_path.to_s}/i, "") }
end
- it "puts loaded gems after -I and RUBYLIB" do
+ it "puts loaded gems after -I and RUBYLIB", :ruby_repo do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
@@ -824,7 +824,7 @@ end
expect(out).to eq("yay")
end
- it "should clean $LOAD_PATH properly" do
+ it "should clean $LOAD_PATH properly", :ruby_repo do
gem_name = "very_simple_binary"
full_gem_name = gem_name + "-1.0"
ext_dir = File.join(tmp("extensions", full_gem_name))
@@ -860,7 +860,7 @@ end
context "with bundler is located in symlinked GEM_HOME" do
let(:gem_home) { Dir.mktmpdir }
let(:symlinked_gem_home) { Tempfile.new("gem_home").path }
- let(:bundler_dir) { File.expand_path("../../..", __FILE__) }
+ let(:bundler_dir) { ruby_core? ? File.expand_path("../../../..", __FILE__) : File.expand_path("../../..", __FILE__) }
let(:bundler_lib) { File.join(bundler_dir, "lib") }
before do
@@ -872,7 +872,8 @@ end
FileUtils.ln_s(bundler_dir, File.join(gems_dir, "bundler-#{Bundler::VERSION}"))
- gemspec = File.read("#{bundler_dir}/bundler.gemspec").
+ gemspec_file = ruby_core? ? "#{bundler_dir}/lib/bundler.gemspec" : "#{bundler_dir}/bundler.gemspec"
+ gemspec = File.read(gemspec_file).
sub("Bundler::VERSION", %("#{Bundler::VERSION}"))
gemspec = gemspec.lines.reject {|line| line =~ %r{lib/bundler/version} }.join
@@ -881,7 +882,7 @@ end
end
end
- it "should successfully require 'bundler/setup'" do
+ it "should successfully require 'bundler/setup'", :ruby_repo do
install_gemfile ""
ruby <<-'R', :env => { "GEM_PATH" => symlinked_gem_home }, :no_lib => true
diff --git a/spec/runtime/with_clean_env_spec.rb b/spec/runtime/with_clean_env_spec.rb
index fd621071ad..321f5b6415 100644
--- a/spec/runtime/with_clean_env_spec.rb
+++ b/spec/runtime/with_clean_env_spec.rb
@@ -34,7 +34,7 @@ RSpec.describe "Bundler.with_env helpers" do
end
end
- it "works with nested bundle exec invocations" do
+ it "works with nested bundle exec invocations", :ruby_repo do
create_file("exe.rb", <<-'RB')
count = ARGV.first.to_i
exit if count < 0
@@ -55,7 +55,7 @@ RSpec.describe "Bundler.with_env helpers" do
EOS
end
- it "removes variables that bundler added" do
+ it "removes variables that bundler added", :ruby_repo do
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.dump}", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
@@ -84,7 +84,7 @@ RSpec.describe "Bundler.with_env helpers" do
expect(last_command.stdboth).not_to include("-rbundler/setup")
end
- it "should clean up RUBYLIB" do
+ 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"
bundle_exec_ruby! code.dump
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 1091c0b7f3..f79c4e683a 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -52,6 +52,12 @@ ENV["THOR_COLUMNS"] = "10000"
Spec::CodeClimate.setup
+module Gem
+ def self.ruby=(ruby)
+ @ruby = ruby
+ end
+end
+
RSpec.configure do |config|
config.include Spec::Builders
config.include Spec::Helpers
@@ -93,6 +99,7 @@ RSpec.configure do |config|
config.filter_run_excluding :git => LessThanProc.with(git_version)
config.filter_run_excluding :rubygems_master => (ENV["RGV"] != "master")
config.filter_run_excluding :bundler => LessThanProc.with(Bundler::VERSION.split(".")[0, 2].join("."))
+ config.filter_run_excluding :ruby_repo => !(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]).nil?
config.filter_run_when_matching :focus unless ENV["CI"]
@@ -107,6 +114,15 @@ RSpec.configure do |config|
mocks.allow_message_expectations_on_nil = false
end
+ config.around :suite do |example|
+ if ENV["BUNDLE_RUBY"]
+ @orig_ruby = Gem.ruby
+ Gem.ruby = ENV["BUNDLE_RUBY"]
+ end
+ example.run
+ Gem.ruby = @orig_ruby if ENV["BUNDLE_RUBY"]
+ end
+
config.before :all do
build_repo1
end
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index a88578aea7..98a4096216 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -212,7 +212,8 @@ module Spec
args = args.gsub(/(?=")/, "\\")
args = %("#{args}")
end
- sys_exec("#{Gem.ruby} -rrubygems -S gem --backtrace #{command} #{args}")
+ gem = ENV["BUNDLE_GEM"] || "#{Gem.ruby} -rrubygems -S gem --backtrace"
+ sys_exec("#{gem} #{command} #{args}")
end
bang :gem_command
@@ -313,7 +314,11 @@ module Spec
gems.each do |g|
path = if g == :bundler
Dir.chdir(root) { gem_command! :build, gemspec.to_s }
- bundler_path = root + "bundler-#{Bundler::VERSION}.gem"
+ bundler_path = if ruby_core?
+ root + "lib/bundler-#{Bundler::VERSION}.gem"
+ else
+ root + "bundler-#{Bundler::VERSION}.gem"
+ end
elsif g.to_s =~ %r{\A/.*\.gem\z}
g
else
diff --git a/spec/support/path.rb b/spec/support/path.rb
index 8dd8f5a277..cecab45c9b 100644
--- a/spec/support/path.rb
+++ b/spec/support/path.rb
@@ -5,19 +5,19 @@ require "pathname"
module Spec
module Path
def root
- @root ||= Pathname.new(File.expand_path("../../..", __FILE__))
+ @root ||= Pathname.new(ruby_core? ? "../../../.." : "../../..").expand_path(__FILE__)
end
def gemspec
- @gemspec ||= root.join("bundler.gemspec")
+ @gemspec ||= root.join(ruby_core? ? "lib/bundler.gemspec" : "bundler.gemspec")
end
def bindir
- @bindir ||= root.join("exe")
+ @bindir ||= root.join(ruby_core? ? "bin" : "exe")
end
def spec_dir
- @spec_dir ||= root.join("spec")
+ @spec_dir ||= root.join(ruby_core? ? "spec/bundler" : "spec")
end
def tmp(*path)
@@ -110,6 +110,17 @@ module Spec
tmp "tmpdir", *args
end
+ def ruby_core?
+ # avoid to wornings
+ @ruby_core ||= nil
+
+ if @ruby_core.nil?
+ @ruby_core = true & (ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"])
+ else
+ @ruby_core
+ end
+ end
+
extend self
end
end