From 5a384e2c08704dc7af9d8d3bdfc475eb8c0723aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 20 Aug 2019 02:46:31 +0200 Subject: Fix some bundler specs (#2380) * These seem to consistenly pass already * Show actual command when running `make test-bundler` Current the setup command that installs the necessary gems for testing bundler was printed, but not the actual command that runs the tests. That was a bit confusing. * Borrow trick from setproctitle specs * A title that long doesn't get set sometimes No idea why, but the test doesn't need that the title is that long. * Fix most gem helper spec ruby-core failures * Fix the rest of the gem helper failures * Fix version spec by improving the assertion * Remove unnecessary `BUNDLE_RUBY` environment var We can use `RUBY` when necessary, and `BUNDLE_RUBY` is not a good name because bundler considers `BUNDLE_*` variables as settings. * Rename `BUNDLE_GEM` to `GEM_COMMAND` This is more descriptive I think, and also friendlier for bundler because `BUNDLE_` env variables are interpreted by bundler as settings, and this is not a bundler setting. This fixes one bundler spec failure in config specs against ruby-core. * Fix quality spec when run in core Use the proper path helper. * Fix dummy lib builder to never load default gems If a dummy library is named as a default gem, when requiring the library from its executable, the default gem would be loaded when running from core, because in core all default gems share path with bundler, and thus they are always in the $LOAD_PATH. We fix the issue by loading lib relatively inside dummy lib executables. * More exact assertions Sometimes I have the problem that I do some "print debugging" inside specs, and suddently the spec passes. This happens when the assertion is too relaxed, and the things I print make it match, specially when they are simple strings like "1.0" than can be easily be part of gem paths that I print for debugging. I fix this by making a more exact assertion. * Detect the correct shebang when ENV["RUBY"] is set * Relax assertion So that the spec passes even if another paths containing "ext" are in the load path. This works to fix a ruby-core issue, but it's a better assertion in general. We just want to know that the extension path was added. * Use folder structure independent path helper It should fix this spec for ruby-core. * Fix the last failing spec on ruby-core * Skip `bundle open ` spec when no default gems --- common.mk | 1 - lib/bundler/bundler.gemspec | 9 +++------ lib/bundler/gem_helper.rb | 12 ++++++------ lib/bundler/shared_helpers.rb | 2 +- spec/bundler/bundler/cli_spec.rb | 2 +- spec/bundler/bundler/env_spec.rb | 4 ++-- spec/bundler/bundler/gem_helper_spec.rb | 2 +- spec/bundler/bundler/mirror_spec.rb | 2 +- spec/bundler/commands/config_spec.rb | 2 +- spec/bundler/commands/exec_spec.rb | 18 +++++++++--------- spec/bundler/commands/info_spec.rb | 2 +- spec/bundler/commands/newgem_spec.rb | 2 +- spec/bundler/commands/open_spec.rb | 12 +++++++++++- spec/bundler/commands/show_spec.rb | 2 +- spec/bundler/install/gemfile/git_spec.rb | 10 +++++----- spec/bundler/install/gems/resolving_spec.rb | 6 +++--- spec/bundler/quality_es_spec.rb | 4 ++-- spec/bundler/quality_spec.rb | 5 ++--- spec/bundler/runtime/setup_spec.rb | 4 ++-- spec/bundler/runtime/with_unbundled_env_spec.rb | 2 +- spec/bundler/spec_helper.rb | 12 ++++++------ spec/bundler/support/builders.rb | 2 +- spec/bundler/support/hax.rb | 8 ++++++++ spec/bundler/support/path.rb | 10 +++++++--- tool/runruby.rb | 3 +-- 25 files changed, 77 insertions(+), 61 deletions(-) diff --git a/common.mk b/common.mk index 06584c270d..23973260d6 100644 --- a/common.mk +++ b/common.mk @@ -1299,7 +1299,6 @@ RSPECOPTS = --format progress BUNDLER_SPECS = test-bundler: $(TEST_RUNNABLE)-test-bundler yes-test-bundler: yes-test-bundler-prepare - $(gnumake_recursive)$(Q) \ $(XRUBY) -C $(srcdir) -Ispec/bundler .bundle/bin/rspec \ --require spec_helper $(RSPECOPTS) spec/bundler/$(BUNDLER_SPECS) no-test-bundler: diff --git a/lib/bundler/bundler.gemspec b/lib/bundler/bundler.gemspec index 50be960cab..30a21f155f 100644 --- a/lib/bundler/bundler.gemspec +++ b/lib/bundler/bundler.gemspec @@ -34,14 +34,11 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 2.3.0" s.required_rubygems_version = ">= 2.5.2" - # s.files = Dir.glob("{lib,man,exe}/**/*", File::FNM_DOTMATCH).reject {|f| File.directory?(f) } + s.files = (Dir.glob("lib/bundler/**/*", File::FNM_DOTMATCH) + Dir.glob("man/bundler*") + Dir.glob("libexec/bundle*")).reject {|f| File.directory?(f) } - # Include the CHANGELOG.md, LICENSE.md, README.md manually - # s.files += %w[CHANGELOG.md LICENSE.md README.md] - # include the gemspec itself because warbler breaks w/o it - s.files += %w[bundler.gemspec] + s.files += ["lib/bundler.rb"] - s.bindir = "exe" + s.bindir = "libexec" s.executables = %w[bundle bundler] s.require_paths = ["lib"] end diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb index 68f5e636ff..d00c1894a8 100644 --- a/lib/bundler/gem_helper.rb +++ b/lib/bundler/gem_helper.rb @@ -75,8 +75,8 @@ module Bundler def build_gem file_name = nil - gem = ENV["BUNDLE_GEM"] ? ENV["BUNDLE_GEM"] : "gem" - sh(%W[#{gem} build -V #{spec_path}]) do + gem = ENV["GEM_COMMAND"] ? ENV["GEM_COMMAND"] : "gem" + sh("#{gem} build -V #{spec_path}".shellsplit) 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") @@ -87,10 +87,10 @@ module Bundler def install_gem(built_gem_path = nil, local = false) built_gem_path ||= build_gem - 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) + gem = ENV["GEM_COMMAND"] ? ENV["GEM_COMMAND"] : "gem" + cmd = "#{gem} install #{built_gem_path}" + cmd += " --local" if local + out, status = sh_with_status(cmd.shellsplit) unless status.success? && out[/Successfully installed/] raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output" end diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index a9bfd57fae..e6e2b79344 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -268,7 +268,7 @@ module Bundler until !File.directory?(current) || current == previous if ENV["BUNDLE_SPEC_RUN"] # avoid stepping above the tmp directory when testing - gemspec = if ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"] + gemspec = if ENV["GEM_COMMAND"] # for Ruby Core "lib/bundler/bundler.gemspec" else diff --git a/spec/bundler/bundler/cli_spec.rb b/spec/bundler/bundler/cli_spec.rb index 79b0cdb737..02e5155733 100644 --- a/spec/bundler/bundler/cli_spec.rb +++ b/spec/bundler/bundler/cli_spec.rb @@ -15,7 +15,7 @@ RSpec.describe "bundle executable" do it "looks for a binary and executes it if it's named bundler-" do File.open(tmp("bundler-testtasks"), "w", 0o755) do |f| - ruby = ENV["BUNDLE_RUBY"] || "/usr/bin/env ruby" + ruby = ENV["RUBY"] || "/usr/bin/env ruby" f.puts "#!#{ruby}\nputs 'Hello, world'\n" end diff --git a/spec/bundler/bundler/env_spec.rb b/spec/bundler/bundler/env_spec.rb index 4b9efd85d6..f0ab5d5f35 100644 --- a/spec/bundler/bundler/env_spec.rb +++ b/spec/bundler/bundler/env_spec.rb @@ -190,11 +190,11 @@ RSpec.describe Bundler::Env do end end - describe ".version_of", :ruby_repo do + describe ".version_of" do let(:parsed_version) { described_class.send(:version_of, "ruby") } it "strips version of new line characters" do - expect(parsed_version).to_not include("\n") + expect(parsed_version).to_not end_with("\n") end end end diff --git a/spec/bundler/bundler/gem_helper_spec.rb b/spec/bundler/bundler/gem_helper_spec.rb index a21fd4c835..c01d65d5dd 100644 --- a/spec/bundler/bundler/gem_helper_spec.rb +++ b/spec/bundler/bundler/gem_helper_spec.rb @@ -50,7 +50,7 @@ RSpec.describe Bundler::GemHelper do end end - context "gem management", :ruby_repo do + context "gem management" do def mock_confirm_message(message) expect(Bundler.ui).to receive(:confirm).with(message) end diff --git a/spec/bundler/bundler/mirror_spec.rb b/spec/bundler/bundler/mirror_spec.rb index fb476b8465..76b697c4d2 100644 --- a/spec/bundler/bundler/mirror_spec.rb +++ b/spec/bundler/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", :ruby_repo do + it "probes the server correctly" 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/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb index c0ef3bb70c..ef580463e5 100644 --- a/spec/bundler/commands/config_spec.rb +++ b/spec/bundler/commands/config_spec.rb @@ -389,7 +389,7 @@ E end describe "subcommands" do - it "list", :ruby_repo do + it "list" do bundle! "config list" expect(out).to eq "Settings are listed in order of priority. The top value will be used.\nspec_run\nSet via BUNDLE_SPEC_RUN: \"true\"" diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb index ec75b9eb0d..a36b303060 100644 --- a/spec/bundler/commands/exec_spec.rb +++ b/spec/bundler/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", :ruby_repo do + it "works when running from a random directory" do install_gemfile <<-G gem "rack" G @@ -56,14 +56,14 @@ RSpec.describe "bundle exec" do end it "respects custom process title when loading through ruby", :github_action_linux do - script_that_changes_its_own_title_and_checks_if_picked_up_by_ps_unix_utility = <<~RUBY - Process.setproctitle("1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16") - puts `ps -eo args | grep [1]-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16` + script_that_changes_its_own_title_and_checks_if_picked_up_by_ps_unix_utility = <<~'RUBY' + Process.setproctitle("1-2-3-4-5-6-7-8-9-10-11-12-13-14-15") + puts `ps -ocommand= -p#{$$}` RUBY create_file "Gemfile" create_file "a.rb", script_that_changes_its_own_title_and_checks_if_picked_up_by_ps_unix_utility bundle "exec ruby a.rb" - expect(out).to eq("1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16") + expect(out).to eq("1-2-3-4-5-6-7-8-9-10-11-12-13-14-15") end it "accepts --verbose" do @@ -192,7 +192,7 @@ RSpec.describe "bundle exec" do it "uses version specified" do bundle! "exec irb --version" - expect(out).to include(specified_irb_version) + expect(out).to eq(specified_irb_version) expect(err).to be_empty end end @@ -222,7 +222,7 @@ RSpec.describe "bundle exec" do end it "uses resolved version" do - expect(out).to include(indirect_irb_version) + expect(out).to eq(indirect_irb_version) expect(err).to be_empty end end @@ -336,7 +336,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)}" @@ -688,7 +688,7 @@ RSpec.describe "bundle exec" do it_behaves_like "it runs" end - context "when the file uses the current ruby shebang", :ruby_repo do + context "when the file uses the current ruby shebang" do let(:shebang) { "#!#{Gem.ruby}" } it_behaves_like "it runs" end diff --git a/spec/bundler/commands/info_spec.rb b/spec/bundler/commands/info_spec.rb index aa6b237d50..4572823498 100644 --- a/spec/bundler/commands/info_spec.rb +++ b/spec/bundler/commands/info_spec.rb @@ -116,7 +116,7 @@ RSpec.describe "bundle info" do end end - context "with a valid regexp for gem name", :ruby_repo do + context "with a valid regexp for gem name" do it "presents alternatives" do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb index beb21f9c2b..32c1868cd2 100644 --- a/spec/bundler/commands/newgem_spec.rb +++ b/spec/bundler/commands/newgem_spec.rb @@ -210,7 +210,7 @@ RSpec.describe "bundle gem" do end end - it "generates a valid gemspec", :ruby_repo do + it "generates a valid gemspec" do in_app_root bundle! "gem newgem --bin" diff --git a/spec/bundler/commands/open_spec.rb b/spec/bundler/commands/open_spec.rb index 98ecd9cad1..8fae4af5b4 100644 --- a/spec/bundler/commands/open_spec.rb +++ b/spec/bundler/commands/open_spec.rb @@ -92,8 +92,18 @@ RSpec.describe "bundle open" do end end - context "when opening a default gem", :ruby_repo do + context "when opening a default gem" do + let(:default_gems) do + ruby!(<<-RUBY).split("\n") + if Gem::Specification.is_a?(Enumerable) + puts Gem::Specification.select(&:default_gem?).map(&:name) + end + RUBY + end + before do + skip "No default gems available on this test run" if default_gems.empty? + install_gemfile <<-G gem "json" G diff --git a/spec/bundler/commands/show_spec.rb b/spec/bundler/commands/show_spec.rb index ce45a961f0..61b8f73e7f 100644 --- a/spec/bundler/commands/show_spec.rb +++ b/spec/bundler/commands/show_spec.rb @@ -166,7 +166,7 @@ RSpec.describe "bundle show", :bundler => "< 3" do end context "with a valid regexp for gem name" do - it "presents alternatives", :ruby_repo do + it "presents alternatives" do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack" diff --git a/spec/bundler/install/gemfile/git_spec.rb b/spec/bundler/install/gemfile/git_spec.rb index afcac8b153..7eb05a995c 100644 --- a/spec/bundler/install/gemfile/git_spec.rb +++ b/spec/bundler/install/gemfile/git_spec.rb @@ -1110,7 +1110,7 @@ RSpec.describe "bundle install with git sources" do end context "with an extension" do - it "installs the extension", :ruby_repo do + it "installs the extension" do build_git "foo" do |s| s.add_dependency "rake" s.extensions << "Rakefile" @@ -1139,7 +1139,7 @@ RSpec.describe "bundle install with git sources" do run! <<-R puts $:.grep(/ext/) R - expect(out).to eq(Pathname.glob(default_bundle_path("bundler/gems/extensions/**/foo-1.0-*")).first.to_s) + 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 @@ -1204,7 +1204,7 @@ In Gemfile: expect(out).not_to include("gem install foo") end - it "does not reinstall the extension", :ruby_repo do + it "does not reinstall the extension" do build_git "foo" do |s| s.add_dependency "rake" s.extensions << "Rakefile" @@ -1245,7 +1245,7 @@ In Gemfile: expect(out).to eq(installed_time) end - it "does not reinstall the extension when changing another gem", :ruby_repo do + it "does not reinstall the extension when changing another gem" do build_git "foo" do |s| s.add_dependency "rake" s.extensions << "Rakefile" @@ -1288,7 +1288,7 @@ In Gemfile: expect(out).to eq(installed_time) end - it "does reinstall the extension when changing refs", :ruby_repo do + it "does reinstall the extension when changing refs" do build_git "foo" do |s| s.add_dependency "rake" s.extensions << "Rakefile" diff --git a/spec/bundler/install/gems/resolving_spec.rb b/spec/bundler/install/gems/resolving_spec.rb index f245b7fc29..26ff40f7aa 100644 --- a/spec/bundler/install/gems/resolving_spec.rb +++ b/spec/bundler/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", :ruby_repo do + it "installs gems with implicit rake dependencies" do install_gemfile <<-G source "#{file_uri_for(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", :ruby_repo do + it "installs plugins depended on by other plugins" do install_gemfile <<-G source "#{file_uri_for(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", :ruby_repo do + it "installs multiple levels of dependencies" do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "net_c" diff --git a/spec/bundler/quality_es_spec.rb b/spec/bundler/quality_es_spec.rb index 46eed8f18a..a01e88d71a 100644 --- a/spec/bundler/quality_es_spec.rb +++ b/spec/bundler/quality_es_spec.rb @@ -55,11 +55,11 @@ RSpec.describe "La biblioteca si misma" do expect(error_messages.compact).to be_well_formed end - it "mantiene la calidad de lenguaje de oraciones usadas en el código fuente", :ruby_repo do + it "mantiene la calidad de lenguaje de oraciones usadas en el código fuente" do error_messages = [] exempt = /vendor/ Dir.chdir(root) do - `git ls-files -z -- lib`.split("\x0").each do |filename| + lib_tracked_files.split("\x0").each do |filename| next if filename =~ exempt error_messages << check_for_expendable_words(filename) error_messages << check_for_specific_pronouns(filename) diff --git a/spec/bundler/quality_spec.rb b/spec/bundler/quality_spec.rb index 40c0b0366e..09e59d88ae 100644 --- a/spec/bundler/quality_spec.rb +++ b/spec/bundler/quality_spec.rb @@ -230,10 +230,9 @@ RSpec.describe "The library itself" do end end - it "ships the correct set of files", :ruby_repo do + it "ships the correct set of files" do Dir.chdir(root) do - git_list = IO.popen("git ls-files -z", &:read).split("\x0").select {|f| f.match(%r{^(lib|man|exe)/}) } - git_list += %w[CHANGELOG.md LICENSE.md README.md bundler.gemspec] + git_list = shipped_files.split("\x0") gem_list = Gem::Specification.load(gemspec.to_s).files diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb index 9fa6e1bf9b..b9d710a9d9 100644 --- a/spec/bundler/runtime/setup_spec.rb +++ b/spec/bundler/runtime/setup_spec.rb @@ -810,12 +810,12 @@ end end end - it "should not remove itself from the LOAD_PATH and require a different copy of 'bundler/setup'", :ruby_repo do + 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 TracePoint.trace(:class) do |tp| - if tp.path.include?("bundler") && !tp.path.start_with?("#{File.expand_path("../..", __dir__)}") + if tp.path.include?("bundler") && !tp.path.start_with?("#{root}") puts "OMG. Defining a class from another bundler at \#{tp.path}:\#{tp.lineno}" end end diff --git a/spec/bundler/runtime/with_unbundled_env_spec.rb b/spec/bundler/runtime/with_unbundled_env_spec.rb index 62a9e40881..a5140ae463 100644 --- a/spec/bundler/runtime/with_unbundled_env_spec.rb +++ b/spec/bundler/runtime/with_unbundled_env_spec.rb @@ -31,7 +31,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", <<-'RB') count = ARGV.first.to_i exit if count < 0 diff --git a/spec/bundler/spec_helper.rb b/spec/bundler/spec_helper.rb index 14df93a3da..bac069888f 100644 --- a/spec/bundler/spec_helper.rb +++ b/spec/bundler/spec_helper.rb @@ -70,7 +70,7 @@ RSpec.configure do |config| config.filter_run_excluding :rubygems => RequirementChecker.against(Gem::VERSION) config.filter_run_excluding :git => RequirementChecker.against(git_version) config.filter_run_excluding :bundler => RequirementChecker.against(Bundler::VERSION.split(".")[0]) - config.filter_run_excluding :ruby_repo => !(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]).nil? + config.filter_run_excluding :ruby_repo => !ENV["GEM_COMMAND"].nil? config.filter_run_excluding :no_color_tty => Gem.win_platform? || !ENV["GITHUB_ACTION"].nil? config.filter_run_excluding :github_action_linux => !ENV["GITHUB_ACTION"].nil? && (ENV["RUNNER_OS"] == "Linux") @@ -88,12 +88,12 @@ RSpec.configure do |config| end config.around :each do |example| - if ENV["BUNDLE_RUBY"] + if ENV["RUBY"] orig_ruby = Gem.ruby - Gem.ruby = ENV["BUNDLE_RUBY"] + Gem.ruby = ENV["RUBY"] end example.run - Gem.ruby = orig_ruby if ENV["BUNDLE_RUBY"] + Gem.ruby = orig_ruby if ENV["RUBY"] end config.before :suite do @@ -108,7 +108,7 @@ RSpec.configure do |config| original_env = ENV.to_hash - if ENV["BUNDLE_RUBY"] + if ENV["RUBY"] FileUtils.cp_r Spec::Path.bindir, File.join(Spec::Path.root, "lib", "exe") end end @@ -139,7 +139,7 @@ RSpec.configure do |config| end config.after :suite do - if ENV["BUNDLE_RUBY"] + if ENV["RUBY"] FileUtils.rm_rf File.join(Spec::Path.root, "lib", "exe") end end diff --git a/spec/bundler/support/builders.rb b/spec/bundler/support/builders.rb index 70125ce52a..c7f299487c 100644 --- a/spec/bundler/support/builders.rb +++ b/spec/bundler/support/builders.rb @@ -557,7 +557,7 @@ module Spec "#!/usr/bin/env ruby\n" end @spec.files << executable - write executable, "#{shebang}require '#{@name}' ; puts #{Builders.constantize(@name)}" + write executable, "#{shebang}require_relative '../lib/#{@name}' ; puts #{Builders.constantize(@name)}" end end diff --git a/spec/bundler/support/hax.rb b/spec/bundler/support/hax.rb index c8f78a34a1..3e1ece2f0a 100644 --- a/spec/bundler/support/hax.rb +++ b/spec/bundler/support/hax.rb @@ -1,6 +1,14 @@ # frozen_string_literal: true module Gem + def self.ruby=(ruby) + @ruby = ruby + end + + if ENV["RUBY"] + Gem.ruby = ENV["RUBY"] + end + if version = ENV["BUNDLER_SPEC_RUBYGEMS_VERSION"] remove_const(:VERSION) if const_defined?(:VERSION) VERSION = version diff --git a/spec/bundler/support/path.rb b/spec/bundler/support/path.rb index 9493c5422a..7504f33c6e 100644 --- a/spec/bundler/support/path.rb +++ b/spec/bundler/support/path.rb @@ -22,7 +22,7 @@ module Spec end def gem_bin - @gem_bin ||= ruby_core? ? ENV["BUNDLE_GEM"] : "#{Gem.ruby} -S gem --backtrace" + @gem_bin ||= ruby_core? ? ENV["GEM_COMMAND"] : "#{Gem.ruby} -S gem --backtrace" end def spec_dir @@ -30,7 +30,11 @@ module Spec end def tracked_files - @tracked_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler` : `git ls-files -z` + @tracked_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler man/bundler*` : `git ls-files -z` + end + + def shipped_files + @shipped_files ||= 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` end def lib_tracked_files @@ -154,7 +158,7 @@ module Spec @ruby_core ||= nil if @ruby_core.nil? - @ruby_core = true & (ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]) + @ruby_core = true & ENV["GEM_COMMAND"] else @ruby_core end diff --git a/tool/runruby.rb b/tool/runruby.rb index d9fc1ac09d..4715ff4d5c 100755 --- a/tool/runruby.rb +++ b/tool/runruby.rb @@ -111,8 +111,7 @@ runner = nil unless File.exist?(runner) abs_ruby = runner || File.expand_path(ruby) env["RUBY"] = abs_ruby env["GEM_PATH"] = env["GEM_HOME"] = File.expand_path(".bundle", srcdir) -env["BUNDLE_RUBY"] = abs_ruby -env["BUNDLE_GEM"] = "#{abs_ruby} -rrubygems #{srcdir}/bin/gem --backtrace" +env["GEM_COMMAND"] = "#{abs_ruby} -rrubygems #{srcdir}/bin/gem --backtrace" env["PATH"] = [File.dirname(abs_ruby), abs_archdir, ENV["PATH"]].compact.join(File::PATH_SEPARATOR) if e = ENV["RUBYLIB"] -- cgit v1.2.1