summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2019-04-08 16:59:02 +0000
committerBundlerbot <bot@bundler.io>2019-04-08 16:59:02 +0000
commitf827947b48c9265bb0d5d4cfe77cc5e9aad3d0c6 (patch)
tree155f012086b8665806a65c78704203950b242a2b
parent48e767da514bb2280b7694a97797eab3904f0442 (diff)
parent7ca4e5bb4e80a0ed1845b7f609279003898345ce (diff)
downloadbundler-f827947b48c9265bb0d5d4cfe77cc5e9aad3d0c6.tar.gz
Merge #6951
6951: Fix symlink spec on ruby 2.6 r=deivid-rodriguez a=deivid-rodriguez ### What was the end-user problem that led to this PR? The problem was that we were skipping this test on ruby 2.6. Skipping tests on old versions is not much of a problem, but doing it on the latest version is opening the door for regressions. So I want to fix it. ### What was your diagnosis of the problem? My diagnosis was that since bundler is now a default gem, that bundler version is being activated by the spec, but since we are on a 2.0.1 locked bundle, the spec runs into a version mismatch error. ### What is your fix for the problem, implemented in this PR? My fix is to enable the `Kernel.require` rubygems monkeypatch for this case (the `bundle` gem itself), that requires default gem files without activating the specific default version, and thus not forcing end users to use that. Since... that's exactly the problem here. ### Why did you choose this fix out of the possible options? I chose this fix because it makes sense to me. Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
-rw-r--r--spec/runtime/setup_spec.rb27
1 files changed, 14 insertions, 13 deletions
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index 2816410a7e..ac8170d2e1 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -1,5 +1,8 @@
# frozen_string_literal: true
+require "tmpdir"
+require "tempfile"
+
RSpec.describe "Bundler.setup" do
describe "with no arguments" do
it "makes all groups available" do
@@ -804,7 +807,7 @@ end
let(:gem_home) { Dir.mktmpdir }
let(:symlinked_gem_home) { Tempfile.new("gem_home").path }
let(:bundler_dir) { ruby_core? ? File.expand_path("../../../..", __FILE__) : File.expand_path("../../..", __FILE__) }
- let(:bundler_lib) { File.join(bundler_dir, "lib") }
+ let(:full_name) { "bundler-#{Bundler::VERSION}" }
before do
FileUtils.ln_sf(gem_home, symlinked_gem_home)
@@ -813,32 +816,30 @@ end
Dir.mkdir(gems_dir)
Dir.mkdir(specifications_dir)
- FileUtils.ln_s(bundler_dir, File.join(gems_dir, "bundler-#{Bundler::VERSION}"))
+ FileUtils.ln_s(bundler_dir, File.join(gems_dir, full_name))
gemspec_file = ruby_core? ? "#{bundler_dir}/lib/bundler/bundler.gemspec" : "#{bundler_dir}/bundler.gemspec"
- gemspec = File.read(gemspec_file).
+ gemspec = File.binread(gemspec_file).
sub("Bundler::VERSION", %("#{Bundler::VERSION}"))
gemspec = gemspec.lines.reject {|line| line =~ %r{lib/bundler/version} }.join
- File.open(File.join(specifications_dir, "bundler.gemspec"), "wb") do |f|
+ File.open(File.join(specifications_dir, "#{full_name}.gemspec"), "wb") do |f|
f.write(gemspec)
end
end
- # Can't make this pass on 2.6 since the ruby standard library has the same $LOAD_PATH
- # entry as bundler (since it's a default gem)
- it "should successfully require 'bundler/setup'", :ruby_repo, :ruby => "< 2.6" do
+ it "should not remove itself from the LOAD_PATH and require a different copy of 'bundler/setup'", :ruby_repo do
install_gemfile ""
- 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")
+ ruby <<-R, :env => { "GEM_PATH" => symlinked_gem_home }, :no_lib => true
+ TracePoint.trace(:class) do |tp|
+ puts "OMG" if tp.path.include?("bundler") && !tp.path.start_with?("#{File.expand_path("../..", __dir__)}")
end
- puts (require 'bundler/setup')
+ gem 'bundler', '#{Bundler::VERSION}'
+ require 'bundler/setup'
R
- expect(out).to eql("true")
+ expect(out).to be_empty
end
end