summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-05-07 23:56:16 +0200
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-05-16 15:44:53 -0400
commitd5729d251b54d7272fd1e0d675c37b7ac5618a35 (patch)
tree211709203dde6d3fc932db5d344347fd2fc5ec49 /lib
parent97c8e428318c6dab46ccef5c00d4c096d31d41fe (diff)
downloadbundler-better_test_specific_file_searching.tar.gz
Previous approach for not walking further up from test folderbetter_test_specific_file_searching
I tried monkeypatching the gemfile finder methods in hax.rb, but that resulted in loading parts of bundler too early, and getting redefinition warnings when loading them again from exe/bundle, resulting in actual errors in some cases. The fix for that required eagerly loading the monkeypatched parts of bundler, but that involves changing lib just for the sake of making existing tests pass, and that's what the original changes intend to avoid. So, I'm just reverting to the previous approach of setting an environment variable just for testing and check that. Reverts 11597fef24274bf1542384512faed697d7f41e3b.
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/shared_helpers.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index da2a384d29..d259f20e6b 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -253,6 +253,19 @@ module Bundler
current = File.expand_path(SharedHelpers.pwd).untaint
until !File.directory?(current) || current == previous
+ if ENV["BUNDLE_SPEC_RUN"]
+ # avoid stepping above the tmp directory when testing
+ gemspec = if ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]
+ # for Ruby Core
+ "lib/bundler/bundler.gemspec"
+ else
+ "bundler.gemspec"
+ end
+
+ # avoid stepping above the tmp directory when testing
+ return nil if File.file?(File.join(current, gemspec))
+ end
+
names.each do |name|
filename = File.join(current, name)
yield filename