From 8b35686ed50570833abaf91fb86921b01fd554e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Sun, 9 Sep 2018 09:21:49 -0300 Subject: [PATCH 1/4] Improve spec There's an option to explicitly not pass lib to the LOAD_PATH. --- spec/runtime/setup_spec.rb | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 7fec55c4c39..3d8ab4e0be5 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -886,14 +886,7 @@ def clean_load_path(lp) ENV["GEM_PATH"] = symlinked_gem_home.path - ruby <<-R - if $LOAD_PATH.include?("#{bundler_lib}") - # We should use bundler from GEM_PATH for this test, so we should - # remove path to the bundler source tree - $LOAD_PATH.delete("#{bundler_lib}") - else - raise "We don't have #{bundler_lib} in $LOAD_PATH" - end + ruby <<-R, :no_lib => true puts (require 'bundler/setup') R From 5914154fab828f762c815b7d72cbdc2d4694bd1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Sun, 9 Sep 2018 09:27:41 -0300 Subject: [PATCH 2/4] Modify env only in subprocess --- spec/runtime/setup_spec.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 3d8ab4e0be5..5a632f83914 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -884,9 +884,7 @@ def clean_load_path(lp) it "should successfully require 'bundler/setup'" do install_gemfile "" - ENV["GEM_PATH"] = symlinked_gem_home.path - - ruby <<-R, :no_lib => true + ruby <<-R, :env => { "GEM_PATH" => symlinked_gem_home.path }, :no_lib => true puts (require 'bundler/setup') R From 75ac1fe72ae495a04f44a3701140c4e28eafefc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Sun, 9 Sep 2018 09:28:28 -0300 Subject: [PATCH 3/4] Move common stuff to inside let --- spec/runtime/setup_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 5a632f83914..88f4807e35d 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -859,12 +859,12 @@ def clean_load_path(lp) context "with bundler is located in symlinked GEM_HOME" do let(:gem_home) { Dir.mktmpdir } - let(:symlinked_gem_home) { Tempfile.new("gem_home") } + let(:symlinked_gem_home) { Tempfile.new("gem_home").path } let(:bundler_dir) { File.expand_path("../../..", __FILE__) } let(:bundler_lib) { File.join(bundler_dir, "lib") } before do - FileUtils.ln_sf(gem_home, symlinked_gem_home.path) + FileUtils.ln_sf(gem_home, symlinked_gem_home) gems_dir = File.join(gem_home, "gems") specifications_dir = File.join(gem_home, "specifications") Dir.mkdir(gems_dir) @@ -884,7 +884,7 @@ def clean_load_path(lp) it "should successfully require 'bundler/setup'" do install_gemfile "" - ruby <<-R, :env => { "GEM_PATH" => symlinked_gem_home.path }, :no_lib => true + ruby <<-R, :env => { "GEM_PATH" => symlinked_gem_home }, :no_lib => true puts (require 'bundler/setup') R From 6590fd50f71a0e4e0e3d1204299eb0d6d7768ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Sun, 9 Sep 2018 14:48:46 -0300 Subject: [PATCH 4/4] Friendlier solution for a problematic spec --- spec/runtime/setup_spec.rb | 6 +++++- spec/spec_helper.rb | 12 ------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 88f4807e35d..d398a6ae8a3 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -884,7 +884,11 @@ def clean_load_path(lp) it "should successfully require 'bundler/setup'" do install_gemfile "" - ruby <<-R, :env => { "GEM_PATH" => symlinked_gem_home }, :no_lib => true + ruby <<-'R', :env => { "GEM_PATH" => symlinked_gem_home }, :no_lib => true + # Remove any bundler that's not the current bundler from $LOAD_PATH + $LOAD_PATH.each do |path| + $LOAD_PATH.delete(path) if File.exist?("#{path}/bundler.rb") + end puts (require 'bundler/setup') R diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 56094b72f53..228b9e5aa3a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -28,18 +28,6 @@ module Gem require "uri" require "digest" -# Delete the default copy of Bundler that RVM installs for us when running in CI -require "fileutils" -if ENV.select {|k, _v| k =~ /TRAVIS/ }.any? && Gem::Version.new(Gem::VERSION) > Gem::Version.new("2.0") - Dir.glob(File.join(Gem::Specification.default_specifications_dir, "bundler*.gemspec")).each do |file| - FileUtils.rm_rf(file) - end - - Dir.glob(File.join(RbConfig::CONFIG["sitelibdir"], "bundler*")).each do |file| - FileUtils.rm_rf(file) - end -end - if File.expand_path(__FILE__) =~ %r{([^\w/\.-])} abort "The bundler specs cannot be run from a path that contains special characters (particularly #{$1.inspect})" end