summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSHIBATA Hiroshi <hsbt@ruby-lang.org>2018-10-16 20:45:45 +0900
committerSHIBATA Hiroshi <hsbt@ruby-lang.org>2018-10-20 20:00:39 +0900
commit5417b218c499db48b23de2bdc38ba2f33d3223c0 (patch)
tree8556a1c1d8e5811f86d2e63b931c1212ae40413a
parentce655f16ca1cc4b07af4bb981c20636bc6b02c84 (diff)
downloadbundler-5417b218c499db48b23de2bdc38ba2f33d3223c0.tar.gz
Added to support BUNDLE_RUBY and BUNDLE_GEM environmental variables.
They are replaced build binary on ruby core repository.
-rw-r--r--lib/bundler/shared_helpers.rb10
-rw-r--r--spec/bundler/cli_spec.rb3
-rw-r--r--spec/commands/newgem_spec.rb5
-rw-r--r--spec/spec_helper.rb19
-rw-r--r--spec/support/helpers.rb3
-rw-r--r--spec/support/path.rb20
6 files changed, 50 insertions, 10 deletions
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index 28699dc61f..9d5684aeaf 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -274,9 +274,13 @@ module Bundler
until !File.directory?(current) || current == previous
if ENV["BUNDLE_SPEC_RUN"]
- gemspec = File.join(current, "bundler.gemspec")
- # for Ruby Core
- gemspec = File.join(current, "lib/bundler.gemspec") unless File.file?(gemspec)
+ # avoid stepping above the tmp directory when testing
+ if !!(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"])
+ # for Ruby Core
+ gemspec = "lib/bundler.gemspec"
+ else
+ gemspec = "bundler.gemspec"
+ end
# avoid stepping above the tmp directory when testing
return nil if File.file?(File.join(current, gemspec))
diff --git a/spec/bundler/cli_spec.rb b/spec/bundler/cli_spec.rb
index 73868d10fb..c82383cabf 100644
--- a/spec/bundler/cli_spec.rb
+++ b/spec/bundler/cli_spec.rb
@@ -15,7 +15,8 @@ RSpec.describe "bundle executable" do
it "looks for a binary and executes it if it's named bundler-<task>" do
File.open(tmp("bundler-testtasks"), "w", 0o755) do |f|
- f.puts "#!/usr/bin/env ruby\nputs 'Hello, world'\n"
+ ruby = ENV['BUNDLE_RUBY'] || "/usr/bin/env ruby"
+ f.puts "#!#{ruby}\nputs 'Hello, world'\n"
end
with_path_added(tmp) do
diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb
index 598d68ec3a..cfea63ece5 100644
--- a/spec/commands/newgem_spec.rb
+++ b/spec/commands/newgem_spec.rb
@@ -211,7 +211,10 @@ RSpec.describe "bundle gem" do
end
Dir.chdir(bundled_app("newgem")) do
- system_gems ["rake-10.0.2", :bundler], :path => :bundle_path
+ gems = ["rake-10.0.2", :bundler]
+ # for Ruby core repository, Ruby 2.6+ has bundler as standard library.
+ gems.delete(:bundler) if ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]
+ system_gems gems, :path => :bundle_path
bundle! "exec rake build"
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 1091c0b7f3..f39a4509a2 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -52,6 +52,12 @@ ENV["THOR_COLUMNS"] = "10000"
Spec::CodeClimate.setup
+module Gem
+ def self.ruby= ruby
+ @ruby = ruby
+ end
+end
+
RSpec.configure do |config|
config.include Spec::Builders
config.include Spec::Helpers
@@ -107,6 +113,13 @@ RSpec.configure do |config|
mocks.allow_message_expectations_on_nil = false
end
+ config.before :suite do
+ if ENV['BUNDLE_RUBY']
+ @orig_ruby = Gem.ruby
+ Gem.ruby = ENV['BUNDLE_RUBY']
+ end
+ end
+
config.before :all do
build_repo1
end
@@ -131,4 +144,10 @@ RSpec.configure do |config|
Dir.chdir(original_wd)
ENV.replace(original_env)
end
+
+ config.after :suite do
+ if ENV['BUNDLE_RUBY']
+ Gem.ruby = @orig_ruby
+ end
+ end
end
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index 87d6152522..e5ff90785e 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -212,7 +212,8 @@ module Spec
args = args.gsub(/(?=")/, "\\")
args = %("#{args}")
end
- sys_exec("#{Gem.ruby} -rrubygems -S gem --backtrace #{command} #{args}")
+ gem = ENV['BUNDLE_GEM'] || "#{Gem.ruby} -rrubygems -S gem --backtrace"
+ sys_exec("#{gem} #{command} #{args}")
end
bang :gem_command
diff --git a/spec/support/path.rb b/spec/support/path.rb
index 8dd8f5a277..d57a2282f0 100644
--- a/spec/support/path.rb
+++ b/spec/support/path.rb
@@ -5,19 +5,19 @@ require "pathname"
module Spec
module Path
def root
- @root ||= Pathname.new(File.expand_path("../../..", __FILE__))
+ @root ||= Pathname.new(for_ruby_core? ? "../../../.." : "../../..").expand_path(__FILE__)
end
def gemspec
- @gemspec ||= root.join("bundler.gemspec")
+ @gemspec ||= root.join(for_ruby_core? ? "lib/bundler.gemspec" : "bundler.gemspec")
end
def bindir
- @bindir ||= root.join("exe")
+ @bindir ||= root.join(for_ruby_core? ? "bin" : "exe")
end
def spec_dir
- @spec_dir ||= root.join("spec")
+ @spec_dir ||= root.join(for_ruby_core? ? "spec/bundler" : "spec")
end
def tmp(*path)
@@ -111,5 +111,17 @@ module Spec
end
extend self
+
+ private
+ def for_ruby_core?
+ # avoid to wornings
+ @for_ruby_core ||= nil
+
+ if @for_ruby_core.nil?
+ @for_ruby_core = true & (ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"])
+ else
+ @for_ruby_core
+ end
+ end
end
end