mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Merge RubyGems 3.1.0.pre3
* Fix gem pristine not accounting for user installed gems. Pull request #2914 by Luis Sagastume. * Refactor keyword argument test for Ruby 2.7. Pull request #2947 by SHIBATA Hiroshi. * Fix errors at frozen Gem::Version. Pull request #2949 by Nobuyoshi Nakada. * Remove taint usage on Ruby 2.7+. Pull request #2951 by Jeremy Evans. * Check Manifest.txt is up to date. Pull request #2953 by David Rodríguez. * Clarify symlink conditionals in tests. Pull request #2962 by David Rodríguez. * Update command line parsing to work under ps. Pull request #2966 by David Rodríguez. * Properly test `Gem::Specifications.stub_for`. Pull request #2970 by David Rodríguez. * Fix Gem::LOADED_SPECS_MUTEX handling for recursive locking. Pull request #2985 by MSP-Greg.
This commit is contained in:
parent
3141642380
commit
7d463e360b
Notes:
git
2019-11-11 17:00:21 +09:00
29 changed files with 237 additions and 133 deletions
|
@ -9,7 +9,7 @@
|
||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
|
|
||||||
module Gem
|
module Gem
|
||||||
VERSION = "3.1.0.pre2".freeze
|
VERSION = "3.1.0.pre3".freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
# Must be first since it unloads the prelude from 1.9.2
|
# Must be first since it unloads the prelude from 1.9.2
|
||||||
|
@ -116,6 +116,11 @@ require 'rubygems/path_support'
|
||||||
module Gem
|
module Gem
|
||||||
RUBYGEMS_DIR = File.dirname File.expand_path(__FILE__)
|
RUBYGEMS_DIR = File.dirname File.expand_path(__FILE__)
|
||||||
|
|
||||||
|
# Taint support is deprecated in Ruby 2.7.
|
||||||
|
# This allows switching ".untaint" to ".tap(&Gem::UNTAINT)",
|
||||||
|
# to avoid deprecation warnings in Ruby 2.7.
|
||||||
|
UNTAINT = RUBY_VERSION < '2.7' ? :untaint.to_sym : proc{}
|
||||||
|
|
||||||
##
|
##
|
||||||
# An Array of Regexps that match windows Ruby platforms.
|
# An Array of Regexps that match windows Ruby platforms.
|
||||||
|
|
||||||
|
@ -521,7 +526,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||||
glob_with_suffixes = "#{glob}#{Gem.suffix_pattern}"
|
glob_with_suffixes = "#{glob}#{Gem.suffix_pattern}"
|
||||||
$LOAD_PATH.map do |load_path|
|
$LOAD_PATH.map do |load_path|
|
||||||
Gem::Util.glob_files_in_dir(glob_with_suffixes, load_path)
|
Gem::Util.glob_files_in_dir(glob_with_suffixes, load_path)
|
||||||
end.flatten.select { |file| File.file? file.untaint }
|
end.flatten.select { |file| File.file? file.tap(&Gem::UNTAINT) }
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -1083,7 +1088,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||||
# The home directory for the user.
|
# The home directory for the user.
|
||||||
|
|
||||||
def self.user_home
|
def self.user_home
|
||||||
@user_home ||= find_home.untaint
|
@user_home ||= find_home.tap(&Gem::UNTAINT)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -1150,7 +1155,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||||
globbed = Gem::Util.glob_files_in_dir(glob, load_path)
|
globbed = Gem::Util.glob_files_in_dir(glob, load_path)
|
||||||
|
|
||||||
globbed.each do |load_path_file|
|
globbed.each do |load_path_file|
|
||||||
files << load_path_file if File.file?(load_path_file.untaint)
|
files << load_path_file if File.file?(load_path_file.tap(&Gem::UNTAINT))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1196,7 +1201,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
path.untaint
|
path.tap(&Gem::UNTAINT)
|
||||||
|
|
||||||
unless File.file? path
|
unless File.file? path
|
||||||
return unless raise_exception
|
return unless raise_exception
|
||||||
|
|
|
@ -98,7 +98,7 @@ class Gem::BasicSpecification
|
||||||
# Returns full path to the directory where gem's extensions are installed.
|
# Returns full path to the directory where gem's extensions are installed.
|
||||||
|
|
||||||
def extension_dir
|
def extension_dir
|
||||||
@extension_dir ||= File.expand_path(File.join(extensions_dir, full_name)).untaint
|
@extension_dir ||= File.expand_path(File.join(extensions_dir, full_name)).tap(&Gem::UNTAINT)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -113,7 +113,7 @@ class Gem::BasicSpecification
|
||||||
def find_full_gem_path # :nodoc:
|
def find_full_gem_path # :nodoc:
|
||||||
# TODO: also, shouldn't it default to full_name if it hasn't been written?
|
# TODO: also, shouldn't it default to full_name if it hasn't been written?
|
||||||
path = File.expand_path File.join(gems_dir, full_name)
|
path = File.expand_path File.join(gems_dir, full_name)
|
||||||
path.untaint
|
path.tap(&Gem::UNTAINT)
|
||||||
path
|
path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -135,9 +135,9 @@ class Gem::BasicSpecification
|
||||||
|
|
||||||
def full_name
|
def full_name
|
||||||
if platform == Gem::Platform::RUBY or platform.nil?
|
if platform == Gem::Platform::RUBY or platform.nil?
|
||||||
"#{name}-#{version}".dup.untaint
|
"#{name}-#{version}".dup.tap(&Gem::UNTAINT)
|
||||||
else
|
else
|
||||||
"#{name}-#{version}-#{platform}".dup.untaint
|
"#{name}-#{version}-#{platform}".dup.tap(&Gem::UNTAINT)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ class Gem::BasicSpecification
|
||||||
@full_require_paths ||=
|
@full_require_paths ||=
|
||||||
begin
|
begin
|
||||||
full_paths = raw_require_paths.map do |path|
|
full_paths = raw_require_paths.map do |path|
|
||||||
File.join full_gem_path, path.untaint
|
File.join full_gem_path, path.tap(&Gem::UNTAINT)
|
||||||
end
|
end
|
||||||
|
|
||||||
full_paths << extension_dir if have_extensions?
|
full_paths << extension_dir if have_extensions?
|
||||||
|
@ -163,7 +163,7 @@ class Gem::BasicSpecification
|
||||||
|
|
||||||
def datadir
|
def datadir
|
||||||
# TODO: drop the extra ", gem_name" which is uselessly redundant
|
# TODO: drop the extra ", gem_name" which is uselessly redundant
|
||||||
File.expand_path(File.join(gems_dir, full_name, "data", name)).untaint
|
File.expand_path(File.join(gems_dir, full_name, "data", name)).tap(&Gem::UNTAINT)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -277,7 +277,7 @@ class Gem::BasicSpecification
|
||||||
# TODO: do we need these?? Kill it
|
# TODO: do we need these?? Kill it
|
||||||
glob = File.join(self.lib_dirs_glob, glob)
|
glob = File.join(self.lib_dirs_glob, glob)
|
||||||
|
|
||||||
Dir[glob].map { |f| f.untaint } # FIX our tests are broken, run w/ SAFE=1
|
Dir[glob].map { |f| f.tap(&Gem::UNTAINT) } # FIX our tests are broken, run w/ SAFE=1
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -295,7 +295,7 @@ class Gem::BasicSpecification
|
||||||
"lib" # default value for require_paths for bundler/inline
|
"lib" # default value for require_paths for bundler/inline
|
||||||
end
|
end
|
||||||
|
|
||||||
"#{self.full_gem_path}/#{dirs}".dup.untaint
|
"#{self.full_gem_path}/#{dirs}".dup.tap(&Gem::UNTAINT)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -328,7 +328,7 @@ class Gem::BasicSpecification
|
||||||
|
|
||||||
def have_file?(file, suffixes)
|
def have_file?(file, suffixes)
|
||||||
return true if raw_require_paths.any? do |path|
|
return true if raw_require_paths.any? do |path|
|
||||||
base = File.join(gems_dir, full_name, path.untaint, file).untaint
|
base = File.join(gems_dir, full_name, path.tap(&Gem::UNTAINT), file).tap(&Gem::UNTAINT)
|
||||||
suffixes.any? { |suf| File.file? base + suf }
|
suffixes.any? { |suf| File.file? base + suf }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ To install the missing version, run `gem install bundler:#{vr.first}`
|
||||||
gemfile = ENV["BUNDLE_GEMFILE"]
|
gemfile = ENV["BUNDLE_GEMFILE"]
|
||||||
gemfile = nil if gemfile && gemfile.empty?
|
gemfile = nil if gemfile && gemfile.empty?
|
||||||
Gem::Util.traverse_parents Dir.pwd do |directory|
|
Gem::Util.traverse_parents Dir.pwd do |directory|
|
||||||
next unless gemfile = Gem::GEM_DEP_FILES.find { |f| File.file?(f.untaint) }
|
next unless gemfile = Gem::GEM_DEP_FILES.find { |f| File.file?(f.tap(&Gem::UNTAINT)) }
|
||||||
|
|
||||||
gemfile = File.join directory, gemfile
|
gemfile = File.join directory, gemfile
|
||||||
break
|
break
|
||||||
|
@ -94,7 +94,7 @@ To install the missing version, run `gem install bundler:#{vr.first}`
|
||||||
lockfile = case gemfile
|
lockfile = case gemfile
|
||||||
when "gems.rb" then "gems.locked"
|
when "gems.rb" then "gems.locked"
|
||||||
else "#{gemfile}.lock"
|
else "#{gemfile}.lock"
|
||||||
end.dup.untaint
|
end.dup.tap(&Gem::UNTAINT)
|
||||||
|
|
||||||
return unless File.file?(lockfile)
|
return unless File.file?(lockfile)
|
||||||
|
|
||||||
|
|
|
@ -111,11 +111,6 @@ extensions will be restored.
|
||||||
"Failed to find gems #{options[:args]} #{options[:version]}"
|
"Failed to find gems #{options[:args]} #{options[:version]}"
|
||||||
end
|
end
|
||||||
|
|
||||||
install_dir = Gem.dir # TODO use installer option
|
|
||||||
|
|
||||||
raise Gem::FilePermissionError.new(install_dir) unless
|
|
||||||
File.writable?(install_dir)
|
|
||||||
|
|
||||||
say "Restoring gems to pristine condition..."
|
say "Restoring gems to pristine condition..."
|
||||||
|
|
||||||
specs.each do |spec|
|
specs.each do |spec|
|
||||||
|
|
|
@ -180,7 +180,7 @@ class Gem::ConfigFile
|
||||||
operating_system_config = Marshal.load Marshal.dump(OPERATING_SYSTEM_DEFAULTS)
|
operating_system_config = Marshal.load Marshal.dump(OPERATING_SYSTEM_DEFAULTS)
|
||||||
platform_config = Marshal.load Marshal.dump(PLATFORM_DEFAULTS)
|
platform_config = Marshal.load Marshal.dump(PLATFORM_DEFAULTS)
|
||||||
system_config = load_file SYSTEM_WIDE_CONFIG_FILE
|
system_config = load_file SYSTEM_WIDE_CONFIG_FILE
|
||||||
user_config = load_file config_file_name.dup.untaint
|
user_config = load_file config_file_name.dup.tap(&Gem::UNTAINT)
|
||||||
|
|
||||||
environment_config = (ENV['GEMRC'] || '')
|
environment_config = (ENV['GEMRC'] || '')
|
||||||
.split(File::PATH_SEPARATOR).inject({}) do |result, file|
|
.split(File::PATH_SEPARATOR).inject({}) do |result, file|
|
||||||
|
|
|
@ -61,9 +61,13 @@ module Kernel
|
||||||
|
|
||||||
spec = dep.to_spec
|
spec = dep.to_spec
|
||||||
|
|
||||||
Gem::LOADED_SPECS_MUTEX.synchronize do
|
if spec
|
||||||
spec.activate
|
if Gem::LOADED_SPECS_MUTEX.owned?
|
||||||
end if spec
|
spec.activate
|
||||||
|
else
|
||||||
|
Gem::LOADED_SPECS_MUTEX.synchronize { spec.activate }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private :gem
|
private :gem
|
||||||
|
|
|
@ -41,7 +41,7 @@ module Kernel
|
||||||
resolved_path = begin
|
resolved_path = begin
|
||||||
rp = nil
|
rp = nil
|
||||||
$LOAD_PATH[0...Gem.load_path_insert_index || -1].each do |lp|
|
$LOAD_PATH[0...Gem.load_path_insert_index || -1].each do |lp|
|
||||||
safe_lp = lp.dup.untaint
|
safe_lp = lp.dup.tap(&Gem::UNTAINT)
|
||||||
next if File.symlink? safe_lp # for backword compatibility
|
next if File.symlink? safe_lp # for backword compatibility
|
||||||
Gem.suffixes.each do |s|
|
Gem.suffixes.each do |s|
|
||||||
full_path = File.expand_path(File.join(safe_lp, "#{path}#{s}"))
|
full_path = File.expand_path(File.join(safe_lp, "#{path}#{s}"))
|
||||||
|
|
|
@ -196,8 +196,6 @@ class Gem::Installer
|
||||||
@package.prog_mode = options[:prog_mode]
|
@package.prog_mode = options[:prog_mode]
|
||||||
@package.data_mode = options[:data_mode]
|
@package.data_mode = options[:data_mode]
|
||||||
|
|
||||||
@bin_dir = options[:bin_dir] if options[:bin_dir]
|
|
||||||
|
|
||||||
if options[:user_install]
|
if options[:user_install]
|
||||||
@gem_home = Gem.user_dir
|
@gem_home = Gem.user_dir
|
||||||
@bin_dir = Gem.bindir gem_home unless options[:bin_dir]
|
@bin_dir = Gem.bindir gem_home unless options[:bin_dir]
|
||||||
|
@ -394,7 +392,7 @@ class Gem::Installer
|
||||||
specs = []
|
specs = []
|
||||||
|
|
||||||
Gem::Util.glob_files_in_dir("*.gemspec", File.join(gem_home, "specifications")).each do |path|
|
Gem::Util.glob_files_in_dir("*.gemspec", File.join(gem_home, "specifications")).each do |path|
|
||||||
spec = Gem::Specification.load path.untaint
|
spec = Gem::Specification.load path.tap(&Gem::UNTAINT)
|
||||||
specs << spec if spec
|
specs << spec if spec
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -502,7 +500,7 @@ class Gem::Installer
|
||||||
raise Gem::FilePermissionError.new(@bin_dir) unless File.writable? @bin_dir
|
raise Gem::FilePermissionError.new(@bin_dir) unless File.writable? @bin_dir
|
||||||
|
|
||||||
spec.executables.each do |filename|
|
spec.executables.each do |filename|
|
||||||
filename.untaint
|
filename.tap(&Gem::UNTAINT)
|
||||||
bin_path = File.join gem_dir, spec.bindir, filename
|
bin_path = File.join gem_dir, spec.bindir, filename
|
||||||
|
|
||||||
unless File.exist? bin_path
|
unless File.exist? bin_path
|
||||||
|
@ -633,7 +631,7 @@ class Gem::Installer
|
||||||
|
|
||||||
def ensure_loadable_spec
|
def ensure_loadable_spec
|
||||||
ruby = spec.to_ruby_for_cache
|
ruby = spec.to_ruby_for_cache
|
||||||
ruby.untaint
|
ruby.tap(&Gem::UNTAINT)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
eval ruby
|
eval ruby
|
||||||
|
|
|
@ -55,7 +55,7 @@ class Gem::NameTuple
|
||||||
"#{@name}-#{@version}"
|
"#{@name}-#{@version}"
|
||||||
else
|
else
|
||||||
"#{@name}-#{@version}-#{@platform}"
|
"#{@name}-#{@version}-#{@platform}"
|
||||||
end.dup.untaint
|
end.dup.tap(&Gem::UNTAINT)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -498,7 +498,7 @@ EOM
|
||||||
real_destination.start_with? destination_dir + '/'
|
real_destination.start_with? destination_dir + '/'
|
||||||
end
|
end
|
||||||
|
|
||||||
destination.untaint
|
destination.tap(&Gem::UNTAINT)
|
||||||
destination
|
destination
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ class Gem::PathSupport
|
||||||
|
|
||||||
@spec_cache_dir = env["GEM_SPEC_CACHE"] || Gem.default_spec_cache_dir
|
@spec_cache_dir = env["GEM_SPEC_CACHE"] || Gem.default_spec_cache_dir
|
||||||
|
|
||||||
@spec_cache_dir = @spec_cache_dir.dup.untaint
|
@spec_cache_dir = @spec_cache_dir.dup.tap(&Gem::UNTAINT)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -334,7 +334,7 @@ class Gem::RequestSet
|
||||||
|
|
||||||
@git_set.root_dir = @install_dir
|
@git_set.root_dir = @install_dir
|
||||||
|
|
||||||
lock_file = "#{File.expand_path(path)}.lock".dup.untaint
|
lock_file = "#{File.expand_path(path)}.lock".dup.tap(&Gem::UNTAINT)
|
||||||
begin
|
begin
|
||||||
tokenizer = Gem::RequestSet::Lockfile::Tokenizer.from_file lock_file
|
tokenizer = Gem::RequestSet::Lockfile::Tokenizer.from_file lock_file
|
||||||
parser = tokenizer.make_parser self, []
|
parser = tokenizer.make_parser self, []
|
||||||
|
|
|
@ -280,7 +280,7 @@ class Gem::RequestSet::GemDependencyAPI
|
||||||
# Loads the gem dependency file and returns self.
|
# Loads the gem dependency file and returns self.
|
||||||
|
|
||||||
def load
|
def load
|
||||||
instance_eval File.read(@path).untaint, @path, 1
|
instance_eval File.read(@path).tap(&Gem::UNTAINT), @path, 1
|
||||||
|
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
|
@ -79,7 +79,9 @@ class Gem::RequestSet::Lockfile
|
||||||
@gem_deps_file = File.expand_path(gem_deps_file)
|
@gem_deps_file = File.expand_path(gem_deps_file)
|
||||||
@gem_deps_dir = File.dirname(@gem_deps_file)
|
@gem_deps_dir = File.dirname(@gem_deps_file)
|
||||||
|
|
||||||
@gem_deps_file.untaint unless gem_deps_file.tainted?
|
if RUBY_VERSION < '2.7'
|
||||||
|
@gem_deps_file.untaint unless gem_deps_file.tainted?
|
||||||
|
end
|
||||||
|
|
||||||
@platforms = []
|
@platforms = []
|
||||||
end
|
end
|
||||||
|
|
|
@ -106,7 +106,7 @@ class Gem::Source
|
||||||
def cache_dir(uri)
|
def cache_dir(uri)
|
||||||
# Correct for windows paths
|
# Correct for windows paths
|
||||||
escaped_path = uri.path.sub(/^\/([a-z]):\//i, '/\\1-/')
|
escaped_path = uri.path.sub(/^\/([a-z]):\//i, '/\\1-/')
|
||||||
escaped_path.untaint
|
escaped_path.tap(&Gem::UNTAINT)
|
||||||
|
|
||||||
File.join Gem.spec_cache_dir, "#{uri.host}%#{uri.port}", File.dirname(escaped_path)
|
File.join Gem.spec_cache_dir, "#{uri.host}%#{uri.port}", File.dirname(escaped_path)
|
||||||
end
|
end
|
||||||
|
|
|
@ -763,7 +763,7 @@ class Gem::Specification < Gem::BasicSpecification
|
||||||
def self.each_gemspec(dirs) # :nodoc:
|
def self.each_gemspec(dirs) # :nodoc:
|
||||||
dirs.each do |dir|
|
dirs.each do |dir|
|
||||||
Gem::Util.glob_files_in_dir("*.gemspec", dir).each do |path|
|
Gem::Util.glob_files_in_dir("*.gemspec", dir).each do |path|
|
||||||
yield path.untaint
|
yield path.tap(&Gem::UNTAINT)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -930,7 +930,7 @@ class Gem::Specification < Gem::BasicSpecification
|
||||||
|
|
||||||
def self.dirs
|
def self.dirs
|
||||||
@@dirs ||= Gem.path.collect do |dir|
|
@@dirs ||= Gem.path.collect do |dir|
|
||||||
File.join dir.dup.untaint, "specifications"
|
File.join dir.dup.tap(&Gem::UNTAINT), "specifications"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1112,12 +1112,12 @@ class Gem::Specification < Gem::BasicSpecification
|
||||||
_spec = LOAD_CACHE_MUTEX.synchronize { LOAD_CACHE[file] }
|
_spec = LOAD_CACHE_MUTEX.synchronize { LOAD_CACHE[file] }
|
||||||
return _spec if _spec
|
return _spec if _spec
|
||||||
|
|
||||||
file = file.dup.untaint
|
file = file.dup.tap(&Gem::UNTAINT)
|
||||||
return unless File.file?(file)
|
return unless File.file?(file)
|
||||||
|
|
||||||
code = File.read file, :mode => 'r:UTF-8:-'
|
code = File.read file, :mode => 'r:UTF-8:-'
|
||||||
|
|
||||||
code.untaint
|
code.tap(&Gem::UNTAINT)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
_spec = eval code, binding, file
|
_spec = eval code, binding, file
|
||||||
|
@ -2642,9 +2642,9 @@ class Gem::Specification < Gem::BasicSpecification
|
||||||
case ivar
|
case ivar
|
||||||
when "date"
|
when "date"
|
||||||
# Force Date to go through the extra coerce logic in date=
|
# Force Date to go through the extra coerce logic in date=
|
||||||
self.date = val.untaint
|
self.date = val.tap(&Gem::UNTAINT)
|
||||||
else
|
else
|
||||||
instance_variable_set "@#{ivar}", val.untaint
|
instance_variable_set "@#{ivar}", val.tap(&Gem::UNTAINT)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ class Gem::StubSpecification < Gem::BasicSpecification
|
||||||
|
|
||||||
def initialize(filename, base_dir, gems_dir, default_gem)
|
def initialize(filename, base_dir, gems_dir, default_gem)
|
||||||
super()
|
super()
|
||||||
filename.untaint
|
filename.tap(&Gem::UNTAINT)
|
||||||
|
|
||||||
self.loaded_from = filename
|
self.loaded_from = filename
|
||||||
@data = nil
|
@data = nil
|
||||||
|
|
|
@ -259,10 +259,10 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
|
||||||
Gem::DefaultUserInteraction.ui = Gem::MockGemUi.new
|
Gem::DefaultUserInteraction.ui = Gem::MockGemUi.new
|
||||||
|
|
||||||
tmpdir = File.realpath Dir.tmpdir
|
tmpdir = File.realpath Dir.tmpdir
|
||||||
tmpdir.untaint
|
tmpdir.tap(&Gem::UNTAINT)
|
||||||
|
|
||||||
@tempdir = File.join(tmpdir, "test_rubygems_#{$$}")
|
@tempdir = File.join(tmpdir, "test_rubygems_#{$$}")
|
||||||
@tempdir.untaint
|
@tempdir.tap(&Gem::UNTAINT)
|
||||||
|
|
||||||
FileUtils.mkdir_p @tempdir
|
FileUtils.mkdir_p @tempdir
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
|
||||||
# Short and long path name is specific to Windows filesystem.
|
# Short and long path name is specific to Windows filesystem.
|
||||||
if win_platform?
|
if win_platform?
|
||||||
@tempdir = Dir[@tempdir][0]
|
@tempdir = Dir[@tempdir][0]
|
||||||
@tempdir.untaint
|
@tempdir.tap(&Gem::UNTAINT)
|
||||||
end
|
end
|
||||||
|
|
||||||
@gemhome = File.join @tempdir, 'gemhome'
|
@gemhome = File.join @tempdir, 'gemhome'
|
||||||
|
@ -295,7 +295,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
|
||||||
$LOAD_PATH.map! do |s|
|
$LOAD_PATH.map! do |s|
|
||||||
expand_path = File.realpath(s) rescue File.expand_path(s)
|
expand_path = File.realpath(s) rescue File.expand_path(s)
|
||||||
if expand_path != s
|
if expand_path != s
|
||||||
expand_path.untaint
|
expand_path.tap(&Gem::UNTAINT)
|
||||||
if s.instance_variable_defined?(:@gem_prelude_index)
|
if s.instance_variable_defined?(:@gem_prelude_index)
|
||||||
expand_path.instance_variable_set(:@gem_prelude_index, expand_path)
|
expand_path.instance_variable_set(:@gem_prelude_index, expand_path)
|
||||||
end
|
end
|
||||||
|
@ -527,7 +527,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
gem = File.join(@tempdir, File.basename(spec.cache_file)).untaint
|
gem = File.join(@tempdir, File.basename(spec.cache_file)).tap(&Gem::UNTAINT)
|
||||||
end
|
end
|
||||||
|
|
||||||
Gem::Installer.at(gem, options.merge({:wrappers => true})).install
|
Gem::Installer.at(gem, options.merge({:wrappers => true})).install
|
||||||
|
@ -566,7 +566,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
|
||||||
# Reads a Marshal file at +path+
|
# Reads a Marshal file at +path+
|
||||||
|
|
||||||
def read_cache(path)
|
def read_cache(path)
|
||||||
File.open path.dup.untaint, 'rb' do |io|
|
File.open path.dup.tap(&Gem::UNTAINT), 'rb' do |io|
|
||||||
Marshal.load io.read
|
Marshal.load io.read
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -197,6 +197,8 @@ class Gem::Version
|
||||||
end
|
end
|
||||||
|
|
||||||
@@all = {}
|
@@all = {}
|
||||||
|
@@bump = {}
|
||||||
|
@@release = {}
|
||||||
|
|
||||||
def self.new(version) # :nodoc:
|
def self.new(version) # :nodoc:
|
||||||
return super unless Gem::Version == self
|
return super unless Gem::Version == self
|
||||||
|
@ -227,14 +229,14 @@ class Gem::Version
|
||||||
# Pre-release (alpha) parts, e.g, 5.3.1.b.2 => 5.4, are ignored.
|
# Pre-release (alpha) parts, e.g, 5.3.1.b.2 => 5.4, are ignored.
|
||||||
|
|
||||||
def bump
|
def bump
|
||||||
@bump ||= begin
|
@@bump[self] ||= begin
|
||||||
segments = self.segments
|
segments = self.segments
|
||||||
segments.pop while segments.any? { |s| String === s }
|
segments.pop while segments.any? { |s| String === s }
|
||||||
segments.pop if segments.size > 1
|
segments.pop if segments.size > 1
|
||||||
|
|
||||||
segments[-1] = segments[-1].succ
|
segments[-1] = segments[-1].succ
|
||||||
self.class.new segments.join(".")
|
self.class.new segments.join(".")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -306,13 +308,13 @@ class Gem::Version
|
||||||
# Non-prerelease versions return themselves.
|
# Non-prerelease versions return themselves.
|
||||||
|
|
||||||
def release
|
def release
|
||||||
@release ||= if prerelease?
|
@@release[self] ||= if prerelease?
|
||||||
segments = self.segments
|
segments = self.segments
|
||||||
segments.pop while segments.any? { |s| String === s }
|
segments.pop while segments.any? { |s| String === s }
|
||||||
self.class.new segments.join('.')
|
self.class.new segments.join('.')
|
||||||
else
|
else
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def segments # :nodoc:
|
def segments # :nodoc:
|
||||||
|
@ -374,6 +376,12 @@ class Gem::Version
|
||||||
end.reduce(&:concat)
|
end.reduce(&:concat)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def freeze
|
||||||
|
prerelease?
|
||||||
|
canonical_segments
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def _version
|
def _version
|
||||||
|
|
|
@ -14,14 +14,14 @@ end
|
||||||
# TODO: push this up to test_case.rb once battle tested
|
# TODO: push this up to test_case.rb once battle tested
|
||||||
|
|
||||||
$LOAD_PATH.map! do |path|
|
$LOAD_PATH.map! do |path|
|
||||||
path.dup.untaint
|
path.dup.tap(&Gem::UNTAINT)
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestGem < Gem::TestCase
|
class TestGem < Gem::TestCase
|
||||||
|
|
||||||
PLUGINS_LOADED = [] # rubocop:disable Style/MutableConstant
|
PLUGINS_LOADED = [] # rubocop:disable Style/MutableConstant
|
||||||
|
|
||||||
PROJECT_DIR = File.expand_path('../../..', __FILE__).untaint
|
PROJECT_DIR = File.expand_path('../../..', __FILE__).tap(&Gem::UNTAINT)
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
|
@ -220,7 +220,7 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
assert_equal(expected, result)
|
assert_equal(expected, result)
|
||||||
ensure
|
ensure
|
||||||
File.chmod(0755, *Dir.glob(@gemhome + '/gems/**/').map {|path| path.untaint})
|
File.chmod(0755, *Dir.glob(@gemhome + '/gems/**/').map {|path| path.tap(&Gem::UNTAINT)})
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_require_missing
|
def test_require_missing
|
||||||
|
@ -1617,8 +1617,8 @@ class TestGem < Gem::TestCase
|
||||||
assert_equal expected_specs, Gem.use_gemdeps.sort_by { |s| s.name }
|
assert_equal expected_specs, Gem.use_gemdeps.sort_by { |s| s.name }
|
||||||
end
|
end
|
||||||
|
|
||||||
LIB_PATH = File.expand_path "../../../lib".dup.untaint, __FILE__.dup.untaint
|
LIB_PATH = File.expand_path "../../../lib".dup.tap(&Gem::UNTAINT), __FILE__.dup.tap(&Gem::UNTAINT)
|
||||||
BUNDLER_LIB_PATH = File.expand_path $LOAD_PATH.find {|lp| File.file?(File.join(lp, "bundler.rb")) }.dup.untaint
|
BUNDLER_LIB_PATH = File.expand_path $LOAD_PATH.find {|lp| File.file?(File.join(lp, "bundler.rb")) }.dup.tap(&Gem::UNTAINT)
|
||||||
BUNDLER_FULL_NAME = "bundler-#{Bundler::VERSION}".freeze
|
BUNDLER_FULL_NAME = "bundler-#{Bundler::VERSION}".freeze
|
||||||
|
|
||||||
def add_bundler_full_name(names)
|
def add_bundler_full_name(names)
|
||||||
|
@ -1645,8 +1645,8 @@ class TestGem < Gem::TestCase
|
||||||
ENV['RUBYGEMS_GEMDEPS'] = "-"
|
ENV['RUBYGEMS_GEMDEPS'] = "-"
|
||||||
|
|
||||||
path = File.join @tempdir, "gem.deps.rb"
|
path = File.join @tempdir, "gem.deps.rb"
|
||||||
cmd = [Gem.ruby.dup.untaint, "-I#{LIB_PATH.untaint}",
|
cmd = [Gem.ruby.dup.tap(&Gem::UNTAINT), "-I#{LIB_PATH.tap(&Gem::UNTAINT)}",
|
||||||
"-I#{BUNDLER_LIB_PATH.untaint}", "-rrubygems"]
|
"-I#{BUNDLER_LIB_PATH.tap(&Gem::UNTAINT)}", "-rrubygems"]
|
||||||
cmd << "-eputs Gem.loaded_specs.values.map(&:full_name).sort"
|
cmd << "-eputs Gem.loaded_specs.values.map(&:full_name).sort"
|
||||||
|
|
||||||
File.open path, "w" do |f|
|
File.open path, "w" do |f|
|
||||||
|
@ -1683,8 +1683,8 @@ class TestGem < Gem::TestCase
|
||||||
Dir.mkdir "sub1"
|
Dir.mkdir "sub1"
|
||||||
|
|
||||||
path = File.join @tempdir, "gem.deps.rb"
|
path = File.join @tempdir, "gem.deps.rb"
|
||||||
cmd = [Gem.ruby.dup.untaint, "-Csub1", "-I#{LIB_PATH.untaint}",
|
cmd = [Gem.ruby.dup.tap(&Gem::UNTAINT), "-Csub1", "-I#{LIB_PATH.tap(&Gem::UNTAINT)}",
|
||||||
"-I#{BUNDLER_LIB_PATH.untaint}", "-rrubygems"]
|
"-I#{BUNDLER_LIB_PATH.tap(&Gem::UNTAINT)}", "-rrubygems"]
|
||||||
cmd << "-eputs Gem.loaded_specs.values.map(&:full_name).sort"
|
cmd << "-eputs Gem.loaded_specs.values.map(&:full_name).sort"
|
||||||
|
|
||||||
File.open path, "w" do |f|
|
File.open path, "w" do |f|
|
||||||
|
@ -1732,7 +1732,7 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_use_gemdeps
|
def test_use_gemdeps
|
||||||
gem_deps_file = 'gem.deps.rb'.untaint
|
gem_deps_file = 'gem.deps.rb'.tap(&Gem::UNTAINT)
|
||||||
spec = util_spec 'a', 1
|
spec = util_spec 'a', 1
|
||||||
install_specs spec
|
install_specs spec
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ require 'rubygems/command_manager'
|
||||||
|
|
||||||
class TestGemCommandManager < Gem::TestCase
|
class TestGemCommandManager < Gem::TestCase
|
||||||
|
|
||||||
PROJECT_DIR = File.expand_path('../../..', __FILE__).untaint
|
PROJECT_DIR = File.expand_path('../../..', __FILE__).tap(&Gem::UNTAINT)
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
|
|
|
@ -53,6 +53,55 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
||||||
assert_empty out, out.inspect
|
assert_empty out, out.inspect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_execute_user_install
|
||||||
|
FileUtils.chmod 0555, @gemhome
|
||||||
|
|
||||||
|
a = util_spec "a" do |s|
|
||||||
|
s.executables = %w[foo]
|
||||||
|
s.files = %w[bin/foo lib/a.rb]
|
||||||
|
end
|
||||||
|
|
||||||
|
write_file File.join(@tempdir, "lib", "a.rb") do |fp|
|
||||||
|
fp.puts "puts __FILE__"
|
||||||
|
end
|
||||||
|
|
||||||
|
write_file File.join(@tempdir, "bin", "foo") do |fp|
|
||||||
|
fp.puts "#!/usr/bin/ruby"
|
||||||
|
end
|
||||||
|
|
||||||
|
install_gem_user(a)
|
||||||
|
|
||||||
|
Gem::Specification.dirs = [Gem.dir, Gem.user_dir]
|
||||||
|
|
||||||
|
foo_path = File.join(Gem.user_dir, "gems", a.full_name, "bin", "foo")
|
||||||
|
a_rb_path = File.join(Gem.user_dir, "gems", a.full_name, "lib", "a.rb")
|
||||||
|
|
||||||
|
write_file foo_path do |io|
|
||||||
|
io.puts("I changed it!")
|
||||||
|
end
|
||||||
|
|
||||||
|
write_file a_rb_path do |io|
|
||||||
|
io.puts("I changed it!")
|
||||||
|
end
|
||||||
|
|
||||||
|
@cmd.options[:args] = %w[a]
|
||||||
|
|
||||||
|
use_ui @ui do
|
||||||
|
@cmd.execute
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal "#!/usr/bin/ruby\n", File.read(foo_path), foo_path
|
||||||
|
assert_equal "puts __FILE__\n", File.read(a_rb_path), a_rb_path
|
||||||
|
|
||||||
|
out = @ui.output.split("\n")
|
||||||
|
|
||||||
|
assert_equal "Restoring gems to pristine condition...", out.shift
|
||||||
|
assert_equal "Restored #{a.full_name}", out.shift
|
||||||
|
assert_empty out, out.inspect
|
||||||
|
ensure
|
||||||
|
FileUtils.chmod(0755, @gemhome)
|
||||||
|
end
|
||||||
|
|
||||||
def test_execute_all
|
def test_execute_all
|
||||||
a = util_spec 'a' do |s|
|
a = util_spec 'a' do |s|
|
||||||
s.executables = %w[foo]
|
s.executables = %w[foo]
|
||||||
|
|
|
@ -17,7 +17,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_class_build
|
def test_class_build
|
||||||
if java_platform? && ENV["CI"]
|
if java_platform?
|
||||||
skip("failing on jruby")
|
skip("failing on jruby")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_class_build_rbconfig_make_prog
|
def test_class_build_rbconfig_make_prog
|
||||||
if java_platform? && ENV["CI"]
|
if java_platform?
|
||||||
skip("failing on jruby")
|
skip("failing on jruby")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase
|
||||||
env_make = ENV.delete 'MAKE'
|
env_make = ENV.delete 'MAKE'
|
||||||
ENV['MAKE'] = 'anothermake'
|
ENV['MAKE'] = 'anothermake'
|
||||||
|
|
||||||
if java_platform? && ENV["CI"]
|
if java_platform?
|
||||||
skip("failing on jruby")
|
skip("failing on jruby")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,9 @@ class TestGemInstaller < Gem::InstallerTestCase
|
||||||
|
|
||||||
@@symlink_supported = nil
|
@@symlink_supported = nil
|
||||||
|
|
||||||
|
# Our CI does not currently hit the "symlink not supported" case, but this is
|
||||||
|
# needed for Windows developers without symlink support enabled (the default
|
||||||
|
# for non admin) to be able to run the tests successfully
|
||||||
def symlink_supported?
|
def symlink_supported?
|
||||||
if @@symlink_supported.nil?
|
if @@symlink_supported.nil?
|
||||||
begin
|
begin
|
||||||
|
@ -544,7 +547,7 @@ gem 'other', version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generate_bin_symlink
|
def test_generate_bin_symlink
|
||||||
return if win_platform? #Windows FS do not support symlinks
|
skip "Symlinks not supported or not enabled" unless symlink_supported?
|
||||||
|
|
||||||
installer = setup_base_installer
|
installer = setup_base_installer
|
||||||
|
|
||||||
|
@ -596,7 +599,7 @@ gem 'other', version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generate_bin_symlink_update_newer
|
def test_generate_bin_symlink_update_newer
|
||||||
return if win_platform? #Windows FS do not support symlinks
|
skip "Symlinks not supported or not enabled" unless symlink_supported?
|
||||||
|
|
||||||
installer = setup_base_installer
|
installer = setup_base_installer
|
||||||
|
|
||||||
|
@ -628,7 +631,7 @@ gem 'other', version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generate_bin_symlink_update_older
|
def test_generate_bin_symlink_update_older
|
||||||
return if !symlink_supported?
|
skip "Symlinks not supported or not enabled" unless symlink_supported?
|
||||||
|
|
||||||
installer = setup_base_installer
|
installer = setup_base_installer
|
||||||
|
|
||||||
|
@ -666,7 +669,7 @@ gem 'other', version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generate_bin_symlink_update_remove_wrapper
|
def test_generate_bin_symlink_update_remove_wrapper
|
||||||
return if !symlink_supported?
|
skip "Symlinks not supported or not enabled" unless symlink_supported?
|
||||||
|
|
||||||
installer = setup_base_installer
|
installer = setup_base_installer
|
||||||
|
|
||||||
|
@ -739,7 +742,7 @@ gem 'other', version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generate_bin_uses_default_shebang
|
def test_generate_bin_uses_default_shebang
|
||||||
return if !symlink_supported?
|
skip "Symlinks not supported or not enabled" unless symlink_supported?
|
||||||
|
|
||||||
installer = setup_base_installer
|
installer = setup_base_installer
|
||||||
|
|
||||||
|
|
|
@ -703,12 +703,12 @@ class TestGemPackage < Gem::Package::TarTestCase
|
||||||
package = Gem::Package.new @gem
|
package = Gem::Package.new @gem
|
||||||
|
|
||||||
file = 'file.rb'.dup
|
file = 'file.rb'.dup
|
||||||
file.taint
|
file.taint if RUBY_VERSION < '2.7'
|
||||||
|
|
||||||
destination = package.install_location file, @destination
|
destination = package.install_location file, @destination
|
||||||
|
|
||||||
assert_equal File.join(@destination, 'file.rb'), destination
|
assert_equal File.join(@destination, 'file.rb'), destination
|
||||||
refute destination.tainted?
|
refute destination.tainted? if RUBY_VERSION < '2.7'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_install_location_absolute
|
def test_install_location_absolute
|
||||||
|
@ -742,14 +742,14 @@ class TestGemPackage < Gem::Package::TarTestCase
|
||||||
package = Gem::Package.new @gem
|
package = Gem::Package.new @gem
|
||||||
|
|
||||||
file = 'foo//file.rb'.dup
|
file = 'foo//file.rb'.dup
|
||||||
file.taint
|
file.taint if RUBY_VERSION < '2.7'
|
||||||
|
|
||||||
destination = @destination.sub '/', '//'
|
destination = @destination.sub '/', '//'
|
||||||
|
|
||||||
destination = package.install_location file, destination
|
destination = package.install_location file, destination
|
||||||
|
|
||||||
assert_equal File.join(@destination, 'foo', 'file.rb'), destination
|
assert_equal File.join(@destination, 'foo', 'file.rb'), destination
|
||||||
refute destination.tainted?
|
refute destination.tainted? if RUBY_VERSION < '2.7'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_install_location_relative
|
def test_install_location_relative
|
||||||
|
|
|
@ -939,22 +939,24 @@ dependencies: []
|
||||||
assert_equal File.join(@tempdir, 'a-2.gemspec'), spec.loaded_from
|
assert_equal File.join(@tempdir, 'a-2.gemspec'), spec.loaded_from
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_load_tainted
|
if RUBY_VERSION < '2.7'
|
||||||
full_path = @a2.spec_file
|
def test_self_load_tainted
|
||||||
write_file full_path do |io|
|
full_path = @a2.spec_file
|
||||||
io.write @a2.to_ruby_for_cache
|
write_file full_path do |io|
|
||||||
|
io.write @a2.to_ruby_for_cache
|
||||||
|
end
|
||||||
|
|
||||||
|
full_path.taint
|
||||||
|
loader = Thread.new { $SAFE = 1; Gem::Specification.load full_path }
|
||||||
|
spec = loader.value
|
||||||
|
|
||||||
|
@a2.files.clear
|
||||||
|
|
||||||
|
assert_equal @a2, spec
|
||||||
|
|
||||||
|
ensure
|
||||||
|
$SAFE = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
full_path.taint
|
|
||||||
loader = Thread.new { $SAFE = 1; Gem::Specification.load full_path }
|
|
||||||
spec = loader.value
|
|
||||||
|
|
||||||
@a2.files.clear
|
|
||||||
|
|
||||||
assert_equal @a2, spec
|
|
||||||
|
|
||||||
ensure
|
|
||||||
$SAFE = 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_load_escape_curly
|
def test_self_load_escape_curly
|
||||||
|
@ -1160,12 +1162,11 @@ dependencies: []
|
||||||
# Create gemspecs in three locations used in stubs
|
# Create gemspecs in three locations used in stubs
|
||||||
loaded_spec = Gem::Specification.new 'a', '3'
|
loaded_spec = Gem::Specification.new 'a', '3'
|
||||||
Gem.loaded_specs['a'] = loaded_spec
|
Gem.loaded_specs['a'] = loaded_spec
|
||||||
save_gemspec 'a', '2', dir_default_specs
|
save_gemspec('a-2', '2', dir_default_specs) { |s| s.name = 'a' }
|
||||||
save_gemspec 'a', '1', dir_standard_specs
|
save_gemspec('a-1', '1', dir_standard_specs) { |s| s.name = 'a' }
|
||||||
|
|
||||||
full_names = ['a-3', 'a-2', 'a-1']
|
full_names = ['a-3', 'a-2', 'a-1']
|
||||||
|
|
||||||
full_names = Gem::Specification.stubs_for('a').map { |s| s.full_name }
|
|
||||||
assert_equal full_names, Gem::Specification.stubs_for('a').map { |s| s.full_name }
|
assert_equal full_names, Gem::Specification.stubs_for('a').map { |s| s.full_name }
|
||||||
assert_equal 1, Gem::Specification.class_variable_get(:@@stubs_by_name).length
|
assert_equal 1, Gem::Specification.class_variable_get(:@@stubs_by_name).length
|
||||||
|
|
||||||
|
@ -2472,7 +2473,7 @@ Gem::Specification.new do |s|
|
||||||
s.email = "example@example.com".freeze
|
s.email = "example@example.com".freeze
|
||||||
s.files = ["lib/code.rb".freeze]
|
s.files = ["lib/code.rb".freeze]
|
||||||
s.homepage = "http://example.com".freeze
|
s.homepage = "http://example.com".freeze
|
||||||
s.rubygems_version = "3.1.0.pre2".freeze
|
s.rubygems_version = "#{Gem::VERSION}".freeze
|
||||||
s.summary = "this is a summary".freeze
|
s.summary = "this is a summary".freeze
|
||||||
end
|
end
|
||||||
SPEC
|
SPEC
|
||||||
|
|
|
@ -217,6 +217,13 @@ class TestGemVersion < Gem::TestCase
|
||||||
assert_equal [1, 2, 3, "pre", 1], v("1.2.3-1").canonical_segments
|
assert_equal [1, 2, 3, "pre", 1], v("1.2.3-1").canonical_segments
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_frozen_version
|
||||||
|
v = v('1.freeze.test').freeze
|
||||||
|
assert_less_than v, v('1')
|
||||||
|
assert_version_equal v('1'), v.release
|
||||||
|
assert_version_equal v('2'), v.bump
|
||||||
|
end
|
||||||
|
|
||||||
# Asserts that +version+ is a prerelease.
|
# Asserts that +version+ is a prerelease.
|
||||||
|
|
||||||
def assert_prerelease(version)
|
def assert_prerelease(version)
|
||||||
|
|
58
test/rubygems/test_project_sanity.rb
Normal file
58
test/rubygems/test_project_sanity.rb
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "rubygems/test_case"
|
||||||
|
require "open3"
|
||||||
|
|
||||||
|
class TestProjectSanity < Minitest::Test
|
||||||
|
|
||||||
|
def test_rake_package_builds_ok
|
||||||
|
skip unless File.exist?(File.expand_path("../../../Rakefile", __FILE__))
|
||||||
|
|
||||||
|
with_empty_pkg_folder do
|
||||||
|
output, status = Open3.capture2e("rake package")
|
||||||
|
|
||||||
|
assert_equal true, status.success?, <<~MSG.chomp
|
||||||
|
Expected `rake package` to work, but got errors:
|
||||||
|
|
||||||
|
```
|
||||||
|
#{output}
|
||||||
|
```
|
||||||
|
|
||||||
|
If you have added or removed files, make sure you run `rake update_manifest` to update the `Manifest.txt` accordingly
|
||||||
|
MSG
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_manifest_is_up_to_date
|
||||||
|
skip unless File.exist?(File.expand_path("../../../Rakefile", __FILE__))
|
||||||
|
|
||||||
|
_, status = Open3.capture2e("rake check_manifest")
|
||||||
|
|
||||||
|
assert status.success?, "Expected Manifest.txt to be up to date, but it's not. Run `rake update_manifest` to sync it."
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def with_empty_pkg_folder
|
||||||
|
if File.exist?("pkg")
|
||||||
|
FileUtils.cp_r("pkg", "tmp")
|
||||||
|
|
||||||
|
begin
|
||||||
|
FileUtils.rm_rf("pkg")
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
FileUtils.rm_rf("pkg")
|
||||||
|
FileUtils.cp_r("tmp/pkg", ".")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Dir.mkdir("pkg")
|
||||||
|
|
||||||
|
begin
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
FileUtils.rm_rf("pkg")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -1,26 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
require "rubygems/test_case"
|
|
||||||
require "open3"
|
|
||||||
|
|
||||||
class TestRakePackage < Minitest::Test
|
|
||||||
|
|
||||||
def test_builds_ok
|
|
||||||
skip unless File.exist?(File.expand_path("../../../Rakefile", __FILE__))
|
|
||||||
|
|
||||||
output, status = Open3.capture2e("rake package")
|
|
||||||
|
|
||||||
assert_equal true, status.success?, <<~MSG.chomp
|
|
||||||
Expected `rake package` to work, but got errors:
|
|
||||||
|
|
||||||
```
|
|
||||||
#{output}
|
|
||||||
```
|
|
||||||
|
|
||||||
If you have added or removed files, make sure you run `rake update_manifest` to update the `Manifest.txt` accordingly
|
|
||||||
MSG
|
|
||||||
|
|
||||||
FileUtils.rm_f "pkg"
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
Loading…
Add table
Add a link
Reference in a new issue