1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

spec/bundler/support: paths for ruby core

* spec/bundler/support/path.rb (Spec::Path#for_ruby_core?): helper
  method to tell whether running in Ruby Core or not.

* spec/bundler/support/helpers.rb (Spec::Helpers#bundle): use
  Path.bindir for ruby core case.

* spec/bundler/support/rubygems_ext.rb (Spec::Rubygems.setup):
  ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-09-09 11:30:32 +00:00
parent 4054b123d4
commit 19ae6bc70d
3 changed files with 16 additions and 30 deletions

View file

@ -104,7 +104,7 @@ module Spec
load_path_str = "-I#{load_path.join(File::PATH_SEPARATOR)}" load_path_str = "-I#{load_path.join(File::PATH_SEPARATOR)}"
env = (options.delete(:env) || {}).map {|k, v| "#{k}='#{v}'" }.join(" ") env = (options.delete(:env) || {}).map {|k, v| "#{k}='#{v}'" }.join(" ")
env["PATH"].gsub!("#{Path.root}/exe", "") if env["PATH"] && system_bundler env["PATH"].gsub!(Path.bindir, "") if env["PATH"] && system_bundler
args = options.map do |k, v| args = options.map do |k, v|
v == true ? " --#{k}" : " --#{k} #{v}" if v v == true ? " --#{k}" : " --#{k} #{v}" if v
end.join end.join

View file

@ -4,43 +4,20 @@ require "pathname"
module Spec module Spec
module Path module Path
def root def root
if !!(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]) @root ||=
# for Ruby Core Pathname.new(for_ruby_core? ? "../../../.." : "../../..").expand_path(__FILE__)
root_path = File.expand_path("../../../..", __FILE__)
else
root_path = File.expand_path("../../..", __FILE__)
end
@root ||= Pathname.new(root_path)
end end
def gemspec def gemspec
if !!(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]) @gemspec ||= root.join(for_ruby_core? ? "lib/bundler.gemspec" : "bundler.gemspec")
# for Ruby Core
gemspec_path = File.expand_path(root.join("lib/bundler.gemspec"), __FILE__)
else
gemspec_path = File.expand_path(root.join("bundler.gemspec"), __FILE__)
end
@gemspec ||= Pathname.new(gemspec_path)
end end
def bindir def bindir
if !!(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]) @bindir ||= root.join(for_ruby_core? ? "bin" : "exe")
# for Ruby Core
bin_path = File.expand_path(root.join("bin"), __FILE__)
else
bin_path = File.expand_path(root.join("exe"), __FILE__)
end
@bindir ||= Pathname.new(bin_path)
end end
def spec_dir def spec_dir
if !!(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]) @spec_dir ||= root.join(for_ruby_core? ? "spec/bundler" : "spec")
# for Ruby Core
spec_path = File.expand_path(root.join("spec/bundler"), __FILE__)
else
spec_path = File.expand_path(root.join("spec"), __FILE__)
end
@spec_dir ||= Pathname.new(spec_path)
end end
def tmp(*path) def tmp(*path)
@ -130,5 +107,14 @@ module Spec
end end
extend self extend self
private
def for_ruby_core?
if @for_ruby_core.nil?
@for_ruby_core = true & (ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"])
else
@for_ruby_core
end
end
end end
end end

View file

@ -31,7 +31,7 @@ module Spec
ENV["BUNDLE_PATH"] = nil ENV["BUNDLE_PATH"] = nil
ENV["GEM_HOME"] = ENV["GEM_PATH"] = Path.base_system_gems.to_s ENV["GEM_HOME"] = ENV["GEM_PATH"] = Path.base_system_gems.to_s
ENV["PATH"] = ["#{Path.root}/exe", "#{Path.system_gem_path}/bin", ENV["PATH"]].join(File::PATH_SEPARATOR) ENV["PATH"] = [Path.bindir, "#{Path.system_gem_path}/bin", ENV["PATH"]].join(File::PATH_SEPARATOR)
manifest = DEPS.to_a.sort_by(&:first).map {|k, v| "#{k} => #{v}\n" } manifest = DEPS.to_a.sort_by(&:first).map {|k, v| "#{k} => #{v}\n" }
manifest_path = "#{Path.base_system_gems}/manifest.txt" manifest_path = "#{Path.base_system_gems}/manifest.txt"