From 0c95d6dcad318737c36b139337ed5913b88f23ff Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Tue, 19 Feb 2019 22:35:15 +0900 Subject: [PATCH 1/4] The ruby core applied the difference structure from bundler upstream repository. We need to modify a configuration for test-bundler. --- spec/quality_spec.rb | 14 +++++++++++--- spec/support/helpers.rb | 12 ++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb index f800ceeebd6..ce57c20e5cd 100644 --- a/spec/quality_spec.rb +++ b/spec/quality_spec.rb @@ -216,7 +216,16 @@ def check_for_specific_pronouns(filename) 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 around this warning last_command.stderr.sub!(/^YAML safe loading.*/, "") @@ -227,8 +236,7 @@ def check_for_specific_pronouns(filename) 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/support/helpers.rb b/spec/support/helpers.rb index 563af1eab3f..41b2004c199 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -308,12 +308,16 @@ def install_gems(*gems) 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 From 0f3375ea81406e0e6ecca20d775c7a4d8ab9ebfd Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Tue, 19 Feb 2019 22:36:28 +0900 Subject: [PATCH 2/4] Fixup r66984. It breakes bundler's examples. --- lib/bundler/shared_helpers.rb | 2 +- spec/runtime/setup_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index 6a0da52e1ed..02b3801c443 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -278,7 +278,7 @@ def search_up(*names) # 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/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index b57d61c3a69..fe84fc53796 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -871,7 +871,7 @@ def clean_load_path(lp) 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 From 48c0ed4480c6fd1c3f35e9e808e84cfeecc9a97b Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Tue, 19 Feb 2019 22:41:56 +0900 Subject: [PATCH 3/4] Use ENV["BUNDLE_GEM"] instead of gem command provided by system ruby. It break the examples of bundler. Because some examples detect the different version of system ruby than test target version like trunk. --- lib/bundler/gem_helper.rb | 6 ++++-- spec/commands/clean_spec.rb | 14 +++++++++----- spec/support/rubygems_ext.rb | 3 ++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb index ca39f122e9b..e9ee03b8a2b 100644 --- a/lib/bundler/gem_helper.rb +++ b/lib/bundler/gem_helper.rb @@ -75,7 +75,8 @@ def install def build_gem file_name = nil - sh(%W[gem build -V #{spec_path}]) do + gem = ENV["BUNDLE_GEM"] ? ENV["BUNDLE_GEM"] : "gem" + sh(%W[#{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") @@ -86,7 +87,8 @@ def build_gem def install_gem(built_gem_path = nil, local = false) built_gem_path ||= build_gem - cmd = %W[gem install #{built_gem_path}] + gem = ENV["BUNDLE_GEM"] ? ENV["BUNDLE_GEM"] : "gem" + cmd = %W[#{gem} install #{built_gem_path}] cmd << "--local" if local out, status = sh_with_status(cmd) unless status.success? && out[/Successfully installed/] diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb index 2ed8b36a852..7e5da904735 100644 --- a/spec/commands/clean_spec.rb +++ b/spec/commands/clean_spec.rb @@ -339,7 +339,8 @@ def should_not_have_gems(*gems) 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,8 +462,9 @@ def should_not_have_gems(*gems) end bundle! :update, :all => bundle_update_requires_all? - sys_exec! "gem list" - expect(out).to include("foo (1.0.1, 1.0)") + gem = ruby_core? ? ENV["BUNDLE_GEM"] : "gem" + sys_exec! "#{gem} list" + expect(out).to include("foo (1.0.1, 1.0)") end it "cleans system gems when --force is used" do @@ -485,7 +487,8 @@ def should_not_have_gems(*gems) 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 @@ def should_not_have_gems(*gems) expect(err).to include(system_gem_path.to_s) expect(err).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/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb index c13ed35413f..478cd12eb5c 100644 --- a/spec/support/rubygems_ext.rb +++ b/spec/support/rubygems_ext.rb @@ -52,7 +52,8 @@ def self.install_gems(gems) no_reqs.map!(&:first) reqs.map! {|name, req| "'#{name}:#{req}'" } deps = reqs.concat(no_reqs).join(" ") - cmd = "#{Gem.ruby} -S gem install #{deps} --no-document --conservative" + gem = Spec::Path.ruby_core? ? ENV["BUNDLE_GEM"] : "#{Gem.ruby} -S gem" + cmd = "#{gem} install #{deps} --no-document --conservative" puts cmd system(cmd) || raise("Installing gems #{deps} for the tests to use failed!") end From c5396b64b5d83eb0ffdda357bb3e3efb46c5d1c8 Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Wed, 20 Feb 2019 09:47:44 +0900 Subject: [PATCH 4/4] Fixed cop failures --- spec/commands/clean_spec.rb | 2 +- spec/quality_spec.rb | 2 +- spec/support/helpers.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb index 7e5da904735..f9c76fdfd0e 100644 --- a/spec/commands/clean_spec.rb +++ b/spec/commands/clean_spec.rb @@ -464,7 +464,7 @@ def should_not_have_gems(*gems) gem = ruby_core? ? ENV["BUNDLE_GEM"] : "gem" sys_exec! "#{gem} list" - expect(out).to include("foo (1.0.1, 1.0)") + expect(out).to include("foo (1.0.1, 1.0)") end it "cleans system gems when --force is used" do diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb index ce57c20e5cd..cbeabb3b6e7 100644 --- a/spec/quality_spec.rb +++ b/spec/quality_spec.rb @@ -219,7 +219,7 @@ def check_for_specific_pronouns(filename) 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 } + 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 diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 41b2004c199..e9138728fc7 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -311,7 +311,7 @@ def install_gems(*gems) 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 } + 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