Merge RubyGems/Bundler master

from bfb0ae6977
This commit is contained in:
Hiroshi SHIBATA 2022-12-12 09:09:23 +09:00
parent f1cdc129d4
commit bbe56a6437
Notes: git 2022-12-12 01:50:02 +00:00
58 changed files with 330 additions and 569 deletions

View File

@ -29,8 +29,8 @@ Gem::Specification.new do |s|
"source_code_uri" => "https://github.com/rubygems/rubygems/tree/master/bundler",
}
s.required_ruby_version = ">= 2.3.0"
s.required_rubygems_version = ">= 2.5.2"
s.required_ruby_version = ">= 2.6.0"
s.required_rubygems_version = ">= 3.0.1"
s.files = Dir.glob("lib/bundler{.rb,/**/*}", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }

View File

@ -40,7 +40,7 @@ module Bundler
raise InvalidOption, "Please specify gems to add." if gems.empty?
version.to_a.each do |v|
raise InvalidOption, "Invalid gem requirement pattern '#{v}'" unless Gem::Requirement::PATTERN =~ v.to_s
raise InvalidOption, "Invalid gem requirement pattern '#{v}'" unless Gem::Requirement::PATTERN.match?(v.to_s)
end
end
end

View File

@ -73,12 +73,10 @@ module Bundler
definition.specs.each do |spec|
bundles_for_gem(spec).each do |bundle|
bad_paths = dylibs(bundle).select do |f|
begin
Fiddle.dlopen(f)
false
rescue Fiddle::DLError
true
end
Fiddle.dlopen(f)
false
rescue Fiddle::DLError
true
end
if bad_paths.any?
broken_links[spec] ||= []

View File

@ -270,7 +270,7 @@ module Bundler
Bundler.ui.info hint_text("test")
result = Bundler.ui.ask "Enter a test framework. rspec/minitest/test-unit/(none):"
if result =~ /rspec|minitest|test-unit/
if /rspec|minitest|test-unit/.match?(result)
test_framework = result
else
test_framework = false
@ -311,7 +311,7 @@ module Bundler
Bundler.ui.info hint_text("ci")
result = Bundler.ui.ask "Enter a CI service. github/travis/gitlab/circle/(none):"
if result =~ /github|travis|gitlab|circle/
if /github|travis|gitlab|circle/.match?(result)
ci_template = result
else
ci_template = false
@ -342,7 +342,7 @@ module Bundler
Bundler.ui.info hint_text("linter")
result = Bundler.ui.ask "Enter a linter. rubocop/standard/(none):"
if result =~ /rubocop|standard/
if /rubocop|standard/.match?(result)
linter_template = result
else
linter_template = false
@ -389,7 +389,7 @@ module Bundler
end
def ensure_safe_gem_name(name, constant_array)
if name =~ /^\d/
if /^\d/.match?(name)
Bundler.ui.error "Invalid gem name #{name} Please give a name which does not start with numbers."
exit 1
end
@ -416,28 +416,15 @@ module Bundler
end
def required_ruby_version
if Gem.ruby_version < Gem::Version.new("2.4.a") then "2.3.0"
elsif Gem.ruby_version < Gem::Version.new("2.5.a") then "2.4.0"
elsif Gem.ruby_version < Gem::Version.new("2.6.a") then "2.5.0"
else
"2.6.0"
end
"2.6.0"
end
def rubocop_version
if Gem.ruby_version < Gem::Version.new("2.4.a") then "0.81.0"
elsif Gem.ruby_version < Gem::Version.new("2.5.a") then "1.12"
else
"1.21"
end
"1.21"
end
def standard_version
if Gem.ruby_version < Gem::Version.new("2.4.a") then "0.2.5"
elsif Gem.ruby_version < Gem::Version.new("2.5.a") then "1.0"
else
"1.3"
end
"1.3"
end
end
end

View File

@ -68,7 +68,7 @@ module Bundler
def info_path(name)
name = name.to_s
if name =~ /[^a-z0-9_-]/
if /[^a-z0-9_-]/.match?(name)
name += "-#{SharedHelpers.digest(:MD5).hexdigest(name).downcase}"
info_roots.last.join(name)
else

View File

@ -20,63 +20,64 @@ module Bundler
def initialize(fetcher)
@fetcher = fetcher
require_relative "../vendored_tmpdir"
end
def update(local_path, remote_path, retrying = nil)
headers = {}
Bundler::Dir.mktmpdir("bundler-compact-index-") do |local_temp_dir|
local_temp_path = Pathname.new(local_temp_dir).join(local_path.basename)
local_temp_path = local_path.sub(/$/, ".#{$$}")
local_temp_path = local_temp_path.sub(/$/, ".retrying") if retrying
local_temp_path = local_temp_path.sub(/$/, ".tmp")
# first try to fetch any new bytes on the existing file
if retrying.nil? && local_path.file?
copy_file local_path, local_temp_path
# first try to fetch any new bytes on the existing file
if retrying.nil? && local_path.file?
copy_file local_path, local_temp_path
headers["If-None-Match"] = etag_for(local_temp_path)
headers["Range"] =
if local_temp_path.size.nonzero?
# Subtract a byte to ensure the range won't be empty.
# Avoids 416 (Range Not Satisfiable) responses.
"bytes=#{local_temp_path.size - 1}-"
else
"bytes=#{local_temp_path.size}-"
end
end
response = @fetcher.call(remote_path, headers)
return nil if response.is_a?(Net::HTTPNotModified)
content = response.body
etag = (response["ETag"] || "").gsub(%r{\AW/}, "")
correct_response = SharedHelpers.filesystem_access(local_temp_path) do
if response.is_a?(Net::HTTPPartialContent) && local_temp_path.size.nonzero?
local_temp_path.open("a") {|f| f << slice_body(content, 1..-1) }
etag_for(local_temp_path) == etag
headers["If-None-Match"] = etag_for(local_temp_path)
headers["Range"] =
if local_temp_path.size.nonzero?
# Subtract a byte to ensure the range won't be empty.
# Avoids 416 (Range Not Satisfiable) responses.
"bytes=#{local_temp_path.size - 1}-"
else
local_temp_path.open("wb") {|f| f << content }
etag.length.zero? || etag_for(local_temp_path) == etag
"bytes=#{local_temp_path.size}-"
end
end
if correct_response
SharedHelpers.filesystem_access(local_path) do
FileUtils.mv(local_temp_path, local_path)
end
return nil
end
if retrying
raise MisMatchedChecksumError.new(remote_path, etag, etag_for(local_temp_path))
end
update(local_path, remote_path, :retrying)
end
response = @fetcher.call(remote_path, headers)
return nil if response.is_a?(Net::HTTPNotModified)
content = response.body
etag = (response["ETag"] || "").gsub(%r{\AW/}, "")
correct_response = SharedHelpers.filesystem_access(local_temp_path) do
if response.is_a?(Net::HTTPPartialContent) && local_temp_path.size.nonzero?
local_temp_path.open("a") {|f| f << slice_body(content, 1..-1) }
etag_for(local_temp_path) == etag
else
local_temp_path.open("wb") {|f| f << content }
etag.length.zero? || etag_for(local_temp_path) == etag
end
end
if correct_response
SharedHelpers.filesystem_access(local_path) do
FileUtils.mv(local_temp_path, local_path)
end
return nil
end
if retrying
raise MisMatchedChecksumError.new(remote_path, etag, etag_for(local_temp_path))
end
update(local_path, remote_path, :retrying)
rescue Zlib::GzipFile::Error
raise Bundler::HTTPError
ensure
FileUtils.remove_file(local_temp_path) if File.exist?(local_temp_path)
end
def etag_for(path)

View File

@ -295,7 +295,7 @@ module Bundler
# Convert to \r\n if the existing lock has them
# i.e., Windows with `git config core.autocrlf=true`
contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match("\r\n")
contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match?("\r\n")
if @locked_bundler_version
locked_major = @locked_bundler_version.segments.first

View File

@ -324,7 +324,7 @@ module Bundler
if name.is_a?(Symbol)
raise GemfileError, %(You need to specify gem names as Strings. Use 'gem "#{name}"' instead)
end
if name =~ /\s/
if /\s/.match?(name)
raise GemfileError, %('#{name}' is not a valid gem name because it contains whitespace)
end
raise GemfileError, %(an empty gem name is not valid) if name.empty?

View File

@ -12,17 +12,15 @@ module Bundler
method = instance_method(method_name)
undef_method(method_name)
define_method(method_name) do |*args, &blk|
begin
method.bind(self).call(*args, &blk)
rescue NetworkDownError, CompactIndexClient::Updater::MisMatchedChecksumError => e
raise HTTPError, e.message
rescue AuthenticationRequiredError
# Fail since we got a 401 from the server.
raise
rescue HTTPError => e
Bundler.ui.trace(e)
nil
end
method.bind(self).call(*args, &blk)
rescue NetworkDownError, CompactIndexClient::Updater::MisMatchedChecksumError => e
raise HTTPError, e.message
rescue AuthenticationRequiredError
# Fail since we got a 401 from the server.
raise
rescue HTTPError => e
Bundler.ui.trace(e)
nil
end
end

View File

@ -80,7 +80,7 @@ module Bundler
private
def validate_uri_scheme!(uri)
return if uri.scheme =~ /\Ahttps?\z/
return if /\Ahttps?\z/.match?(uri.scheme)
raise InvalidOption,
"The request uri `#{uri}` has an invalid scheme (`#{uri.scheme}`). " \
"Did you mean `http` or `https`?"

View File

@ -37,7 +37,7 @@ module Bundler
when Thor::Error
Bundler.ui.error error.message
when LoadError
raise error unless error.message =~ /cannot load such file -- openssl|openssl.so|libcrypto.so/
raise error unless /cannot load such file -- openssl|openssl.so|libcrypto.so/.match?(error.message)
Bundler.ui.error "\nCould not load OpenSSL. #{error.class}: #{error}\n#{error.backtrace.join("\n ")}"
when Interrupt
Bundler.ui.error "\nQuitting..."

View File

@ -235,7 +235,7 @@ module Bundler
gemfile.each_with_index do |line, index|
next unless !line.nil? && line.strip.start_with?(block_name)
if gemfile[index + 1] =~ /^\s*end\s*$/
if /^\s*end\s*$/.match?(gemfile[index + 1])
gemfile[index] = nil
gemfile[index + 1] = nil
end

View File

@ -136,11 +136,7 @@ module Bundler
mode = Gem.win_platform? ? "wb:UTF-8" : "w"
require "erb"
content = if RUBY_VERSION >= "2.6"
ERB.new(template, :trim_mode => "-").result(binding)
else
ERB.new(template, nil, "-").result(binding)
end
content = ERB.new(template, :trim_mode => "-").result(binding)
File.write(binstub_path, content, :mode => mode, :perm => 0o777 & ~File.umask)
if Gem.win_platform? || options[:all_platforms]
@ -183,11 +179,7 @@ module Bundler
mode = Gem.win_platform? ? "wb:UTF-8" : "w"
require "erb"
content = if RUBY_VERSION >= "2.6"
ERB.new(template, :trim_mode => "-").result(binding)
else
ERB.new(template, nil, "-").result(binding)
end
content = ERB.new(template, :trim_mode => "-").result(binding)
File.write("#{bin_path}/#{executable}", content, :mode => mode, :perm => 0o755)
if Gem.win_platform? || options[:all_platforms]
@ -226,12 +218,10 @@ module Bundler
requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
path_plugin_files = requested_path_gems.map do |spec|
begin
Bundler.rubygems.spec_matches_for_glob(spec, "rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
rescue TypeError
error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
raise Gem::InvalidSpecificationException, error_message
end
Bundler.rubygems.spec_matches_for_glob(spec, "rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
rescue TypeError
error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
raise Gem::InvalidSpecificationException, error_message
end.flatten
Bundler.rubygems.load_plugin_files(path_plugin_files)
Bundler.rubygems.load_env_plugins

View File

@ -63,7 +63,7 @@ module Bundler
@state = nil
@specs = {}
if lockfile.match(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/)
if lockfile.match?(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/)
raise LockfileError, "Your #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} contains merge conflicts.\n" \
"Run `git checkout HEAD -- #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` first to get a clean lock."
end
@ -80,7 +80,7 @@ module Bundler
@state = :ruby
elsif line == BUNDLED
@state = :bundled_with
elsif line =~ /^[^\s]/
elsif /^[^\s]/.match?(line)
@state = nil
elsif @state
send("parse_#{@state}", line)

View File

@ -148,13 +148,11 @@ module Bundler
class TCPSocketProbe
def replies?(mirror)
MirrorSockets.new(mirror).any? do |socket, address, timeout|
begin
socket.connect_nonblock(address)
rescue Errno::EINPROGRESS
wait_for_writtable_socket(socket, address, timeout)
rescue RuntimeError # Connection failed somehow, again
false
end
socket.connect_nonblock(address)
rescue Errno::EINPROGRESS
wait_for_writtable_socket(socket, address, timeout)
rescue RuntimeError # Connection failed somehow, again
false
end
end

View File

@ -338,11 +338,7 @@ module Gem
end
def glob_files_in_dir(glob, base_path)
if RUBY_VERSION >= "2.5"
Dir.glob(glob, :base => base_path).map! {|f| File.expand_path(f, base_path) }
else
Dir.glob(File.join(base_path.to_s.gsub(/[\[\]]/, '\\\\\\&'), glob)).map! {|f| File.expand_path(f) }
end
Dir.glob(glob, :base => base_path).map! {|f| File.expand_path(f, base_path) }
end
end
end

View File

@ -64,7 +64,7 @@ module Bundler
at = if local?
path
elsif user_ref = options["ref"]
if ref =~ /\A[a-z0-9]{4,}\z/i
if /\A[a-z0-9]{4,}\z/i.match?(ref)
shortref_for_display(user_ref)
else
user_ref
@ -295,7 +295,7 @@ module Bundler
end
def uri_hash
if uri =~ %r{^\w+://(\w+@)?}
if %r{^\w+://(\w+@)?}.match?(uri)
# Downcase the domain component of the URI
# and strip off a trailing slash, if one is present
input = Bundler::URI.parse(uri).normalize.to_s.sub(%r{/$}, "")

View File

@ -250,7 +250,7 @@ module Bundler
# Adds credentials to the URI
def configured_uri
if /https?:/ =~ uri
if /https?:/.match?(uri)
remote = Bundler::URI(uri)
config_auth = Bundler.settings[remote.to_s] || Bundler.settings[remote.host]
remote.userinfo ||= config_auth

View File

@ -224,13 +224,13 @@ module Bundler
# Some gem authors put absolute paths in their gemspec
# and we have to save them from themselves
spec.files = spec.files.map do |p|
next p unless p =~ /\A#{Pathname::SEPARATOR_PAT}/
next if File.directory?(p)
spec.files = spec.files.map do |path|
next path unless /\A#{Pathname::SEPARATOR_PAT}/.match?(path)
next if File.directory?(path)
begin
Pathname.new(p).relative_path_from(gem_dir).to_s
Pathname.new(path).relative_path_from(gem_dir).to_s
rescue ArgumentError
p
path
end
end.compact

View File

@ -145,7 +145,7 @@ module Bundler
end
if installed?(spec) && !force
print_using_message "Using #{version_message(spec)}"
print_using_message "Using #{version_message(spec, options[:previous_spec])}"
return nil # no post-install message
end
@ -163,8 +163,6 @@ module Bundler
install_path = rubygems_dir
bin_path = Bundler.system_bindir
Bundler.mkdir_p bin_path unless spec.executables.empty? || Bundler.rubygems.provides?(">= 2.7.5")
require_relative "../rubygems_gem_installer"
installer = Bundler::RubyGemsGemInstaller.at(
@ -340,7 +338,7 @@ module Bundler
def normalize_uri(uri)
uri = uri.to_s
uri = "#{uri}/" unless uri =~ %r{/$}
uri = "#{uri}/" unless %r{/$}.match?(uri)
require_relative "../vendored_uri"
uri = Bundler::URI(uri)
raise ArgumentError, "The source must be an absolute URI. For example:\n" \
@ -383,7 +381,7 @@ module Bundler
idx = @allow_local ? installed_specs.dup : Index.new
Dir["#{cache_path}/*.gem"].each do |gemfile|
next if gemfile =~ /^bundler\-[\d\.]+?\.gem/
next if /^bundler\-[\d\.]+?\.gem/.match?(gemfile)
s ||= Bundler.rubygems.spec_from_gem(gemfile)
s.source = self
idx << s

View File

@ -206,7 +206,7 @@ module Bundler
def warn_on_git_protocol(source)
return if Bundler.settings["git.allow_insecure"]
if source.uri =~ /^git\:/
if /^git\:/.match?(source.uri)
Bundler.ui.warn "The git source `#{source.uri}` uses the `git` protocol, " \
"which transmits data without encryption. Disable this warning with " \
"`bundle config set --local git.allow_insecure true`, or switch to the `https` " \

View File

@ -72,13 +72,7 @@ m = Module.new do
bundler_gem_version = Gem::Version.new(version)
requirement = bundler_gem_version.approximate_recommendation
return requirement unless Gem.rubygems_version < Gem::Version.new("2.7.0")
requirement += ".a" if bundler_gem_version.prerelease?
requirement
bundler_gem_version.approximate_recommendation
end
def load_bundler!

View File

@ -1,154 +0,0 @@
# frozen_string_literal: true
#
# tmpdir - retrieve temporary directory path
#
# $Id$
#
require_relative '../../fileutils/lib/fileutils'
begin
require 'etc.so'
rescue LoadError # rescue LoadError for miniruby
end
class Bundler::Dir < Dir
@systmpdir ||= defined?(Etc.systmpdir) ? Etc.systmpdir : '/tmp'
##
# Returns the operating system's temporary file path.
def self.tmpdir
tmp = nil
['TMPDIR', 'TMP', 'TEMP', ['system temporary path', @systmpdir], ['/tmp']*2, ['.']*2].each do |name, dir = ENV[name]|
next if !dir
dir = File.expand_path(dir)
stat = File.stat(dir) rescue next
case
when !stat.directory?
warn "#{name} is not a directory: #{dir}"
when !stat.writable?
warn "#{name} is not writable: #{dir}"
when stat.world_writable? && !stat.sticky?
warn "#{name} is world-writable: #{dir}"
else
tmp = dir
break
end
end
raise ArgumentError, "could not find a temporary directory" unless tmp
tmp
end
# Bundler::Dir.mktmpdir creates a temporary directory.
#
# The directory is created with 0700 permission.
# Application should not change the permission to make the temporary directory accessible from other users.
#
# The prefix and suffix of the name of the directory is specified by
# the optional first argument, <i>prefix_suffix</i>.
# - If it is not specified or nil, "d" is used as the prefix and no suffix is used.
# - If it is a string, it is used as the prefix and no suffix is used.
# - If it is an array, first element is used as the prefix and second element is used as a suffix.
#
# Bundler::Dir.mktmpdir {|dir| dir is ".../d..." }
# Bundler::Dir.mktmpdir("foo") {|dir| dir is ".../foo..." }
# Bundler::Dir.mktmpdir(["foo", "bar"]) {|dir| dir is ".../foo...bar" }
#
# The directory is created under Bundler::Dir.tmpdir or
# the optional second argument <i>tmpdir</i> if non-nil value is given.
#
# Bundler::Dir.mktmpdir {|dir| dir is "#{Bundler::Dir.tmpdir}/d..." }
# Bundler::Dir.mktmpdir(nil, "/var/tmp") {|dir| dir is "/var/tmp/d..." }
#
# If a block is given,
# it is yielded with the path of the directory.
# The directory and its contents are removed
# using Bundler::FileUtils.remove_entry before Bundler::Dir.mktmpdir returns.
# The value of the block is returned.
#
# Bundler::Dir.mktmpdir {|dir|
# # use the directory...
# open("#{dir}/foo", "w") { ... }
# }
#
# If a block is not given,
# The path of the directory is returned.
# In this case, Bundler::Dir.mktmpdir doesn't remove the directory.
#
# dir = Bundler::Dir.mktmpdir
# begin
# # use the directory...
# open("#{dir}/foo", "w") { ... }
# ensure
# # remove the directory.
# Bundler::FileUtils.remove_entry dir
# end
#
def self.mktmpdir(prefix_suffix=nil, *rest, **options)
base = nil
path = Tmpname.create(prefix_suffix || "d", *rest, **options) {|p, _, _, d|
base = d
mkdir(p, 0700)
}
if block_given?
begin
yield path.dup
ensure
unless base
stat = File.stat(File.dirname(path))
if stat.world_writable? and !stat.sticky?
raise ArgumentError, "parent directory is world writable but not sticky"
end
end
Bundler::FileUtils.remove_entry path
end
else
path
end
end
module Tmpname # :nodoc:
module_function
def tmpdir
Bundler::Dir.tmpdir
end
UNUSABLE_CHARS = "^,-.0-9A-Z_a-z~"
class << (RANDOM = Random.new)
MAX = 36**6 # < 0x100000000
def next
rand(MAX).to_s(36)
end
end
private_constant :RANDOM
def create(basename, tmpdir=nil, max_try: nil, **opts)
origdir = tmpdir
tmpdir ||= tmpdir()
n = nil
prefix, suffix = basename
prefix = (String.try_convert(prefix) or
raise ArgumentError, "unexpected prefix: #{prefix.inspect}")
prefix = prefix.delete(UNUSABLE_CHARS)
suffix &&= (String.try_convert(suffix) or
raise ArgumentError, "unexpected suffix: #{suffix.inspect}")
suffix &&= suffix.delete(UNUSABLE_CHARS)
begin
t = Time.now.strftime("%Y%m%d")
path = "#{prefix}#{t}-#{$$}-#{RANDOM.next}"\
"#{n ? %[-#{n}] : ''}#{suffix||''}"
path = File.join(tmpdir, path)
yield(path, n, opts, origdir)
rescue Errno::EEXIST
n ||= 0
n += 1
retry if !max_try or n < max_try
raise "cannot generate temporary name using `#{basename}' under `#{tmpdir}'"
end
path
end
end
end

View File

@ -1,4 +0,0 @@
# frozen_string_literal: true
module Bundler; end
require_relative "vendor/tmpdir/lib/tmpdir"

View File

@ -87,14 +87,12 @@ module Bundler
creation_errors = []
@threads = Array.new(@size) do |i|
begin
Thread.start { process_queue(i) }.tap do |thread|
thread.name = "#{name} Worker ##{i}" if thread.respond_to?(:name=)
end
rescue ThreadError => e
creation_errors << e
nil
Thread.start { process_queue(i) }.tap do |thread|
thread.name = "#{name} Worker ##{i}" if thread.respond_to?(:name=)
end
rescue ThreadError => e
creation_errors << e
nil
end.compact
add_interrupt_handler unless @threads.empty?

View File

@ -107,7 +107,7 @@ class Gem::Commands::SetupCommand < Gem::Command
end
def check_ruby_version
required_version = Gem::Requirement.new ">= 2.3.0"
required_version = Gem::Requirement.new ">= 2.6.0"
unless required_version.satisfied_by? Gem.ruby_version
alert_error "Expected Ruby version #{required_version}, is #{Gem.ruby_version}"

View File

@ -329,14 +329,8 @@ command to remove old versions.
Gem::Version.new("3.2.3")
elsif Gem.ruby_version > Gem::Version.new("2.7.a")
Gem::Version.new("3.1.2")
elsif Gem.ruby_version > Gem::Version.new("2.6.a")
Gem::Version.new("3.0.1")
elsif Gem.ruby_version > Gem::Version.new("2.5.a")
Gem::Version.new("2.7.3")
elsif Gem.ruby_version > Gem::Version.new("2.4.a")
Gem::Version.new("2.6.8")
else
Gem::Version.new("2.5.2")
Gem::Version.new("3.0.1")
end
end
end

View File

@ -1,7 +1,6 @@
# frozen_string_literal: true
# `uplevel` keyword argument of Kernel#warn is available since ruby 2.5.
if RUBY_VERSION >= "2.5" && !Gem::KERNEL_WARN_IGNORES_INTERNAL_ENTRIES
if !Gem::KERNEL_WARN_IGNORES_INTERNAL_ENTRIES
module Kernel
rubygems_path = "#{__dir__}/" # Frames to be skipped start with this path.

View File

@ -433,13 +433,6 @@ module Gem::Security
ec_key
end
##
# In Ruby 2.3 EC doesn't implement the private_key? but not the private? method
if defined?(OpenSSL::PKey::EC) && Gem::Version.new(String.new(RUBY_VERSION)) < Gem::Version.new("2.4.0")
OpenSSL::PKey::EC.send(:alias_method, :private?, :private_key?)
end
##
# Creates a self-signed certificate with an issuer and subject from +email+,
# a subject alternative name of +email+ and the given +extensions+ for the
@ -492,13 +485,7 @@ module Gem::Security
when "rsa"
OpenSSL::PKey::RSA.new(RSA_DSA_KEY_LENGTH)
when "ec"
if RUBY_VERSION >= "2.4.0"
OpenSSL::PKey::EC.generate(EC_NAME)
else
domain_key = OpenSSL::PKey::EC.new(EC_NAME)
domain_key.generate_key
domain_key
end
OpenSSL::PKey::EC.generate(EC_NAME)
else
raise Gem::Security::Exception,
"#{algorithm} algorithm not found. RSA, DSA, and EC algorithms are supported."

View File

@ -97,11 +97,7 @@ module Gem::Util
# returning absolute paths to the matching files.
def self.glob_files_in_dir(glob, base_path)
if RUBY_VERSION >= "2.5"
Dir.glob(glob, base: base_path).map! {|f| File.expand_path(f, base_path) }
else
Dir.glob(File.expand_path(glob, base_path))
end
Dir.glob(glob, base: base_path).map! {|f| File.expand_path(f, base_path) }
end
##

View File

@ -15,10 +15,7 @@ else
require "bundler"
end
# Workaround for non-activated bundler spec due to missing https://github.com/rubygems/rubygems/commit/4e306d7bcdee924b8d80ca9db6125aa59ee4e5a3
gem "bundler", Bundler::VERSION if Gem.rubygems_version < Gem::Version.new("2.6.2")
if Gem.rubygems_version < Gem::Version.new("3.2.3") && Gem.ruby_version < Gem::Version.new("2.6.a") && !ENV["BUNDLER_NO_OLD_RUBYGEMS_WARNING"]
if Gem.rubygems_version < Gem::Version.new("3.2.3") && Gem.ruby_version < Gem::Version.new("3.0.a") && !ENV["BUNDLER_NO_OLD_RUBYGEMS_WARNING"]
Bundler.ui.warn \
"Your RubyGems version (#{Gem::VERSION}) has a bug that prevents " \
"`required_ruby_version` from working for Bundler. Any scripts that use " \

View File

@ -34,8 +34,6 @@ RSpec.describe Bundler::Env do
end
it "prints user home" do
skip "needs to use a valid HOME" if Gem.win_platform? && RUBY_VERSION < "2.6.0"
with_clear_paths("HOME", "/a/b/c") do
out = described_class.report
expect(out).to include("User Home /a/b/c")
@ -43,8 +41,6 @@ RSpec.describe Bundler::Env do
end
it "prints user path" do
skip "needs to use a valid HOME" if Gem.win_platform? && RUBY_VERSION < "2.6.0"
with_clear_paths("HOME", "/a/b/c") do
allow(File).to receive(:exist?)
allow(File).to receive(:exist?).with("/a/b/c/.gem").and_return(true)

View File

@ -143,17 +143,15 @@ RSpec.describe ".bundle/config" do
end
it "has lower precedence than env" do
begin
ENV["BUNDLE_FOO"] = "env"
ENV["BUNDLE_FOO"] = "env"
bundle "config set --global foo global"
expect(out).to match(/You have a bundler environment variable for foo set to "env"/)
bundle "config set --global foo global"
expect(out).to match(/You have a bundler environment variable for foo set to "env"/)
run "puts Bundler.settings[:foo]"
expect(out).to eq("env")
ensure
ENV.delete("BUNDLE_FOO")
end
run "puts Bundler.settings[:foo]"
expect(out).to eq("env")
ensure
ENV.delete("BUNDLE_FOO")
end
it "can be deleted" do
@ -221,15 +219,13 @@ RSpec.describe ".bundle/config" do
end
it "has higher precedence than env" do
begin
ENV["BUNDLE_FOO"] = "env"
bundle "config set --local foo local"
ENV["BUNDLE_FOO"] = "env"
bundle "config set --local foo local"
run "puts Bundler.settings[:foo]"
expect(out).to eq("local")
ensure
ENV.delete("BUNDLE_FOO")
end
run "puts Bundler.settings[:foo]"
expect(out).to eq("local")
ensure
ENV.delete("BUNDLE_FOO")
end
it "can be deleted" do

View File

@ -2,9 +2,7 @@
RSpec.describe "bundle viz", :bundler => "< 3", :if => Bundler.which("dot") do
before do
graphviz_version = RUBY_VERSION >= "2.4" ? "1.2.5" : "1.2.4"
realworld_system_gems "ruby-graphviz --version #{graphviz_version}"
realworld_system_gems "ruby-graphviz --version 1.2.5"
end
it "graphs gems from the Gemfile" do

View File

@ -210,6 +210,33 @@ RSpec.describe "bundle install" do
expect(err).to be_empty
end
it "prints the previous version when switching to a previously downloaded gem" do
build_repo4 do
build_gem "rails", "7.0.3"
build_gem "rails", "7.0.4"
end
bundle "config set path.system true"
install_gemfile <<-G
source "#{file_uri_for(gem_repo4)}"
gem 'rails', "7.0.4"
G
install_gemfile <<-G
source "#{file_uri_for(gem_repo4)}"
gem 'rails', "7.0.3"
G
install_gemfile <<-G
source "#{file_uri_for(gem_repo4)}"
gem 'rails', "7.0.4"
G
expect(out).to include("Using rails 7.0.4 (was 7.0.3)")
expect(err).to be_empty
end
it "can install dependencies with newer bundler version with system gems" do
bundle "config set path.system true"

View File

@ -1237,7 +1237,7 @@ RSpec.describe "bundle install with git sources" do
s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-RUBY
require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"]
create_makefile("foo")
RUBY
s.write "ext/foo.c", "void Init_foo() {}"

View File

@ -7,7 +7,7 @@ RSpec.describe "installing a gem with native extensions" do
s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-E
require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"]
name = "c_extension_bundle"
dir_config(name)
raise "OMG" unless with_config("c_extension") == "hello"
@ -52,7 +52,7 @@ RSpec.describe "installing a gem with native extensions" do
s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-E
require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"]
name = "c_extension_bundle"
dir_config(name)
raise "OMG" unless with_config("c_extension") == "hello"
@ -97,7 +97,7 @@ RSpec.describe "installing a gem with native extensions" do
s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-E
require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"]
name = "c_extension_bundle_#{n}"
dir_config(name)
raise "OMG" unless with_config("c_extension_#{n}") == "#{n}"
@ -150,7 +150,7 @@ RSpec.describe "installing a gem with native extensions" do
s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-E
require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"]
name = "c_extension_bundle"
dir_config(name)
raise "OMG" unless with_config("c_extension") == "hello" && with_config("c_extension_bundle-dir") == "hola"

View File

@ -589,8 +589,7 @@ RSpec.describe "major deprecations" do
context "bundle viz" do
before do
graphviz_version = RUBY_VERSION >= "2.4" ? "1.2.5" : "1.2.4"
realworld_system_gems "ruby-graphviz --version #{graphviz_version}"
realworld_system_gems "ruby-graphviz --version 1.2.5"
create_file "gems.rb", "source \"#{file_uri_for(gem_repo1)}\""
bundle "viz"
end

View File

@ -41,7 +41,7 @@ RSpec.describe "La biblioteca si misma" do
included = /ronn/
error_messages = []
man_tracked_files.each do |filename|
next unless filename =~ included
next unless filename&.match?(included)
error_messages << check_for_expendable_words(filename)
error_messages << check_for_specific_pronouns(filename)
end
@ -52,7 +52,7 @@ RSpec.describe "La biblioteca si misma" do
error_messages = []
exempt = /vendor/
lib_tracked_files.each do |filename|
next if filename =~ exempt
next if filename&.match?(exempt)
error_messages << check_for_expendable_words(filename)
error_messages << check_for_specific_pronouns(filename)
end

View File

@ -12,7 +12,7 @@ RSpec.describe "The library itself" do
failing_lines = []
each_line(filename) do |line, number|
failing_lines << number + 1 if line =~ merge_conflicts_regex
failing_lines << number + 1 if line&.match?(merge_conflicts_regex)
end
return if failing_lines.empty?
@ -32,8 +32,8 @@ RSpec.describe "The library itself" do
def check_for_extra_spaces(filename)
failing_lines = []
each_line(filename) do |line, number|
next if line =~ /^\s+#.*\s+\n$/
failing_lines << number + 1 if line =~ /\s+\n$/
next if /^\s+#.*\s+\n$/.match?(line)
failing_lines << number + 1 if /\s+\n$/.match?(line)
end
return if failing_lines.empty?
@ -45,7 +45,7 @@ RSpec.describe "The library itself" do
failing_lines = []
each_line(filename) do |line, number|
failing_lines << number + 1 if line =~ //
failing_lines << number + 1 if //.match?(line)
end
return if failing_lines.empty?
@ -89,7 +89,7 @@ RSpec.describe "The library itself" do
exempt = /\.gitmodules|fixtures|vendor|LICENSE|vcr_cassettes|rbreadline\.diff|index\.txt$/
error_messages = []
tracked_files.each do |filename|
next if filename =~ exempt
next if filename&.match?(exempt)
error_messages << check_for_tab_characters(filename)
error_messages << check_for_extra_spaces(filename)
end
@ -100,7 +100,7 @@ RSpec.describe "The library itself" do
exempt = /vendor|vcr_cassettes|LICENSE|rbreadline\.diff/
error_messages = []
tracked_files.each do |filename|
next if filename =~ exempt
next if filename&.match?(exempt)
error_messages << check_for_straneous_quotes(filename)
end
expect(error_messages.compact).to be_well_formed
@ -110,7 +110,7 @@ RSpec.describe "The library itself" do
error_messages = []
exempt = %r{lock/lockfile_spec|quality_spec|vcr_cassettes|\.ronn|lockfile_parser\.rb}
tracked_files.each do |filename|
next if filename =~ exempt
next if filename&.match?(exempt)
error_messages << check_for_git_merge_conflicts(filename)
end
expect(error_messages.compact).to be_well_formed
@ -120,7 +120,7 @@ RSpec.describe "The library itself" do
included = /ronn/
error_messages = []
man_tracked_files.each do |filename|
next unless filename =~ included
next unless filename&.match?(included)
error_messages << check_for_expendable_words(filename)
error_messages << check_for_specific_pronouns(filename)
end
@ -131,7 +131,7 @@ RSpec.describe "The library itself" do
error_messages = []
exempt = /vendor|vcr_cassettes|CODE_OF_CONDUCT/
lib_tracked_files.each do |filename|
next if filename =~ exempt
next if filename&.match?(exempt)
error_messages << check_for_expendable_words(filename)
error_messages << check_for_specific_pronouns(filename)
end
@ -229,7 +229,7 @@ RSpec.describe "The library itself" do
exempt = %r{templates/|\.5|\.1|vendor/}
all_bad_requires = []
lib_tracked_files.each do |filename|
next if filename =~ exempt
next if filename&.match?(exempt)
each_line(filename) do |line, number|
line.scan(/^ *require "bundler/).each { all_bad_requires << "#{filename}:#{number.succ}" }
end

View File

@ -1304,11 +1304,7 @@ end
describe "default gem activation" do
let(:exemptions) do
exempts = if Gem.rubygems_version >= Gem::Version.new("2.7")
%w[did_you_mean]
else
%w[io-console openssl]
end << "bundler"
exempts = %w[did_you_mean bundler]
exempts << "uri" if Gem.ruby_version >= Gem::Version.new("2.7")
exempts << "pathname" if Gem.ruby_version >= Gem::Version.new("3.0")
exempts << "set" unless Gem.rubygems_version >= Gem::Version.new("3.2.6")

View File

@ -96,23 +96,21 @@ RSpec.configure do |config|
end
config.around :each do |example|
begin
FileUtils.cp_r pristine_system_gem_path, system_gem_path
FileUtils.cp_r pristine_system_gem_path, system_gem_path
with_gem_path_as(system_gem_path) do
Bundler.ui.silence { example.run }
with_gem_path_as(system_gem_path) do
Bundler.ui.silence { example.run }
all_output = all_commands_output
if example.exception && !all_output.empty?
message = all_output + "\n" + example.exception.message
(class << example.exception; self; end).send(:define_method, :message) do
message
end
all_output = all_commands_output
if example.exception && !all_output.empty?
message = all_output + "\n" + example.exception.message
(class << example.exception; self; end).send(:define_method, :message) do
message
end
end
ensure
reset!
end
ensure
reset!
end
config.after :suite do

View File

@ -456,7 +456,7 @@ module Spec
write "ext/extconf.rb", <<-RUBY
require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"]
extension_name = "#{name}_c"
if extra_lib_dir = with_config("ext-lib")

View File

@ -1,6 +1,8 @@
# frozen_string_literal: true
require "rubygems"
Gem.instance_variable_set(:@ruby, ENV["RUBY"]) if ENV["RUBY"]
require_relative "path"
bundler_gemspec = Spec::Path.loaded_gemspec
bundler_gemspec.instance_variable_set(:@full_gem_path, Spec::Path.source_root)

View File

@ -33,11 +33,4 @@ module Gem
if ENV["BUNDLER_SPEC_GEM_SOURCES"]
self.sources = [ENV["BUNDLER_SPEC_GEM_SOURCES"]]
end
# We only need this hack for rubygems versions without the BundlerVersionFinder
if Gem.rubygems_version < Gem::Version.new("2.7.0")
@path_to_default_spec_map.delete_if do |_path, spec|
spec.name == "bundler"
end
end
end

View File

@ -290,7 +290,7 @@ module Spec
if gem_name.start_with?("bundler")
version = gem_name.match(/\Abundler-(?<version>.*)\z/)[:version] if gem_name != "bundler"
with_built_bundler(version) {|gem_path| install_gem(gem_path, default) }
elsif gem_name =~ %r{\A(?:[a-zA-Z]:)?/.*\.gem\z}
elsif %r{\A(?:[a-zA-Z]:)?/.*\.gem\z}.match?(gem_name)
install_gem(gem_name, default)
else
install_gem("#{gem_repo}/gems/#{gem_name}.gem", default)
@ -486,10 +486,10 @@ module Spec
Gem.ruby_version.segments[0..1].map.with_index {|s, i| i == 1 ? s + 1 : s }.join(".")
end
# versions providing a bundler version finder but not including
# versions not including
# https://github.com/rubygems/rubygems/commit/929e92d752baad3a08f3ac92eaec162cb96aedd1
def rubygems_version_failing_to_activate_bundler_prereleases
Gem.rubygems_version < Gem::Version.new("3.1.0.pre.1") && Gem.rubygems_version >= Gem::Version.new("2.7.0")
Gem.rubygems_version < Gem::Version.new("3.1.0.pre.1")
end
def revision_for(path)

View File

@ -126,7 +126,7 @@ module Spec
next if version == v("1.4.2.1") && platform != pl("x86-mswin32")
next if version == v("1.4.2") && platform == pl("x86-mswin32")
gem "nokogiri", version, platform do
dep "weakling", ">= 0.0.3" if platform =~ pl("java")
dep "weakling", ">= 0.0.3" if platform =~ pl("java") # rubocop:disable Performance/RegexpMatch
end
end
end

View File

@ -295,25 +295,11 @@ module Spec
end
def rubocop_gemfile_basename
filename = if RUBY_VERSION.start_with?("2.3")
"rubocop23_gems"
elsif RUBY_VERSION.start_with?("2.4")
"rubocop24_gems"
else
"rubocop_gems"
end
tool_dir.join("#{filename}.rb")
source_root.join("tool/bundler/rubocop_gems.rb")
end
def standard_gemfile_basename
filename = if RUBY_VERSION.start_with?("2.3")
"standard23_gems"
elsif RUBY_VERSION.start_with?("2.4")
"standard24_gems"
else
"standard_gems"
end
tool_dir.join("#{filename}.rb")
source_root.join("tool/bundler/standard_gems.rb")
end
def tool_dir

View File

@ -113,7 +113,7 @@ class RubygemsVersionManager
end
def resolve_target_tag
return "v#{@source}" if @source.match(/^\d/)
return "v#{@source}" if @source.match?(/^\d/)
@source
end

View File

@ -2061,13 +2061,8 @@ You may need to `bundle install` to install missing gems
end
def redefine_method(base, method, new_result)
if RUBY_VERSION >= "2.5"
base.alias_method(method, method)
base.define_method(method) { new_result }
else
base.send(:alias_method, method, method)
base.send(:define_method, method) { new_result }
end
base.alias_method(method, method)
base.define_method(method) { new_result }
end
def with_plugin(path)

View File

@ -76,7 +76,7 @@ class TestGemCommandManager < Gem::TestCase
message = "Unknown command pish".dup
if RUBY_VERSION >= "2.4" && defined?(DidYouMean::SPELL_CHECKERS) && defined?(DidYouMean::Correctable)
if defined?(DidYouMean::SPELL_CHECKERS) && defined?(DidYouMean::Correctable)
message << "\nDid you mean? \"push\""
end

View File

@ -83,7 +83,7 @@ class TestGemRequirement < Gem::TestCase
Gem::Requirement.parse(Gem::Version.new("2"))
end
if RUBY_VERSION >= "2.5" && !(Gem.java_platform? && ENV["JRUBY_OPTS"].to_s.include?("--debug"))
if !(Gem.java_platform? && ENV["JRUBY_OPTS"].to_s.include?("--debug"))
def test_parse_deduplication
assert_same "~>", Gem::Requirement.parse("~> 1").first
end

View File

@ -596,77 +596,74 @@ class TestGemRequire < Gem::TestCase
assert_empty unresolved_names
end
# uplevel is 2.5+ only
if RUBY_VERSION >= "2.5"
["", "Kernel."].each do |prefix|
define_method "test_no_kernel_require_in_#{prefix.tr(".", "_")}warn_with_uplevel" do
Dir.mktmpdir("warn_test") do |dir|
File.write(dir + "/sub.rb", "#{prefix}warn 'uplevel', 'test', uplevel: 1\n")
File.write(dir + "/main.rb", "require 'sub'\n")
_, err = capture_subprocess_io do
system(*ruby_with_rubygems_in_load_path, "-w", "--disable=gems", "-C", dir, "-I", dir, "main.rb")
end
assert_match(/main\.rb:1: warning: uplevel\ntest\n$/, err)
_, err = capture_subprocess_io do
system(*ruby_with_rubygems_in_load_path, "-w", "--enable=gems", "-C", dir, "-I", dir, "main.rb")
end
assert_match(/main\.rb:1: warning: uplevel\ntest\n$/, err)
end
end
define_method "test_no_other_behavioral_changes_with_#{prefix.tr(".", "_")}warn" do
Dir.mktmpdir("warn_test") do |dir|
File.write(dir + "/main.rb", "#{prefix}warn({x:1}, {y:2}, [])\n")
_, err = capture_subprocess_io do
system(*ruby_with_rubygems_in_load_path, "-w", "--disable=gems", "-C", dir, "main.rb")
end
assert_match(/{:x=>1}\n{:y=>2}\n$/, err)
_, err = capture_subprocess_io do
system(*ruby_with_rubygems_in_load_path, "-w", "--enable=gems", "-C", dir, "main.rb")
end
assert_match(/{:x=>1}\n{:y=>2}\n$/, err)
end
end
end
def test_no_crash_when_overriding_warn_with_warning_module
["", "Kernel."].each do |prefix|
define_method "test_no_kernel_require_in_#{prefix.tr(".", "_")}warn_with_uplevel" do
Dir.mktmpdir("warn_test") do |dir|
File.write(dir + "/main.rb", "module Warning; def warn(str); super; end; end; warn 'Foo Bar'")
_, err = capture_subprocess_io do
system(*ruby_with_rubygems_in_load_path, "-w", "--disable=gems", "-C", dir, "main.rb")
end
assert_match(/Foo Bar\n$/, err)
_, err = capture_subprocess_io do
system(*ruby_with_rubygems_in_load_path, "-w", "--enable=gems", "-C", dir, "main.rb")
end
assert_match(/Foo Bar\n$/, err)
end
end
def test_expected_backtrace_location_when_inheriting_from_basic_object_and_including_kernel
Dir.mktmpdir("warn_test") do |dir|
File.write(dir + "/main.rb", "\nrequire 'sub'\n")
File.write(dir + "/sub.rb", <<-'RUBY')
require 'rubygems'
class C < BasicObject
include ::Kernel
def deprecated
warn "This is a deprecated method", uplevel: 2
end
end
C.new.deprecated
RUBY
File.write(dir + "/sub.rb", "#{prefix}warn 'uplevel', 'test', uplevel: 1\n")
File.write(dir + "/main.rb", "require 'sub'\n")
_, err = capture_subprocess_io do
system(*ruby_with_rubygems_in_load_path, "-w", "--disable=gems", "-C", dir, "-I", dir, "main.rb")
end
assert_match(/main\.rb:2: warning: This is a deprecated method$/, err)
assert_match(/main\.rb:1: warning: uplevel\ntest\n$/, err)
_, err = capture_subprocess_io do
system(*ruby_with_rubygems_in_load_path, "-w", "--enable=gems", "-C", dir, "-I", dir, "main.rb")
end
assert_match(/main\.rb:2: warning: This is a deprecated method$/, err)
assert_match(/main\.rb:1: warning: uplevel\ntest\n$/, err)
end
end
define_method "test_no_other_behavioral_changes_with_#{prefix.tr(".", "_")}warn" do
Dir.mktmpdir("warn_test") do |dir|
File.write(dir + "/main.rb", "#{prefix}warn({x:1}, {y:2}, [])\n")
_, err = capture_subprocess_io do
system(*ruby_with_rubygems_in_load_path, "-w", "--disable=gems", "-C", dir, "main.rb")
end
assert_match(/{:x=>1}\n{:y=>2}\n$/, err)
_, err = capture_subprocess_io do
system(*ruby_with_rubygems_in_load_path, "-w", "--enable=gems", "-C", dir, "main.rb")
end
assert_match(/{:x=>1}\n{:y=>2}\n$/, err)
end
end
end
def test_no_crash_when_overriding_warn_with_warning_module
Dir.mktmpdir("warn_test") do |dir|
File.write(dir + "/main.rb", "module Warning; def warn(str); super; end; end; warn 'Foo Bar'")
_, err = capture_subprocess_io do
system(*ruby_with_rubygems_in_load_path, "-w", "--disable=gems", "-C", dir, "main.rb")
end
assert_match(/Foo Bar\n$/, err)
_, err = capture_subprocess_io do
system(*ruby_with_rubygems_in_load_path, "-w", "--enable=gems", "-C", dir, "main.rb")
end
assert_match(/Foo Bar\n$/, err)
end
end
def test_expected_backtrace_location_when_inheriting_from_basic_object_and_including_kernel
Dir.mktmpdir("warn_test") do |dir|
File.write(dir + "/main.rb", "\nrequire 'sub'\n")
File.write(dir + "/sub.rb", <<-'RUBY')
require 'rubygems'
class C < BasicObject
include ::Kernel
def deprecated
warn "This is a deprecated method", uplevel: 2
end
end
C.new.deprecated
RUBY
_, err = capture_subprocess_io do
system(*ruby_with_rubygems_in_load_path, "-w", "--disable=gems", "-C", dir, "-I", dir, "main.rb")
end
assert_match(/main\.rb:2: warning: This is a deprecated method$/, err)
_, err = capture_subprocess_io do
system(*ruby_with_rubygems_in_load_path, "-w", "--enable=gems", "-C", dir, "-I", dir, "main.rb")
end
assert_match(/main\.rb:2: warning: This is a deprecated method$/, err)
end
end
private

View File

@ -2,17 +2,16 @@
source "https://rubygems.org"
gem "rdoc", "6.2.0" # 6.2.1 is required > Ruby 2.3
gem "test-unit", "~> 3.0"
gem "rake", "~> 13.0"
gem "webrick", "~> 1.6"
gem "parallel_tests", "~> 2.29"
gem "parallel", "1.19.2" # 1.20+ is required > Ruby 2.3
gem "parallel", "~> 1.19"
gem "rspec-core", "~> 3.12"
gem "rspec-expectations", "~> 3.12"
gem "rspec-mocks", "~> 3.12"
gem "uri", "~> 0.10.1"
gem "uri", "~> 0.12.0"
group :doc do
gem "ronn", "~> 0.7.3", :platform => :ruby

View File

@ -5,13 +5,12 @@ GEM
hpricot (0.8.6)
hpricot (0.8.6-java)
mustache (1.1.1)
parallel (1.19.2)
parallel (1.22.1)
parallel_tests (2.32.0)
parallel
power_assert (2.0.1)
power_assert (2.0.2)
rake (13.0.6)
rdiscount (2.2.0.2)
rdoc (6.2.0)
rdiscount (2.2.7)
ronn (0.7.3)
hpricot (>= 0.8.2)
mustache (>= 0.7.0)
@ -21,13 +20,13 @@ GEM
rspec-expectations (3.12.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.0)
rspec-mocks (3.12.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
test-unit (3.5.3)
test-unit (3.5.5)
power_assert
uri (0.10.1)
uri (0.12.0)
webrick (1.7.0)
PLATFORMS
@ -41,16 +40,15 @@ PLATFORMS
x86_64-linux
DEPENDENCIES
parallel (= 1.19.2)
parallel (~> 1.19)
parallel_tests (~> 2.29)
rake (~> 13.0)
rdoc (= 6.2.0)
ronn (~> 0.7.3)
rspec-core (~> 3.12)
rspec-expectations (~> 3.12)
rspec-mocks (~> 3.12)
test-unit (~> 3.0)
uri (~> 0.10.1)
uri (~> 0.12.0)
webrick (~> 1.6)
BUNDLED WITH

View File

@ -3,45 +3,48 @@ GEM
specs:
ast (2.4.2)
diff-lcs (1.5.0)
minitest (5.15.0)
parallel (1.21.0)
parser (3.1.0.0)
json (2.6.3)
json (2.6.3-java)
minitest (5.16.3)
parallel (1.22.1)
parser (3.1.3.0)
ast (~> 2.4.1)
power_assert (2.0.1)
power_assert (2.0.2)
rainbow (3.1.1)
rake (13.0.6)
rake-compiler (1.1.7)
rake-compiler (1.2.0)
rake
regexp_parser (2.2.0)
regexp_parser (2.6.1)
rexml (3.2.5)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.2)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.2)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.0)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.3)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.3)
rubocop (1.24.1)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
rubocop (1.40.0)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.0.0.0)
parser (>= 3.1.2.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.15.1, < 2.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.23.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.15.1)
parser (>= 3.0.1.1)
rubocop-ast (1.24.0)
parser (>= 3.1.1.0)
ruby-progressbar (1.11.0)
test-unit (3.5.3)
test-unit (3.5.5)
power_assert
unicode-display_width (2.1.0)
unicode-display_width (2.3.0)
PLATFORMS
aarch64-linux

View File

@ -3,51 +3,56 @@ GEM
specs:
ast (2.4.2)
diff-lcs (1.5.0)
minitest (5.15.0)
parallel (1.21.0)
parser (3.1.0.0)
json (2.6.3)
json (2.6.3-java)
language_server-protocol (3.17.0.2)
minitest (5.16.3)
parallel (1.22.1)
parser (3.1.3.0)
ast (~> 2.4.1)
power_assert (2.0.1)
power_assert (2.0.2)
rainbow (3.1.1)
rake (13.0.6)
rake-compiler (1.1.7)
rake-compiler (1.2.0)
rake
regexp_parser (2.2.0)
regexp_parser (2.6.1)
rexml (3.2.5)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.2)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.2)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.0)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.3)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.3)
rubocop (1.24.1)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
rubocop (1.39.0)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.0.0.0)
parser (>= 3.1.2.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.15.1, < 2.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.23.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.15.1)
parser (>= 3.0.1.1)
rubocop-performance (1.13.1)
rubocop-ast (1.24.0)
parser (>= 3.1.1.0)
rubocop-performance (1.15.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
ruby-progressbar (1.11.0)
standard (1.6.0)
rubocop (= 1.24.1)
rubocop-performance (= 1.13.1)
test-unit (3.5.3)
standard (1.19.1)
language_server-protocol (~> 3.17.0.2)
rubocop (= 1.39.0)
rubocop-performance (= 1.15.1)
test-unit (3.5.5)
power_assert
unicode-display_width (2.1.0)
unicode-display_width (2.3.0)
PLATFORMS
aarch64-linux

View File

@ -5,7 +5,7 @@ GEM
rack-test
builder (3.2.4)
compact_index (0.13.0)
mustermann (1.1.1)
mustermann (1.1.2)
ruby2_keywords (~> 0.0.1)
rack (2.0.8)
rack-protection (2.0.8.1)
@ -19,7 +19,7 @@ GEM
rack (~> 2.0)
rack-protection (= 2.0.8.1)
tilt (~> 2.0)
tilt (2.0.10)
tilt (2.0.11)
webrick (1.7.0)
PLATFORMS