2018-11-02 19:07:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require "pathname"
|
2019-07-31 20:44:46 -04:00
|
|
|
require "rbconfig"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
module Spec
|
|
|
|
module Path
|
|
|
|
def root
|
|
|
|
@root ||= Pathname.new(ruby_core? ? "../../../.." : "../../..").expand_path(__FILE__)
|
|
|
|
end
|
|
|
|
|
|
|
|
def gemspec
|
2019-02-02 05:41:22 -05:00
|
|
|
@gemspec ||= root.join(ruby_core? ? "lib/bundler/bundler.gemspec" : "bundler.gemspec")
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def bindir
|
2018-11-24 20:20:00 -05:00
|
|
|
@bindir ||= root.join(ruby_core? ? "libexec" : "exe")
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
2019-08-15 12:12:34 -04:00
|
|
|
def gem_bin
|
2019-08-15 12:13:06 -04:00
|
|
|
@gem_bin ||= ruby_core? ? ENV["BUNDLE_GEM"] : "#{Gem.ruby} -S gem --backtrace"
|
2019-08-15 12:12:34 -04:00
|
|
|
end
|
|
|
|
|
2018-11-02 19:07:56 -04:00
|
|
|
def spec_dir
|
|
|
|
@spec_dir ||= root.join(ruby_core? ? "spec/bundler" : "spec")
|
|
|
|
end
|
|
|
|
|
|
|
|
def tmp(*path)
|
|
|
|
root.join("tmp", *path)
|
|
|
|
end
|
|
|
|
|
|
|
|
def home(*path)
|
|
|
|
tmp.join("home", *path)
|
|
|
|
end
|
|
|
|
|
|
|
|
def default_bundle_path(*path)
|
2019-01-04 08:10:58 -05:00
|
|
|
if Bundler::VERSION.split(".").first.to_i < 3
|
2018-11-02 19:07:56 -04:00
|
|
|
system_gem_path(*path)
|
|
|
|
else
|
2019-07-31 20:44:46 -04:00
|
|
|
bundled_app(*[".bundle", ENV.fetch("BUNDLER_SPEC_RUBY_ENGINE", Gem.ruby_engine), RbConfig::CONFIG["ruby_version"], *path].compact)
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def bundled_app(*path)
|
|
|
|
root = tmp.join("bundled_app")
|
|
|
|
FileUtils.mkdir_p(root)
|
|
|
|
root.join(*path)
|
|
|
|
end
|
|
|
|
|
|
|
|
alias_method :bundled_app1, :bundled_app
|
|
|
|
|
|
|
|
def bundled_app2(*path)
|
|
|
|
root = tmp.join("bundled_app2")
|
|
|
|
FileUtils.mkdir_p(root)
|
|
|
|
root.join(*path)
|
|
|
|
end
|
|
|
|
|
|
|
|
def vendored_gems(path = nil)
|
2019-07-31 20:44:46 -04:00
|
|
|
bundled_app(*["vendor/bundle", Gem.ruby_engine, RbConfig::CONFIG["ruby_version"], path].compact)
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def cached_gem(path)
|
|
|
|
bundled_app("vendor/cache/#{path}.gem")
|
|
|
|
end
|
|
|
|
|
|
|
|
def base_system_gems
|
|
|
|
tmp.join("gems/base")
|
|
|
|
end
|
|
|
|
|
2019-05-06 12:06:21 -04:00
|
|
|
def file_uri_for(path)
|
|
|
|
protocol = "file://"
|
2019-05-05 13:00:47 -04:00
|
|
|
root = Gem.win_platform? ? "/" : ""
|
2019-05-06 12:06:21 -04:00
|
|
|
|
2019-05-05 13:00:47 -04:00
|
|
|
return protocol + "localhost" + root + path.to_s if RUBY_VERSION < "2.5"
|
2019-05-06 12:06:21 -04:00
|
|
|
|
2019-05-05 13:00:47 -04:00
|
|
|
protocol + root + path.to_s
|
2019-05-06 12:06:21 -04:00
|
|
|
end
|
|
|
|
|
2018-11-02 19:07:56 -04:00
|
|
|
def gem_repo1(*args)
|
|
|
|
tmp("gems/remote1", *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def gem_repo_missing(*args)
|
|
|
|
tmp("gems/missing", *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def gem_repo2(*args)
|
|
|
|
tmp("gems/remote2", *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def gem_repo3(*args)
|
|
|
|
tmp("gems/remote3", *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def gem_repo4(*args)
|
|
|
|
tmp("gems/remote4", *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def security_repo(*args)
|
|
|
|
tmp("gems/security_repo", *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def system_gem_path(*path)
|
|
|
|
tmp("gems/system", *path)
|
|
|
|
end
|
|
|
|
|
|
|
|
def lib_path(*args)
|
|
|
|
tmp("libs", *args)
|
|
|
|
end
|
|
|
|
|
2019-08-06 07:16:15 -04:00
|
|
|
def lib
|
|
|
|
root.join("lib")
|
|
|
|
end
|
|
|
|
|
2018-11-02 19:07:56 -04:00
|
|
|
def global_plugin_gem(*args)
|
|
|
|
home ".bundle", "plugin", "gems", *args
|
|
|
|
end
|
|
|
|
|
|
|
|
def local_plugin_gem(*args)
|
|
|
|
bundled_app ".bundle", "plugin", "gems", *args
|
|
|
|
end
|
|
|
|
|
|
|
|
def tmpdir(*args)
|
|
|
|
tmp "tmpdir", *args
|
|
|
|
end
|
|
|
|
|
|
|
|
def ruby_core?
|
|
|
|
# avoid to wornings
|
|
|
|
@ruby_core ||= nil
|
|
|
|
|
|
|
|
if @ruby_core.nil?
|
|
|
|
@ruby_core = true & (ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"])
|
|
|
|
else
|
|
|
|
@ruby_core
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
extend self
|
|
|
|
end
|
|
|
|
end
|