diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-05-15 21:31:12 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-05-22 20:32:30 +0900 |
commit | c7ebeb7eda9f7f6bbb48effe1efc026eeb64d09c (patch) | |
tree | b516b3b5119331d4d8431b4d17f552e2c8e798fe /spec/bundler/commands | |
parent | f4f157fc81b940c0f76a01ee266a08e6bba69b6b (diff) | |
download | ruby-c7ebeb7eda9f7f6bbb48effe1efc026eeb64d09c.tar.gz |
Sync Bundler PR #3624
Diffstat (limited to 'spec/bundler/commands')
-rw-r--r-- | spec/bundler/commands/binstubs_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/commands/clean_spec.rb | 6 | ||||
-rw-r--r-- | spec/bundler/commands/exec_spec.rb | 35 | ||||
-rw-r--r-- | spec/bundler/commands/info_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/commands/newgem_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/commands/pristine_spec.rb | 37 | ||||
-rw-r--r-- | spec/bundler/commands/update_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/commands/viz_spec.rb | 11 |
8 files changed, 51 insertions, 46 deletions
diff --git a/spec/bundler/commands/binstubs_spec.rb b/spec/bundler/commands/binstubs_spec.rb index 409c32c4f0..8a9f02aee7 100644 --- a/spec/bundler/commands/binstubs_spec.rb +++ b/spec/bundler/commands/binstubs_spec.rb @@ -98,7 +98,7 @@ RSpec.describe "bundle binstubs <gem>" do context "the bundle binstub" do before do - system_gems "bundler-#{system_bundler_version}" + pristine_system_gems "bundler-#{system_bundler_version}" build_repo2 do build_gem "prints_loaded_gems", "1.0" do |s| s.executables = "print_loaded_gems" diff --git a/spec/bundler/commands/clean_spec.rb b/spec/bundler/commands/clean_spec.rb index 0c69585c0b..b808e0085c 100644 --- a/spec/bundler/commands/clean_spec.rb +++ b/spec/bundler/commands/clean_spec.rb @@ -765,7 +765,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", :ruby_repo do + it "doesn't remove extensions artifacts from bundled git gems after clean" do build_git "very_simple_git_binary", &:add_c_extension revision = revision_for(lib_path("very_simple_git_binary-1.0")) @@ -788,7 +788,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", :ruby_repo do + it "removes extension directories" do gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -824,7 +824,7 @@ RSpec.describe "bundle clean" do expect(simple_binary_extensions_dir).to exist end - it "removes git extension directories", :ruby_repo do + it "removes git extension directories" do build_git "very_simple_git_binary", &:add_c_extension revision = revision_for(lib_path("very_simple_git_binary-1.0")) diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb index f381a51263..08ebfe5ead 100644 --- a/spec/bundler/commands/exec_spec.rb +++ b/spec/bundler/commands/exec_spec.rb @@ -6,7 +6,7 @@ RSpec.describe "bundle exec" do 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 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 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 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 @@ -269,7 +269,7 @@ RSpec.describe "bundle exec" do ) end - it "handles gems installed with --without", :ruby_repo do + it "handles gems installed with --without" do install_gemfile <<-G, forgotten_command_line_options(:without => "middleware") source "#{file_uri_for(gem_repo1)}" gem "rack" # rack 0.9.1 and 1.0 exist @@ -353,7 +353,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)}" @@ -457,7 +457,7 @@ RSpec.describe "bundle exec" do 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" @@ -598,8 +598,9 @@ RSpec.describe "bundle exec" do end Bundler.rubygems.extend(Monkey) G - bundle "install --deployment" - bundle "exec ruby -e '`#{bindir.join("bundler")} -v`; puts $?.success?'" + bundle! "config set path.system true" + bundle! "install" + bundle "exec ruby -e '`bundle -v`; puts $?.success?'", :env => { "BUNDLER_VERSION" => Bundler::VERSION } expect(out).to match("true") end end @@ -881,7 +882,7 @@ __FILE__: #{path.to_s.inspect} puts `bundle exec echo foo` RUBY file.chmod(0o777) - bundle! "exec #{file}" + bundle! "exec #{file}", :env => { "PATH" => path } expect(out).to eq("foo") end end @@ -904,7 +905,7 @@ __FILE__: #{path.to_s.inspect} end end - system_gems(:bundler, "openssl-#{openssl_version}", :gem_repo => gem_repo4) + system_gems("openssl-#{openssl_version}", :gem_repo => gem_repo4) file = bundled_app("require_openssl.rb") create_file(file, <<-RUBY) @@ -915,15 +916,17 @@ __FILE__: #{path.to_s.inspect} RUBY file.chmod(0o777) + env = { "PATH" => path } aggregate_failures do - expect(bundle!("exec #{file}", :artifice => nil)).to eq(expected) - expect(bundle!("exec bundle exec #{file}", :artifice => nil)).to eq(expected) - expect(bundle!("exec ruby #{file}", :artifice => nil)).to eq(expected) - expect(run!(file.read, :artifice => nil)).to eq(expected) + expect(bundle!("exec #{file}", :artifice => nil, :env => env)).to eq(expected) + expect(bundle!("exec bundle exec #{file}", :artifice => nil, :env => env)).to eq(expected) + expect(bundle!("exec ruby #{file}", :artifice => nil, :env => env)).to eq(expected) + expect(run!(file.read, :artifice => nil, :env => env)).to eq(expected) end + skip "ruby_core has openssl and rubygems in the same folder, and this test needs rubygems require but default openssl not in a directly added entry in $LOAD_PATH" if ruby_core? # sanity check that we get the newer, custom version without bundler - sys_exec("#{Gem.ruby} #{file}") + sys_exec("#{Gem.ruby} #{file}", :env => env) expect(err).to include("custom openssl should not be loaded") end end diff --git a/spec/bundler/commands/info_spec.rb b/spec/bundler/commands/info_spec.rb index df2d5f2824..53158c9168 100644 --- a/spec/bundler/commands/info_spec.rb +++ b/spec/bundler/commands/info_spec.rb @@ -41,7 +41,7 @@ RSpec.describe "bundle info" do expect(err).to eq("Could not find gem 'missing'.") end - context "given a default gem shippped in ruby", :ruby_repo do + context "given a default gem shippped in ruby" do it "prints information about the default gem" do bundle! "info rdoc" expect(out).to include("* rdoc") diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb index 1dc51de9e7..62ffaedcc0 100644 --- a/spec/bundler/commands/newgem_spec.rb +++ b/spec/bundler/commands/newgem_spec.rb @@ -246,7 +246,7 @@ RSpec.describe "bundle gem" do end end - it "generates a valid gemspec", :readline, :ruby_repo do + it "generates a valid gemspec", :readline do bundle! "gem newgem --bin" prepare_gemspec(bundled_app("newgem", "newgem.gemspec")) diff --git a/spec/bundler/commands/pristine_spec.rb b/spec/bundler/commands/pristine_spec.rb index 15336137b6..9729d55cdc 100644 --- a/spec/bundler/commands/pristine_spec.rb +++ b/spec/bundler/commands/pristine_spec.rb @@ -2,7 +2,7 @@ require "bundler/vendored_fileutils" -RSpec.describe "bundle pristine", :ruby_repo do +RSpec.describe "bundle pristine" do before :each do build_lib "baz", :path => bundled_app do |s| s.version = "1.0.0" @@ -34,7 +34,7 @@ RSpec.describe "bundle pristine", :ruby_repo do context "when sourced from RubyGems" do it "reverts using cached .gem file" do - spec = Bundler.definition.specs["weakling"].first + spec = find_spec("weakling") changes_txt = Pathname.new(spec.full_gem_path).join("lib/changes.txt") FileUtils.touch(changes_txt) @@ -45,10 +45,9 @@ RSpec.describe "bundle pristine", :ruby_repo do end it "does not delete the bundler gem" do - system_gems :bundler bundle! "install" - bundle! "pristine", :system_bundler => true - bundle! "-v", :system_bundler => true + bundle! "pristine" + bundle! "-v" expected = if Bundler::VERSION < "3.0" "Bundler version" @@ -62,7 +61,7 @@ RSpec.describe "bundle pristine", :ruby_repo do context "when sourced from git repo" do it "reverts by resetting to current revision`" do - spec = Bundler.definition.specs["foo"].first + spec = find_spec("foo") changed_file = Pathname.new(spec.full_gem_path).join("lib/foo.rb") diff = "#Pristine spec changes" @@ -74,7 +73,7 @@ RSpec.describe "bundle pristine", :ruby_repo do end it "removes added files" do - spec = Bundler.definition.specs["foo"].first + spec = find_spec("foo") changes_txt = Pathname.new(spec.full_gem_path).join("lib/changes.txt") FileUtils.touch(changes_txt) @@ -85,7 +84,7 @@ RSpec.describe "bundle pristine", :ruby_repo do end it "displays warning and ignores changes when a local config exists" do - spec = Bundler.definition.specs["foo"].first + spec = find_spec("foo") bundle "config set local.#{spec.name} #{lib_path(spec.name)}" changes_txt = Pathname.new(spec.full_gem_path).join("lib/changes.txt") @@ -100,7 +99,7 @@ RSpec.describe "bundle pristine", :ruby_repo do context "when sourced from gemspec" do it "displays warning and ignores changes when sourced from gemspec" do - spec = Bundler.definition.specs["baz"].first + spec = find_spec("baz") changed_file = Pathname.new(spec.full_gem_path).join("lib/baz.rb") diff = "#Pristine spec changes" @@ -113,7 +112,7 @@ RSpec.describe "bundle pristine", :ruby_repo do end it "reinstall gemspec dependency" do - spec = Bundler.definition.specs["baz-dev"].first + spec = find_spec("baz-dev") changed_file = Pathname.new(spec.full_gem_path).join("lib/baz/dev.rb") diff = "#Pristine spec changes" @@ -127,7 +126,7 @@ RSpec.describe "bundle pristine", :ruby_repo do context "when sourced from path" do it "displays warning and ignores changes when sourced from local path" do - spec = Bundler.definition.specs["bar"].first + spec = find_spec("bar") changes_txt = Pathname.new(spec.full_gem_path).join("lib/changes.txt") FileUtils.touch(changes_txt) expect(changes_txt).to be_file @@ -139,17 +138,17 @@ RSpec.describe "bundle pristine", :ruby_repo do context "when passing a list of gems to pristine" do it "resets them" do - foo = Bundler.definition.specs["foo"].first + foo = find_spec("foo") foo_changes_txt = Pathname.new(foo.full_gem_path).join("lib/changes.txt") FileUtils.touch(foo_changes_txt) expect(foo_changes_txt).to be_file - bar = Bundler.definition.specs["bar"].first + bar = find_spec("bar") bar_changes_txt = Pathname.new(bar.full_gem_path).join("lib/changes.txt") FileUtils.touch(bar_changes_txt) expect(bar_changes_txt).to be_file - weakling = Bundler.definition.specs["weakling"].first + weakling = find_spec("weakling") weakling_changes_txt = Pathname.new(weakling.full_gem_path).join("lib/changes.txt") FileUtils.touch(weakling_changes_txt) expect(weakling_changes_txt).to be_file @@ -171,7 +170,7 @@ RSpec.describe "bundle pristine", :ruby_repo do end context "when a build config exists for one of the gems" do - let(:very_simple_binary) { Bundler.definition.specs["very_simple_binary"].first } + let(:very_simple_binary) { find_spec("very_simple_binary") } let(:c_ext_dir) { Pathname.new(very_simple_binary.full_gem_path).join("ext") } let(:build_opt) { "--with-ext-lib=#{c_ext_dir}" } before { bundle "config set build.very_simple_binary -- #{build_opt}" } @@ -188,7 +187,7 @@ RSpec.describe "bundle pristine", :ruby_repo do end context "when a build config exists for a git sourced gem" do - let(:git_with_ext) { Bundler.definition.specs["git_with_ext"].first } + let(:git_with_ext) { find_spec("git_with_ext") } let(:c_ext_dir) { Pathname.new(git_with_ext.full_gem_path).join("ext") } let(:build_opt) { "--with-ext-lib=#{c_ext_dir}" } before { bundle "config set build.git_with_ext -- #{build_opt}" } @@ -203,4 +202,10 @@ RSpec.describe "bundle pristine", :ruby_repo do expect(makefile_contents).to match(/LIBPATH =.*-L#{c_ext_dir}/) end end + + def find_spec(name) + without_env_side_effects do + Bundler.definition.specs[name].first + end + end end diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb index f8b8800de4..b6d3e08996 100644 --- a/spec/bundler/commands/update_spec.rb +++ b/spec/bundler/commands/update_spec.rb @@ -964,7 +964,7 @@ RSpec.describe "bundle update conservative" do isolated_owner BUNDLED WITH - 1.13.0 + #{Bundler::VERSION} L end diff --git a/spec/bundler/commands/viz_spec.rb b/spec/bundler/commands/viz_spec.rb index 029c3aca24..8d4f49df9f 100644 --- a/spec/bundler/commands/viz_spec.rb +++ b/spec/bundler/commands/viz_spec.rb @@ -1,13 +1,10 @@ # frozen_string_literal: true RSpec.describe "bundle viz", :bundler => "< 3", :if => Bundler.which("dot") do - let(:ruby_graphviz) do - graphviz_glob = base_system_gems.join("cache/ruby-graphviz*") - Pathname.glob(graphviz_glob).first - end - before do - system_gems ruby_graphviz + graphviz_version = RUBY_VERSION >= "2.4" ? "1.2.5" : "1.2.4" + + realworld_system_gems "ruby-graphviz --version #{graphviz_version}" end it "graphs gems from the Gemfile" do @@ -82,7 +79,7 @@ RSpec.describe "bundle viz", :bundler => "< 3", :if => Bundler.which("dot") do end end - system_gems ruby_graphviz, "graphviz-999", :gem_repo => gem_repo4 + system_gems "graphviz-999", :gem_repo => gem_repo4 end it "loads the correct ruby-graphviz gem" do |