summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2019-02-20 07:14:53 +0000
committerSHIBATA Hiroshi <hsbt@ruby-lang.org>2019-02-20 19:16:15 +0900
commit87c8dd3a08d5c873c53dedb2c7f43074d252f255 (patch)
tree334be7f014e7e873401298642b9b80d1cd79a9a1
parent115df2642722dcdb2cf9e4ddb3a51aec9e6f4afa (diff)
downloadbundler-87c8dd3a08d5c873c53dedb2c7f43074d252f255.tar.gz
Merge #6973
6973: Backport the latest commits on ruby core repository. r=hsbt a=hsbt ### What was the end-user problem that led to this PR? RSpec example of the bundled bundler was failed on Ruby 2.7 from ruby core repository. I fixed some of the issues on ruby core repository. ### What was your diagnosis of the problem? 1. I fixed the location of `lib/bundler.gemspec` to `lib/bundler/bundler.gemspec` for fixing gemspec issue of Ruby 2.6.1: https://github.com/ruby/ruby/commit/7c9771be02ddc707fea8ec96089c8a100c59f806 2. The current Bundler examples relied on the same versions of Ruby that are the first binary of PATH and rspec invocation binary. But the ruby core repository uses the different versions for them. ### What is your fix for the problem, implemented in this PR? I fixed the location path of bundler.gemspec and uses `ENV['BUNDLE_GEM']` instead of hard-coded `gem` command. ### Why did you choose this fix out of the possible options? There is no options on ruby core repository. I welcome to another options. Co-authored-by: SHIBATA Hiroshi <hsbt@ruby-lang.org> (cherry picked from commit 98a0a2dfdd42d9f624682915ab27fe1d4319def8)
-rw-r--r--lib/bundler/gem_helper.rb6
-rw-r--r--lib/bundler/shared_helpers.rb2
-rw-r--r--spec/commands/clean_spec.rb12
-rw-r--r--spec/quality_spec.rb14
-rw-r--r--spec/runtime/setup_spec.rb2
-rw-r--r--spec/support/helpers.rb12
-rw-r--r--spec/support/rubygems_ext.rb5
7 files changed, 36 insertions, 17 deletions
diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb
index e7673cba88..55f484f723 100644
--- a/lib/bundler/gem_helper.rb
+++ b/lib/bundler/gem_helper.rb
@@ -74,7 +74,8 @@ module Bundler
def build_gem
file_name = nil
- sh("gem build -V '#{spec_path}'") do
+ gem = ENV["BUNDLE_GEM"] ? ENV["BUNDLE_GEM"] : "gem"
+ sh("#{gem} build -V '#{spec_path}'") do
file_name = File.basename(built_gem_path)
SharedHelpers.filesystem_access(File.join(base, "pkg")) {|p| FileUtils.mkdir_p(p) }
FileUtils.mv(built_gem_path, "pkg")
@@ -85,7 +86,8 @@ module Bundler
def install_gem(built_gem_path = nil, local = false)
built_gem_path ||= build_gem
- out, _ = sh_with_code("gem install '#{built_gem_path}'#{" --local" if local}")
+ gem = ENV["BUNDLE_GEM"] ? ENV["BUNDLE_GEM"] : "gem"
+ out, _ = sh_with_code("#{gem} install '#{built_gem_path}'#{" --local" if local}")
raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output" unless out[/Successfully installed/]
Bundler.ui.confirm "#{name} (#{version}) installed."
end
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index 3c0901ed67..ac29179d4d 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -278,7 +278,7 @@ module Bundler
# avoid stepping above the tmp directory when testing
gemspec = if ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]
# for Ruby Core
- "lib/bundler.gemspec"
+ "lib/bundler/bundler.gemspec"
else
"bundler.gemspec"
end
diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb
index 158d58d67c..e1f007fc35 100644
--- a/spec/commands/clean_spec.rb
+++ b/spec/commands/clean_spec.rb
@@ -339,7 +339,8 @@ RSpec.describe "bundle clean" do
gem "rack"
G
- sys_exec! "gem list"
+ gem = ruby_core? ? ENV["BUNDLE_GEM"] : "gem"
+ sys_exec! "#{gem} list"
expect(out).to include("rack (1.0.0)").and include("thin (1.0)")
end
@@ -461,7 +462,8 @@ RSpec.describe "bundle clean" do
end
bundle! :update, :all => bundle_update_requires_all?
- sys_exec! "gem list"
+ gem = ruby_core? ? ENV["BUNDLE_GEM"] : "gem"
+ sys_exec! "#{gem} list"
expect(out).to include("foo (1.0.1, 1.0)")
end
@@ -485,7 +487,8 @@ RSpec.describe "bundle clean" do
bundle "clean --force"
expect(out).to include("Removing foo (1.0)")
- sys_exec "gem list"
+ gem = ruby_core? ? ENV["BUNDLE_GEM"] : "gem"
+ sys_exec "#{gem} list"
expect(out).not_to include("foo (1.0)")
expect(out).to include("rack (1.0.0)")
end
@@ -519,7 +522,8 @@ RSpec.describe "bundle clean" do
expect(out).to include(system_gem_path.to_s)
expect(out).to include("grant write permissions")
- sys_exec "gem list"
+ gem = ruby_core? ? ENV["BUNDLE_GEM"] : "gem"
+ sys_exec "#{gem} list"
expect(out).to include("foo (1.0)")
expect(out).to include("rack (1.0.0)")
end
diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb
index ce7058afc0..b24b42c542 100644
--- a/spec/quality_spec.rb
+++ b/spec/quality_spec.rb
@@ -225,7 +225,16 @@ RSpec.describe "The library itself" do
it "can still be built" do
Dir.chdir(root) do
begin
- gem_command! :build, gemspec
+ if ruby_core?
+ spec = Gem::Specification.load(gemspec.to_s)
+ spec.bindir = "libexec"
+ File.open(root.join("bundler.gemspec").to_s, "w") {|f| f.write spec.to_ruby }
+ gem_command! :build, root.join("bundler.gemspec").to_s
+ FileUtils.rm(root.join("bundler.gemspec").to_s)
+ else
+ gem_command! :build, gemspec
+ end
+
if Bundler.rubygems.provides?(">= 2.4")
# there's no way aroudn this warning
last_command.stderr.sub!(/^YAML safe loading.*/, "")
@@ -236,8 +245,7 @@ RSpec.describe "The library itself" do
end
ensure
# clean up the .gem generated
- path_prefix = ruby_core? ? "lib/" : "./"
- FileUtils.rm("#{path_prefix}bundler-#{Bundler::VERSION}.gem")
+ FileUtils.rm("bundler-#{Bundler::VERSION}.gem")
end
end
end
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index c41738a598..f2f750a9ca 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -876,7 +876,7 @@ end
FileUtils.ln_s(bundler_dir, File.join(gems_dir, "bundler-#{Bundler::VERSION}"))
- gemspec_file = ruby_core? ? "#{bundler_dir}/lib/bundler.gemspec" : "#{bundler_dir}/bundler.gemspec"
+ gemspec_file = ruby_core? ? "#{bundler_dir}/lib/bundler/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
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index 43bf6af229..89c67c45b7 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -313,12 +313,16 @@ module Spec
gem_repo = options.fetch(:gem_repo) { gem_repo1 }
gems.each do |g|
path = if g == :bundler
- Dir.chdir(root) { gem_command! :build, gemspec.to_s }
- bundler_path = if ruby_core?
- root + "lib/bundler-#{Bundler::VERSION}.gem"
+ if ruby_core?
+ spec = Gem::Specification.load(gemspec.to_s)
+ spec.bindir = "libexec"
+ File.open(root.join("bundler.gemspec").to_s, "w") {|f| f.write spec.to_ruby }
+ Dir.chdir(root) { gem_command! :build, root.join("bundler.gemspec").to_s }
+ FileUtils.rm(root.join("bundler.gemspec"))
else
- root + "bundler-#{Bundler::VERSION}.gem"
+ Dir.chdir(root) { gem_command! :build, gemspec.to_s }
end
+ bundler_path = root + "bundler-#{Bundler::VERSION}.gem"
elsif g.to_s =~ %r{\A/.*\.gem\z}
g
else
diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb
index c18f7650fc..063738c798 100644
--- a/spec/support/rubygems_ext.rb
+++ b/spec/support/rubygems_ext.rb
@@ -59,10 +59,11 @@ module Spec
no_reqs.map!(&:first)
reqs.map! {|name, req| "'#{name}:#{req}'" }
deps = reqs.concat(no_reqs).join(" ")
+ gem = Spec::Path.ruby_core? ? ENV["BUNDLE_GEM"] : "#{Gem.ruby} -S gem"
cmd = if Gem::VERSION < "2.0.0"
- "gem install #{deps} --no-rdoc --no-ri --conservative"
+ "#{gem} install #{deps} --no-rdoc --no-ri --conservative"
else
- "gem install #{deps} --no-document --conservative"
+ "#{gem} install #{deps} --no-document --conservative"
end
puts cmd
system(cmd) || raise("Installing gems #{deps} for the tests to use failed!")