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/runtime | |
parent | f4f157fc81b940c0f76a01ee266a08e6bba69b6b (diff) |
Sync Bundler PR #3624
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3114
Diffstat (limited to 'spec/bundler/runtime')
-rw-r--r-- | spec/bundler/runtime/executable_spec.rb | 4 | ||||
-rw-r--r-- | spec/bundler/runtime/setup_spec.rb | 60 | ||||
-rw-r--r-- | spec/bundler/runtime/with_unbundled_env_spec.rb | 14 |
3 files changed, 51 insertions, 27 deletions
diff --git a/spec/bundler/runtime/executable_spec.rb b/spec/bundler/runtime/executable_spec.rb index e420594f52..92c16a5f44 100644 --- a/spec/bundler/runtime/executable_spec.rb +++ b/spec/bundler/runtime/executable_spec.rb @@ -89,10 +89,6 @@ RSpec.describe "Running bin/* commands" do end it "creates a bundle binstub" do - build_gem "bundler", Bundler::VERSION, :to_system => true do |s| - s.executables = "bundle" - end - gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "bundler" diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb index b39a740653..2aa0585bac 100644 --- a/spec/bundler/runtime/setup_spec.rb +++ b/spec/bundler/runtime/setup_spec.rb @@ -112,7 +112,7 @@ RSpec.describe "Bundler.setup" do lp.map! {|p| p.sub(/^#{Regexp.union system_gem_path.to_s, default_bundle_path.to_s, lib_dir.to_s}/i, "") } end - it "puts loaded gems after -I and RUBYLIB", :ruby_repo do + it "puts loaded gems after -I and RUBYLIB" do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack" @@ -136,7 +136,7 @@ RSpec.describe "Bundler.setup" do end it "orders the load path correctly when there are dependencies" do - system_gems :bundler + bundle "config set path.system true" install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -755,7 +755,7 @@ end expect(out).to eq("yay") end - it "should clean $LOAD_PATH properly", :ruby_repo do + it "should clean $LOAD_PATH properly" do gem_name = "very_simple_binary" full_gem_name = gem_name + "-1.0" ext_dir = File.join(tmp("extensions", full_gem_name)) @@ -802,7 +802,7 @@ end Dir.mkdir(gems_dir) Dir.mkdir(specifications_dir) - FileUtils.ln_s(root, File.join(gems_dir, full_name)) + FileUtils.ln_s(source_root, File.join(gems_dir, full_name)) gemspec_content = File.binread(gemspec). sub("Bundler::VERSION", %("#{Bundler::VERSION}")). @@ -816,9 +816,9 @@ end 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 + ruby <<-R, :env => { "GEM_PATH" => symlinked_gem_home } TracePoint.trace(:class) do |tp| - if tp.path.include?("bundler") && !tp.path.start_with?("#{root}") + if tp.path.include?("bundler") && !tp.path.start_with?("#{source_root}") puts "OMG. Defining a class from another bundler at \#{tp.path}:\#{tp.lineno}" end end @@ -1209,6 +1209,7 @@ end %w[io-console openssl] end << "bundler" exempts << "fiddle" if Gem.win_platform? && Gem::Version.new(Gem::VERSION) >= Gem::Version.new("2.7") + exempts << "uri" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7") exempts end @@ -1273,19 +1274,42 @@ end build_gem "net-http-pipeline", "1.0.1" end - system_gems "net-http-pipeline-1.0.1", :gem_repo => gem_repo4 do - gemfile <<-G - source "#{file_uri_for(gem_repo4)}" - gem "net-http-pipeline", "1.0.1" - G + system_gems "net-http-pipeline-1.0.1", :gem_repo => gem_repo4 + + gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem "net-http-pipeline", "1.0.1" + G + + bundle "config set --local path vendor/bundle" - bundle "config set --local path vendor/bundle" + bundle! :install - bundle! :install + bundle! :check - bundle! :check + expect(out).to eq("The Gemfile's dependencies are satisfied") + end - expect(out).to eq("The Gemfile's dependencies are satisfied") + # bundler respects paths specified direclty in RUBYLIB or RUBYOPT, and + # that happens when running ruby from the ruby-core setup. To + # workaround, we manually remove those for these tests when they would + # override the default gem. + def load_path_exclusions_hack_for(name) + if ruby_core? + ext_folder = source_root.join(".ext/common") + require_name = name.tr("-", "/") + if File.exist?(ext_folder.join("#{require_name}.rb")) + { :exclude_from_load_path => ext_folder.to_s } + else + lib_folder = source_root.join("lib") + if File.exist?(lib_folder.join("#{require_name}.rb")) + { :exclude_from_load_path => lib_folder.to_s } + else + {} + end + end + else + {} end end @@ -1302,7 +1326,8 @@ end gem "#{g}", "999999" G - expect(the_bundle).to include_gem("#{g} 999999", :env => { "RUBYOPT" => activation_warning_hack_rubyopt }) + opts = { :env => { "RUBYOPT" => activation_warning_hack_rubyopt } } + expect(the_bundle).to include_gem("#{g} 999999", opts.merge(load_path_exclusions_hack_for(g))) end it "activates older versions of #{g}" do @@ -1317,7 +1342,8 @@ end gem "#{g}", "0.0.0.a" G - expect(the_bundle).to include_gem("#{g} 0.0.0.a", :env => { "RUBYOPT" => activation_warning_hack_rubyopt }) + opts = { :env => { "RUBYOPT" => activation_warning_hack_rubyopt } } + expect(the_bundle).to include_gem("#{g} 0.0.0.a", opts.merge(load_path_exclusions_hack_for(g))) end end end diff --git a/spec/bundler/runtime/with_unbundled_env_spec.rb b/spec/bundler/runtime/with_unbundled_env_spec.rb index 81e4fcfd6e..2baa785285 100644 --- a/spec/bundler/runtime/with_unbundled_env_spec.rb +++ b/spec/bundler/runtime/with_unbundled_env_spec.rb @@ -39,7 +39,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", <<-'RUBY') count = ARGV.first.to_i exit if count < 0 @@ -61,7 +61,7 @@ RSpec.describe "Bundler.with_env helpers" do EOS end - it "removes variables that bundler added", :ruby_repo do + it "removes variables that bundler added" do # Simulate bundler has not yet been loaded ENV.replace(ENV.to_hash.delete_if {|k, _v| k.start_with?(Bundler::EnvironmentPreserver::BUNDLER_PREFIX) }) @@ -89,11 +89,13 @@ RSpec.describe "Bundler.with_env helpers" do print #{modified_env}['RUBYOPT'] RUBY ENV["RUBYOPT"] = "-W2 -rbundler/setup #{ENV["RUBYOPT"]}" - bundle_exec_ruby! bundled_app("source.rb"), :env => { "BUNDLER_SPEC_DISABLE_DEFAULT_BUNDLER_GEM" => "true" } + simulate_bundler_version_when_missing_prerelease_default_gem_activation do + bundle_exec_ruby! bundled_app("source.rb") + end expect(last_command.stdboth).not_to include("-rbundler/setup") end - it "should restore RUBYLIB", :ruby_repo do + it "should restore RUBYLIB" do create_file("source.rb", <<-RUBY) print #{modified_env}['RUBYLIB'] RUBY @@ -202,7 +204,7 @@ RSpec.describe "Bundler.with_env helpers" do RUBY end - it "runs system inside with_clean_env", :ruby_repo do + it "runs system inside with_clean_env" do run_bundler_script({ "BUNDLE_FOO" => "bar" }, bundled_app("source.rb")) expect($?.exitstatus).to eq(42) end @@ -217,7 +219,7 @@ RSpec.describe "Bundler.with_env helpers" do RUBY end - it "runs system inside with_unbundled_env", :ruby_repo do + it "runs system inside with_unbundled_env" do run_bundler_script({ "BUNDLE_FOO" => "bar" }, bundled_app("source.rb")) expect($?.exitstatus).to eq(42) end |