ruby-changes:61716
From: David <ko1@a...>
Date: Mon, 15 Jun 2020 12:38:55 +0900 (JST)
Subject: [ruby-changes:61716] 117b504b98 (master): Fix most exec specs
https://git.ruby-lang.org/ruby.git/commit/?id=117b504b98 From 117b504b98add70984313d96e9d4b67d74b10c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...> Date: Thu, 11 Jun 2020 21:05:17 +0200 Subject: Fix most exec specs The `gem_command` helper was failing to require `support/hax.rb`, which takes care of making sure rubygems actually picks up the right `ruby` executable under ruby-core setup (`ENV["RUBY"]`). This caused binstubs to be generated with a wrong shebang, and that caused `bundle exec` to not work. The error message was pretty confusing though due to https://bugs.ruby-lang.org/issues/16952. diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb index 0c899b9..965d715 100644 --- a/spec/bundler/commands/exec_spec.rb +++ b/spec/bundler/commands/exec_spec.rb @@ -6,7 +6,7 @@ RSpec.describe "bundle exec" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/exec_spec.rb#L6 system_gems(system_gems_to_install, :path => default_bundle_path) end - it "works with --gemfile flag", :ruby_repo do + it "works with --gemfile flag" do create_file "CustomGemfile", <<-G gem "rack", "1.0.0" G @@ -15,7 +15,7 @@ RSpec.describe "bundle exec" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/exec_spec.rb#L15 expect(out).to eq("1.0.0") end - it "activates the correct gem", :ruby_repo do + it "activates the correct gem" do gemfile <<-G gem "rack", "0.9.1" G @@ -24,7 +24,7 @@ RSpec.describe "bundle exec" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/exec_spec.rb#L24 expect(out).to eq("0.9.1") end - it "works when the bins are in ~/.bundle", :ruby_repo do + it "works when the bins are in ~/.bundle" do install_gemfile <<-G gem "rack" G @@ -33,7 +33,7 @@ RSpec.describe "bundle exec" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/exec_spec.rb#L33 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 @@ -67,7 +67,7 @@ RSpec.describe "bundle exec" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/exec_spec.rb#L67 expect(out).to eq(Gem::VERSION) end - it "respects custom process title when loading through ruby" do + it "respects custom process title when loading through ruby", :ruby_repo do skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform? script_that_changes_its_own_title_and_checks_if_picked_up_by_ps_unix_utility = <<~'RUBY' @@ -269,7 +269,7 @@ RSpec.describe "bundle exec" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/exec_spec.rb#L269 ) end - it "handles gems installed with --without", :ruby_repo do + it "handles gems installed with --without" do bundle "config --local without middleware" install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -354,7 +354,7 @@ RSpec.describe "bundle exec" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/exec_spec.rb#L354 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)}" @@ -458,7 +458,7 @@ RSpec.describe "bundle exec" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/exec_spec.rb#L458 end describe "with gem executables" do - describe "run from a random directory", :ruby_repo do + describe "run from a random directory" do before(:each) do install_gemfile <<-G gem "rack" @@ -588,7 +588,7 @@ RSpec.describe "bundle exec" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/exec_spec.rb#L588 end describe "with gems bundled for deployment" do - it "works when calling bundler from another script", :ruby_repo do + it "works when calling bundler from another script" do skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform? gemfile <<-G @@ -874,7 +874,7 @@ __FILE__: #{path.to_s.inspect} https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/exec_spec.rb#L874 bundle! :install end - it "correctly shells out", :ruby_repo do + it "correctly shells out" do skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform? file = bundled_app("file_that_bundle_execs.rb") diff --git a/spec/bundler/install/deploy_spec.rb b/spec/bundler/install/deploy_spec.rb index d8f8c76..2f48437 100644 --- a/spec/bundler/install/deploy_spec.rb +++ b/spec/bundler/install/deploy_spec.rb @@ -63,7 +63,7 @@ RSpec.describe "install with --deployment or --frozen" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/install/deploy_spec.rb#L63 bundle! :install end - it "works when you bundle exec bundle", :ruby_repo do + it "works when you bundle exec bundle" do skip "doesn't find bundle" if Gem.win_platform? bundle! :install diff --git a/spec/bundler/other/platform_spec.rb b/spec/bundler/other/platform_spec.rb index 4831adc..565706c 100644 --- a/spec/bundler/other/platform_spec.rb +++ b/spec/bundler/other/platform_spec.rb @@ -829,7 +829,7 @@ G https://github.com/ruby/ruby/blob/trunk/spec/bundler/other/platform_spec.rb#L829 system_gems "rack-1.0.0", "rack-0.9.1", :path => default_bundle_path end - it "activates the correct gem when ruby version matches", :ruby_repo do + it "activates the correct gem when ruby version matches" do gemfile <<-G gem "rack", "0.9.1" @@ -852,7 +852,7 @@ G https://github.com/ruby/ruby/blob/trunk/spec/bundler/other/platform_spec.rb#L852 expect(out).to include("0.9.1") end - it "fails when the ruby version doesn't match", :ruby_repo do + it "fails when the ruby version doesn't match" do gemfile <<-G gem "rack", "0.9.1" @@ -863,7 +863,7 @@ G https://github.com/ruby/ruby/blob/trunk/spec/bundler/other/platform_spec.rb#L863 should_be_ruby_version_incorrect end - it "fails when the engine doesn't match", :ruby_repo do + it "fails when the engine doesn't match" do gemfile <<-G gem "rack", "0.9.1" @@ -885,7 +885,7 @@ G https://github.com/ruby/ruby/blob/trunk/spec/bundler/other/platform_spec.rb#L885 # should_be_engine_version_incorrect # end - it "fails when patchlevel doesn't match", :ruby_repo do + it "fails when patchlevel doesn't match" do gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack" diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb index fe786d4..8151907 100644 --- a/spec/bundler/support/helpers.rb +++ b/spec/bundler/support/helpers.rb @@ -171,6 +171,9 @@ module Spec https://github.com/ruby/ruby/blob/trunk/spec/bundler/support/helpers.rb#L171 end def gem_command(command, options = {}) + env = options[:env] || {} + env["RUBYOPT"] = opt_add("-r#{spec_dir}/support/hax.rb", env["RUBYOPT"] || ENV["RUBYOPT"]) + options[:env] = env sys_exec("#{Path.gem_bin} #{command}", options) end bang :gem_command -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/