aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-09 11:30:32 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-09 11:30:32 +0000
commitc2bf2a144795888cea3e3e8d78c98992f1d7081f (patch)
treec7054c662de899404f25fc93c62bf8f0c5b3765f /spec
parentef28eedced9ffd55f62480ba06a8b73f9c431839 (diff)
downloadruby-c2bf2a144795888cea3e3e8d78c98992f1d7081f.tar.gz
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
Diffstat (limited to 'spec')
-rw-r--r--spec/bundler/support/helpers.rb2
-rw-r--r--spec/bundler/support/path.rb42
-rw-r--r--spec/bundler/support/rubygems_ext.rb2
3 files changed, 16 insertions, 30 deletions
diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb
index 1a3fec1960..691e7381ff 100644
--- a/spec/bundler/support/helpers.rb
+++ b/spec/bundler/support/helpers.rb
@@ -104,7 +104,7 @@ module Spec
load_path_str = "-I#{load_path.join(File::PATH_SEPARATOR)}"
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|
v == true ? " --#{k}" : " --#{k} #{v}" if v
end.join
diff --git a/spec/bundler/support/path.rb b/spec/bundler/support/path.rb
index f28d660e83..b58658e71a 100644
--- a/spec/bundler/support/path.rb
+++ b/spec/bundler/support/path.rb
@@ -4,43 +4,20 @@ require "pathname"
module Spec
module Path
def root
- if !!(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"])
- # for Ruby Core
- root_path = File.expand_path("../../../..", __FILE__)
- else
- root_path = File.expand_path("../../..", __FILE__)
- end
- @root ||= Pathname.new(root_path)
+ @root ||=
+ Pathname.new(for_ruby_core? ? "../../../.." : "../../..").expand_path(__FILE__)
end
def gemspec
- if !!(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"])
- # 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)
+ @gemspec ||= root.join(for_ruby_core? ? "lib/bundler.gemspec" : "bundler.gemspec")
end
def bindir
- if !!(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"])
- # 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)
+ @bindir ||= root.join(for_ruby_core? ? "bin" : "exe")
end
def spec_dir
- if !!(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"])
- # 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)
+ @spec_dir ||= root.join(for_ruby_core? ? "spec/bundler" : "spec")
end
def tmp(*path)
@@ -130,5 +107,14 @@ module Spec
end
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
diff --git a/spec/bundler/support/rubygems_ext.rb b/spec/bundler/support/rubygems_ext.rb
index 5229192165..596e1530d2 100644
--- a/spec/bundler/support/rubygems_ext.rb
+++ b/spec/bundler/support/rubygems_ext.rb
@@ -31,7 +31,7 @@ module Spec
ENV["BUNDLE_PATH"] = nil
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_path = "#{Path.base_system_gems}/manifest.txt"