summaryrefslogtreecommitdiff
path: root/spec/bundler/support
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2019-12-14 19:49:16 +0900
committerSHIBATA Hiroshi <hsbt@ruby-lang.org>2019-12-15 16:41:10 +0900
commit38002a8adbd98266426940d829429a30af0622a4 (patch)
treedb01bcc2653ba0230a07345c4a3c877246dfe473 /spec/bundler/support
parente2b192f7d5b4f0e2133bb6cf03cfc609258826be (diff)
Prepare to release bundler-2.1.0
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2753
Diffstat (limited to 'spec/bundler/support')
-rw-r--r--spec/bundler/support/artifice/compact_index.rb2
-rw-r--r--spec/bundler/support/artifice/compact_index_api_missing.rb2
-rw-r--r--spec/bundler/support/artifice/compact_index_extra_api_missing.rb2
-rw-r--r--spec/bundler/support/artifice/compact_index_extra_missing.rb2
-rw-r--r--spec/bundler/support/artifice/endpoint.rb2
-rw-r--r--spec/bundler/support/artifice/endpoint_api_missing.rb2
-rw-r--r--spec/bundler/support/artifice/endpoint_extra_missing.rb2
-rw-r--r--spec/bundler/support/artifice/windows.rb2
-rw-r--r--spec/bundler/support/helpers.rb11
-rw-r--r--spec/bundler/support/path.rb25
-rw-r--r--spec/bundler/support/rubygems_ext.rb12
-rw-r--r--spec/bundler/support/rubygems_version_manager.rb74
12 files changed, 56 insertions, 82 deletions
diff --git a/spec/bundler/support/artifice/compact_index.rb b/spec/bundler/support/artifice/compact_index.rb
index 89362c4dbc..72abf26224 100644
--- a/spec/bundler/support/artifice/compact_index.rb
+++ b/spec/bundler/support/artifice/compact_index.rb
@@ -10,7 +10,7 @@ class CompactIndexAPI < Endpoint
def load_spec(name, version, platform, gem_repo)
full_name = "#{name}-#{version}"
full_name += "-#{platform}" if platform != "ruby"
- Marshal.load(Bundler.rubygems.inflate(File.open(gem_repo.join("quick/Marshal.4.8/#{full_name}.gemspec.rz")).read))
+ Marshal.load(Bundler.rubygems.inflate(File.binread(gem_repo.join("quick/Marshal.4.8/#{full_name}.gemspec.rz"))))
end
def etag_response
diff --git a/spec/bundler/support/artifice/compact_index_api_missing.rb b/spec/bundler/support/artifice/compact_index_api_missing.rb
index fdd342bc08..6514fde01e 100644
--- a/spec/bundler/support/artifice/compact_index_api_missing.rb
+++ b/spec/bundler/support/artifice/compact_index_api_missing.rb
@@ -10,7 +10,7 @@ class CompactIndexApiMissing < CompactIndexAPI
if params[:id] == "rack-1.0.gemspec.rz"
halt 404
else
- File.read("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
+ File.binread("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
end
end
end
diff --git a/spec/bundler/support/artifice/compact_index_extra_api_missing.rb b/spec/bundler/support/artifice/compact_index_extra_api_missing.rb
index 6bd24ddbb4..b9d757c266 100644
--- a/spec/bundler/support/artifice/compact_index_extra_api_missing.rb
+++ b/spec/bundler/support/artifice/compact_index_extra_api_missing.rb
@@ -9,7 +9,7 @@ class CompactIndexExtraAPIMissing < CompactIndexExtraApi
if params[:id] == "missing-1.0.gemspec.rz"
halt 404
else
- File.read("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
+ File.binread("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
end
end
end
diff --git a/spec/bundler/support/artifice/compact_index_extra_missing.rb b/spec/bundler/support/artifice/compact_index_extra_missing.rb
index 4758b785ac..ff1e47a1bb 100644
--- a/spec/bundler/support/artifice/compact_index_extra_missing.rb
+++ b/spec/bundler/support/artifice/compact_index_extra_missing.rb
@@ -9,7 +9,7 @@ class CompactIndexExtraMissing < CompactIndexExtra
if params[:id] == "missing-1.0.gemspec.rz"
halt 404
else
- File.read("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
+ File.binread("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
end
end
end
diff --git a/spec/bundler/support/artifice/endpoint.rb b/spec/bundler/support/artifice/endpoint.rb
index bf26c56503..7bca681e70 100644
--- a/spec/bundler/support/artifice/endpoint.rb
+++ b/spec/bundler/support/artifice/endpoint.rb
@@ -68,7 +68,7 @@ class Endpoint < Sinatra::Base
def load_spec(name, version, platform, gem_repo)
full_name = "#{name}-#{version}"
full_name += "-#{platform}" if platform != "ruby"
- Marshal.load(Bundler.rubygems.inflate(File.open(gem_repo.join("quick/Marshal.4.8/#{full_name}.gemspec.rz")).read))
+ Marshal.load(Bundler.rubygems.inflate(File.binread(gem_repo.join("quick/Marshal.4.8/#{full_name}.gemspec.rz"))))
end
end
diff --git a/spec/bundler/support/artifice/endpoint_api_missing.rb b/spec/bundler/support/artifice/endpoint_api_missing.rb
index 8dafde7362..755c42e836 100644
--- a/spec/bundler/support/artifice/endpoint_api_missing.rb
+++ b/spec/bundler/support/artifice/endpoint_api_missing.rb
@@ -10,7 +10,7 @@ class EndpointApiMissing < Endpoint
if params[:id] == "rack-1.0.gemspec.rz"
halt 404
else
- File.read("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
+ File.binread("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
end
end
end
diff --git a/spec/bundler/support/artifice/endpoint_extra_missing.rb b/spec/bundler/support/artifice/endpoint_extra_missing.rb
index ee129025ff..5fd9238207 100644
--- a/spec/bundler/support/artifice/endpoint_extra_missing.rb
+++ b/spec/bundler/support/artifice/endpoint_extra_missing.rb
@@ -9,7 +9,7 @@ class EndpointExtraMissing < EndpointExtra
if params[:id] == "missing-1.0.gemspec.rz"
halt 404
else
- File.read("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
+ File.binread("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
end
end
end
diff --git a/spec/bundler/support/artifice/windows.rb b/spec/bundler/support/artifice/windows.rb
index ce7455b86c..21170c81d9 100644
--- a/spec/bundler/support/artifice/windows.rb
+++ b/spec/bundler/support/artifice/windows.rb
@@ -27,7 +27,7 @@ class Windows < Sinatra::Base
files.each do |file|
get "/#{file}" do
- File.read gem_repo.join(file)
+ File.binread gem_repo.join(file)
end
end
diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb
index 911f734d8b..7d1bd65185 100644
--- a/spec/bundler/support/helpers.rb
+++ b/spec/bundler/support/helpers.rb
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require "open3"
-
require_relative "command_execution"
require_relative "the_bundle"
@@ -25,9 +23,7 @@ module Spec
define_method("#{method}!") do |*args, &blk|
send(method, *args, &blk).tap do
unless last_command.success?
- raise RuntimeError,
- "Invoking #{method}!(#{args.map(&:inspect).join(", ")}) failed:\n#{last_command.stdboth}",
- caller.drop_while {|bt| bt.start_with?(__FILE__) }
+ raise "Invoking #{method}!(#{args.map(&:inspect).join(", ")}) failed:\n#{last_command.stdboth}"
end
end
end
@@ -174,7 +170,7 @@ module Spec
env = options.delete(:env) || {}
ruby = ruby.gsub(/["`\$]/) {|m| "\\#{m}" }
lib_option = options[:no_lib] ? "" : " -I#{lib_dir}"
- sys_exec(%(#{Gem.ruby}#{lib_option} -e "#{ruby}"), env)
+ sys_exec(%(#{Gem.ruby}#{lib_option} -w -e "#{ruby}"), env)
end
bang :ruby
@@ -209,8 +205,7 @@ module Spec
def sys_exec(cmd, env = {})
command_execution = CommandExecution.new(cmd.to_s, Dir.pwd)
- env = env.map {|k, v| [k.to_s, v.to_s] }.to_h # convert env keys and values to string
-
+ require "open3"
Open3.popen3(env, cmd.to_s) do |stdin, stdout, stderr, wait_thr|
yield stdin, stdout, wait_thr if block_given?
stdin.close
diff --git a/spec/bundler/support/path.rb b/spec/bundler/support/path.rb
index 6f78490fe8..eea3161b15 100644
--- a/spec/bundler/support/path.rb
+++ b/spec/bundler/support/path.rb
@@ -22,7 +22,7 @@ module Spec
end
def gem_bin
- @gem_bin ||= ruby_core? ? ENV["GEM_COMMAND"] : "#{Gem.ruby} -I#{spec_dir}/rubygems -S gem --backtrace"
+ @gem_bin ||= ruby_core? ? ENV["GEM_COMMAND"] : "#{Gem.ruby} -S gem --backtrace"
end
def spec_dir
@@ -30,23 +30,20 @@ module Spec
end
def tracked_files
- if root != `git rev-parse --show-toplevel`
- skip 'not in git working directory'
- end
+ skip "not in git working directory" unless git_root_dir?
+
@tracked_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler man/bundler*` : `git ls-files -z`
end
def shipped_files
- if root != `git rev-parse --show-toplevel`
- skip 'not in git working directory'
- end
+ skip "not in git working directory" unless git_root_dir?
+
@shipped_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb man/bundler* libexec/bundle*` : `git ls-files -z -- lib man exe CHANGELOG.md LICENSE.md README.md bundler.gemspec`
end
def lib_tracked_files
- if root != `git rev-parse --show-toplevel`
- skip 'not in git working directory'
- end
+ skip "not in git working directory" unless git_root_dir?
+
@lib_tracked_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb` : `git ls-files -z -- lib`
end
@@ -103,8 +100,6 @@ module Spec
protocol = "file://"
root = Gem.win_platform? ? "/" : ""
- return protocol + "localhost" + root + path.to_s if RUBY_VERSION < "2.5"
-
protocol + root + path.to_s
end
@@ -182,5 +177,11 @@ module Spec
end
extend self
+
+ private
+
+ def git_root_dir?
+ root.to_s == `git rev-parse --show-toplevel`.chomp
+ end
end
end
diff --git a/spec/bundler/support/rubygems_ext.rb b/spec/bundler/support/rubygems_ext.rb
index d237897b67..7e9e8328c5 100644
--- a/spec/bundler/support/rubygems_ext.rb
+++ b/spec/bundler/support/rubygems_ext.rb
@@ -5,13 +5,13 @@ require_relative "path"
module Spec
module Rubygems
DEV_DEPS = {
- "automatiek" => "~> 0.2.0",
+ "automatiek" => "~> 0.3.0",
"parallel_tests" => "~> 2.29",
"rake" => "~> 12.0",
"ronn" => "~> 0.7.3",
"rspec" => "~> 3.8",
- "rubocop" => "= 0.74.0",
- "rubocop-performance" => "= 1.4.0",
+ "rubocop" => "= 0.77.0",
+ "rubocop-performance" => "= 1.5.1",
}.freeze
DEPS = {
@@ -39,7 +39,9 @@ module Spec
end
def gem_load(gem_name, bin_container)
- require_relative "../rubygems/rubygems"
+ require_relative "rubygems_version_manager"
+ RubygemsVersionManager.new(ENV["RGV"]).switch
+
gem_load_and_activate(gem_name, bin_container)
end
@@ -65,7 +67,7 @@ module Spec
FileUtils.mkdir_p(Path.base_system_gems)
puts "installing gems for the tests to use..."
install_gems(DEPS)
- manifest_path.open("w") {|f| f << manifest.join }
+ manifest_path.open("wb") {|f| f << manifest.join }
end
FileUtils.mkdir_p(Path.home)
diff --git a/spec/bundler/support/rubygems_version_manager.rb b/spec/bundler/support/rubygems_version_manager.rb
index 356d391c08..854bce890d 100644
--- a/spec/bundler/support/rubygems_version_manager.rb
+++ b/spec/bundler/support/rubygems_version_manager.rb
@@ -8,27 +8,25 @@ class RubygemsVersionManager
include Spec::Helpers
include Spec::Path
- def initialize(env_version)
- @env_version = env_version
+ def initialize(source)
+ @source = source
end
def switch
return if use_system?
- unrequire_rubygems_if_needed
-
switch_local_copy_if_needed
- prepare_environment
+ reexec_if_needed
end
private
def use_system?
- @env_version.nil?
+ @source.nil?
end
- def unrequire_rubygems_if_needed
+ def reexec_if_needed
return unless rubygems_unrequire_needed?
require "rbconfig"
@@ -37,7 +35,8 @@ private
ruby << RbConfig::CONFIG["EXEEXT"]
cmd = [ruby, $0, *ARGV].compact
- cmd[1, 0] = "--disable-gems"
+
+ ENV["RUBYOPT"] = "-I#{local_copy_path.join("lib")} #{ENV["RUBYOPT"]}"
exec(ENV, *cmd)
end
@@ -47,35 +46,28 @@ private
Dir.chdir(local_copy_path) do
sys_exec!("git remote update")
- sys_exec!("git checkout #{target_tag_version} --quiet")
+ sys_exec!("git checkout #{target_tag} --quiet")
end
- end
- def prepare_environment
- $:.unshift File.expand_path("lib", local_copy_path)
+ ENV["RGV"] = local_copy_path.to_s
end
def rubygems_unrequire_needed?
- defined?(Gem::VERSION) && Gem::VERSION != target_gem_version
+ !$LOADED_FEATURES.include?(local_copy_path.join("lib/rubygems.rb").to_s)
end
def local_copy_switch_needed?
- !env_version_is_path? && target_gem_version != local_copy_version
- end
-
- def target_gem_version
- @target_gem_version ||= resolve_target_gem_version
+ !source_is_path? && target_tag != local_copy_tag
end
- def target_tag_version
- @target_tag_version ||= resolve_target_tag_version
+ def target_tag
+ @target_tag ||= resolve_target_tag
end
- def local_copy_version
- gemspec_contents = File.read(local_copy_path.join("lib/rubygems.rb"))
- version_regexp = /VERSION = ["'](.*)["']/
-
- version_regexp.match(gemspec_contents)[1]
+ def local_copy_tag
+ Dir.chdir(local_copy_path) do
+ sys_exec!("git rev-parse --abbrev-ref HEAD")
+ end
end
def local_copy_path
@@ -83,7 +75,7 @@ private
end
def resolve_local_copy_path
- return expanded_env_version if env_version_is_path?
+ return expanded_source if source_is_path?
rubygems_path = root.join("tmp/rubygems")
@@ -95,33 +87,17 @@ private
rubygems_path
end
- def env_version_is_path?
- expanded_env_version.directory?
+ def source_is_path?
+ expanded_source.directory?
end
- def expanded_env_version
- @expanded_env_version ||= Pathname.new(@env_version).expand_path(root)
+ def expanded_source
+ @expanded_source ||= Pathname.new(@source).expand_path(root)
end
- def resolve_target_tag_version
- return "v#{@env_version}" if @env_version.match(/^\d/)
-
- return "master" if @env_version == master_gem_version
-
- @env_version
- end
-
- def resolve_target_gem_version
- return local_copy_version if env_version_is_path?
-
- return @env_version[1..-1] if @env_version.match(/^v/)
-
- return master_gem_version if @env_version == "master"
-
- @env_version
- end
+ def resolve_target_tag
+ return "v#{@source}" if @source.match(/^\d/)
- def master_gem_version
- "3.1.0.pre1"
+ @source
end
end