diff options
Diffstat (limited to 'spec/bundler/support/path.rb')
-rw-r--r-- | spec/bundler/support/path.rb | 66 |
1 files changed, 44 insertions, 22 deletions
diff --git a/spec/bundler/support/path.rb b/spec/bundler/support/path.rb index a98ef7c6cf..7352d5a353 100644 --- a/spec/bundler/support/path.rb +++ b/spec/bundler/support/path.rb @@ -30,7 +30,7 @@ module Spec end def test_gemfile - @test_gemfile ||= source_root.join("tool/bundler/test_gems.rb") + @test_gemfile ||= tool_dir.join("test_gems.rb") end def rubocop_gemfile @@ -42,7 +42,7 @@ module Spec end def dev_gemfile - @dev_gemfile ||= git_root.join("dev_gems.rb") + @dev_gemfile ||= tool_dir.join("dev_gems.rb") end def bindir @@ -71,10 +71,6 @@ module Spec @spec_dir ||= source_root.join(ruby_core? ? "spec/bundler" : "spec") end - def api_request_limit_hack_file - spec_dir.join("support/api_request_limit_hax.rb") - end - def man_dir @man_dir ||= lib_dir.join("bundler/man") end @@ -84,7 +80,13 @@ module Spec end def shipped_files - @shipped_files ||= loaded_gemspec.files + @shipped_files ||= if ruby_core_tarball? + loaded_gemspec.files.map {|f| f.gsub(%r{^exe/}, "libexec/") } + elsif ruby_core? + tracked_files + else + loaded_gemspec.files + end end def lib_tracked_files @@ -118,6 +120,14 @@ module Spec end end + def default_cache_path(*path) + if Bundler.feature_flag.global_gem_cache? + home(".bundle/cache", *path) + else + default_bundle_path("cache/bundler", *path) + end + end + def bundled_app(*path) root = tmp.join("bundled_app") FileUtils.mkdir_p(root) @@ -146,6 +156,10 @@ module Spec bundled_app("Gemfile.lock") end + def base_system_gem_path + scoped_gem_path(base_system_gems) + end + def base_system_gems tmp.join("gems/base") end @@ -217,13 +231,6 @@ module Spec root.join("lib") end - # Sometimes rubygems version under test does not include - # https://github.com/rubygems/rubygems/pull/2728 and will not always end up - # activating the current bundler. In that case, require bundler absolutely. - def entrypoint - Gem.rubygems_version < Gem::Version.new("3.1.a") ? "#{lib_dir}/bundler" : "bundler" - end - def global_plugin_gem(*args) home ".bundle", "plugin", "gems", *args end @@ -243,6 +250,13 @@ module Spec File.open(version_file, "w") {|f| f << contents } end + def replace_required_ruby_version(version, dir:) + gemspec_file = File.expand_path("bundler.gemspec", dir) + contents = File.read(gemspec_file) + contents.sub!(/(^\s+s\.required_ruby_version\s*=\s*)"[^"]+"/, %(\\1"#{version}")) + File.open(gemspec_file, "w") {|f| f << contents } + end + def ruby_core? # avoid to warnings @ruby_core ||= nil @@ -254,16 +268,20 @@ module Spec end end + def git_root + ruby_core? ? source_root : source_root.parent + end + private def git_ls_files(glob) skip "Not running on a git context, since running tests from a tarball" if ruby_core_tarball? - sys_exec("git ls-files -z -- #{glob}", :dir => source_root).split("\x0") + sys_exec("git ls-files -z -- #{glob}", dir: source_root).split("\x0") end def tracked_files_glob - ruby_core? ? "lib/bundler lib/bundler.rb spec/bundler man/bundle*" : "" + ruby_core? ? "libexec/bundle* lib/bundler lib/bundler.rb spec/bundler man/bundle*" : "lib exe spec CHANGELOG.md LICENSE.md README.md bundler.gemspec" end def lib_tracked_files_glob @@ -274,20 +292,24 @@ module Spec ruby_core? ? "man/bundle* man/gemfile*" : "lib/bundler/man/bundle*.1 lib/bundler/man/gemfile*.5" end - def git_root - ruby_core? ? source_root : source_root.parent - end - def ruby_core_tarball? !git_root.join(".git").directory? end def rubocop_gemfile_basename - source_root.join("tool/bundler/#{RUBY_VERSION.start_with?("2.3") ? "rubocop23_gems.rb" : "rubocop_gems.rb"}") + tool_dir.join("rubocop_gems.rb") end def standard_gemfile_basename - source_root.join("tool/bundler/#{RUBY_VERSION.start_with?("2.3") ? "standard23_gems.rb" : "standard_gems.rb"}") + tool_dir.join("standard_gems.rb") + end + + def tool_dir + ruby_core? ? source_root.join("tool/bundler") : source_root.join("../tool/bundler") + end + + def templates_dir + lib_dir.join("bundler", "templates") end extend self |