summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/rubygems.rb156
-rw-r--r--lib/rubygems/basic_specification.rb8
-rw-r--r--lib/rubygems/command.rb6
-rw-r--r--lib/rubygems/command_manager.rb1
-rw-r--r--lib/rubygems/commands/help_command.rb2
-rw-r--r--lib/rubygems/commands/info_command.rb13
-rw-r--r--lib/rubygems/commands/install_command.rb6
-rw-r--r--lib/rubygems/commands/list_command.rb15
-rw-r--r--lib/rubygems/commands/pristine_command.rb12
-rw-r--r--lib/rubygems/commands/search_command.rb14
-rw-r--r--lib/rubygems/commands/setup_command.rb19
-rw-r--r--lib/rubygems/commands/sources_command.rb6
-rw-r--r--lib/rubygems/commands/update_command.rb37
-rw-r--r--lib/rubygems/deprecate.rb18
-rw-r--r--lib/rubygems/doctor.rb2
-rw-r--r--lib/rubygems/exceptions.rb13
-rw-r--r--lib/rubygems/gem_runner.rb10
-rw-r--r--lib/rubygems/installer.rb38
-rw-r--r--lib/rubygems/installer_test_case.rb4
-rw-r--r--lib/rubygems/installer_uninstaller_utils.rb24
-rw-r--r--lib/rubygems/package.rb3
-rw-r--r--lib/rubygems/query_utils.rb362
-rw-r--r--lib/rubygems/remote_fetcher.rb14
-rw-r--r--lib/rubygems/request_set/gem_dependency_api.rb2
-rw-r--r--lib/rubygems/resolver/api_set.rb2
-rw-r--r--lib/rubygems/resolver/api_specification.rb2
-rw-r--r--lib/rubygems/security.rb8
-rw-r--r--lib/rubygems/security/signer.rb2
-rw-r--r--lib/rubygems/server.rb2
-rw-r--r--lib/rubygems/specification.rb33
-rw-r--r--lib/rubygems/specification_policy.rb3
-rw-r--r--lib/rubygems/test_case.rb58
-rw-r--r--lib/rubygems/uninstaller.rb36
-rw-r--r--lib/rubygems/user_interaction.rb8
-rw-r--r--lib/rubygems/version.rb2
-rw-r--r--test/rubygems/test_deprecate.rb18
-rw-r--r--test/rubygems/test_gem.rb79
-rw-r--r--test/rubygems/test_gem_command_manager.rb41
-rw-r--r--test/rubygems/test_gem_commands_build_command.rb2
-rw-r--r--test/rubygems/test_gem_commands_pristine_command.rb37
-rw-r--r--test/rubygems/test_gem_commands_query_command.rb857
-rw-r--r--test/rubygems/test_gem_commands_setup_command.rb37
-rw-r--r--test/rubygems/test_gem_commands_sources_command.rb40
-rw-r--r--test/rubygems/test_gem_commands_update_command.rb54
-rw-r--r--test/rubygems/test_gem_config_file.rb7
-rw-r--r--test/rubygems/test_gem_dependency_installer.rb2
-rw-r--r--test/rubygems/test_gem_doctor.rb28
-rw-r--r--test/rubygems/test_gem_gem_runner.rb30
-rw-r--r--test/rubygems/test_gem_installer.rb74
-rw-r--r--test/rubygems/test_gem_remote_fetcher.rb25
-rw-r--r--test/rubygems/test_gem_request_set.rb52
-rw-r--r--test/rubygems/test_gem_specification.rb13
-rw-r--r--test/rubygems/test_gem_uninstaller.rb104
-rw-r--r--test/rubygems/test_gem_version.rb2
54 files changed, 1236 insertions, 1207 deletions
@@ -9,7 +9,7 @@
require 'rbconfig'
module Gem
- VERSION = "3.1.2".freeze
end
# Must be first since it unloads the prelude from 1.9.2
@@ -26,27 +26,27 @@ require 'rubygems/errors'
# For user documentation, see:
#
# * <tt>gem help</tt> and <tt>gem help [command]</tt>
-# * {RubyGems User Guide}[http://guides.rubygems.org/]
-# * {Frequently Asked Questions}[http://guides.rubygems.org/faqs]
#
# For gem developer documentation see:
#
-# * {Creating Gems}[http://guides.rubygems.org/make-your-own-gem]
# * Gem::Specification
# * Gem::Version for version dependency notes
#
# Further RubyGems documentation can be found at:
#
-# * {RubyGems Guides}[http://guides.rubygems.org]
-# * {RubyGems API}[http://www.rubydoc.info//rubygems/rubygems] (also available from
# <tt>gem server</tt>)
#
# == RubyGems Plugins
#
-# As of RubyGems 1.3.2, RubyGems will load plugins installed in gems or
# $LOAD_PATH. Plugins must be named 'rubygems_plugin' (.rb, .so, etc) and
-# placed at the root of your gem's #require_path. Plugins are discovered via
-# Gem::find_files and then loaded.
#
# For an example plugin, see the {Graph gem}[https://.com/seattlerb/graph]
# which adds a `gem graph` command.
@@ -148,6 +148,7 @@ module Gem
doc
extensions
gems
specifications
].freeze
@@ -409,8 +410,6 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
##
# The path where gems are to be installed.
- #--
- # FIXME deprecate these once everything else has been done -ebh
def self.dir
paths.home
@@ -424,6 +423,10 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
paths.spec_cache_dir
end
##
# Quietly ensure the Gem directory +dir+ contains all the proper
# subdirectories. If we can't create a directory due to a permission
@@ -573,50 +576,6 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
private_class_method :find_home
- # TODO: remove in RubyGems 4.0
-
- ##
- # Zlib::GzipReader wrapper that unzips +data+.
-
- def self.gunzip(data)
- Gem::Util.gunzip data
- end
-
- class << self
-
- extend Gem::Deprecate
- deprecate :gunzip, "Gem::Util.gunzip", 2018, 12
-
- end
-
- ##
- # Zlib::GzipWriter wrapper that zips +data+.
-
- def self.gzip(data)
- Gem::Util.gzip data
- end
-
- class << self
-
- extend Gem::Deprecate
- deprecate :gzip, "Gem::Util.gzip", 2018, 12
-
- end
-
- ##
- # A Zlib::Inflate#inflate wrapper
-
- def self.inflate(data)
- Gem::Util.inflate data
- end
-
- class << self
-
- extend Gem::Deprecate
- deprecate :inflate, "Gem::Util.inflate", 2018, 12
-
- end
-
##
# Top level install helper method. Allows you to install gems interactively:
#
@@ -1018,11 +977,28 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
@suffix_pattern ||= "{#{suffixes.join(',')}}"
end
def self.suffix_regexp
@suffix_regexp ||= /#{Regexp.union(suffixes)}\z/
end
##
# Suffixes for require-able paths.
def self.suffixes
@@ -1120,35 +1096,17 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
end
##
- # Find the 'rubygems_plugin' files in the latest installed gems and load
- # them
def self.load_plugins
- # Remove this env var by at least 3.0
- if ENV['RUBYGEMS_LOAD_ALL_PLUGINS']
- load_plugin_files find_files('rubygems_plugin', false)
- else
- load_plugin_files find_latest_files('rubygems_plugin', false)
- end
end
##
# Find all 'rubygems_plugin' files in $LOAD_PATH and load them
def self.load_env_plugins
- path = "rubygems_plugin"
-
- files = []
- glob = "#{path}#{Gem.suffix_pattern}"
- $LOAD_PATH.each do |load_path|
- globbed = Gem::Util.glob_files_in_dir(glob, load_path)
-
- globbed.each do |load_path_file|
- files << load_path_file if File.file?(load_path_file.tap(&Gem::UNTAINT))
- end
- end
-
- load_plugin_files files
end
##
@@ -1223,18 +1181,6 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
end
end
- class << self
-
- ##
- # TODO remove with RubyGems 4.0
-
- alias detect_gemdeps use_gemdeps # :nodoc:
-
- extend Gem::Deprecate
- deprecate :detect_gemdeps, "Gem.use_gemdeps", 2018, 12
-
- end
-
##
# The SOURCE_DATE_EPOCH environment variable (or, if that's not set, the current time), converted to Time object.
# This is used throughout RubyGems for enabling reproducible builds.
@@ -1366,23 +1312,23 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
MARSHAL_SPEC_DIR = "quick/Marshal.#{Gem.marshal_version}/".freeze
- autoload :BundlerVersionFinder, 'rubygems/bundler_version_finder'
- autoload :ConfigFile, 'rubygems/config_file'
- autoload :Dependency, 'rubygems/dependency'
- autoload :DependencyList, 'rubygems/dependency_list'
- autoload :Installer, 'rubygems/installer'
- autoload :Licenses, 'rubygems/util/licenses'
- autoload :PathSupport, 'rubygems/path_support'
- autoload :Platform, 'rubygems/platform'
- autoload :RequestSet, 'rubygems/request_set'
- autoload :Requirement, 'rubygems/requirement'
- autoload :Resolver, 'rubygems/resolver'
- autoload :Source, 'rubygems/source'
- autoload :SourceList, 'rubygems/source_list'
- autoload :SpecFetcher, 'rubygems/spec_fetcher'
- autoload :Specification, 'rubygems/specification'
- autoload :Util, 'rubygems/util'
- autoload :Version, 'rubygems/version'
require "rubygems/specification"
end
@@ -274,13 +274,19 @@ class Gem::BasicSpecification
# Return all files in this gem that match for +glob+.
def matches_for_glob(glob) # TODO: rename?
- # TODO: do we need these?? Kill it
glob = File.join(self.lib_dirs_glob, glob)
Dir[glob].map { |f| f.tap(&Gem::UNTAINT) } # FIX our tests are broken, run w/ SAFE=1
end
##
# Returns a string usable in Dir.glob to match all requirable paths
# for this spec.
@@ -466,6 +466,10 @@ class Gem::Command
result
end
private
def option_is_deprecated?(option)
@@ -646,7 +650,7 @@ basic help message containing pointers to more information.
http://localhost:8808/
with info about installed gems
Further information:
- http://guides.rubygems.org
HELP
# :startdoc:
@@ -176,6 +176,7 @@ class Gem::CommandManager
cmd_name = args.shift.downcase
cmd = find_command cmd_name
cmd.invoke_with_build_args args, build_args
end
end
@@ -38,7 +38,7 @@ Some examples of 'gem' usage.
* Create a gem:
- See http://guides.rubygems.org/make-your-own-gem/
* See information about RubyGems:
@@ -1,14 +1,19 @@
# frozen_string_literal: true
require 'rubygems/command'
-require 'rubygems/commands/query_command'
-class Gem::Commands::InfoCommand < Gem::Commands::QueryCommand
def initialize
- super "info", "Show information for the given gem"
- remove_option('--name-matches')
remove_option('-d')
defaults[:details] = true
@@ -218,7 +218,7 @@ You can use `i` command instead of `install`.
gem_version ||= options[:version]
domain = options[:domain]
domain = :local unless options[:suggest_alternate]
- supress_suggestions = (domain == :local)
begin
install_gem gem_name, gem_version
@@ -226,11 +226,11 @@ You can use `i` command instead of `install`.
alert_error "Error installing #{gem_name}:\n\t#{e.message}"
exit_code |= 1
rescue Gem::GemNotFoundException => e
- show_lookup_failure e.name, e.version, e.errors, supress_suggestions
exit_code |= 2
rescue Gem::UnsatisfiableDependencyError => e
- show_lookup_failure e.name, e.version, e.errors, supress_suggestions,
"'#{gem_name}' (#{gem_version})"
exit_code |= 2
@@ -1,17 +1,20 @@
# frozen_string_literal: true
require 'rubygems/command'
-require 'rubygems/commands/query_command'
##
-# An alternate to Gem::Commands::QueryCommand that searches for gems starting
-# with the supplied argument.
-class Gem::Commands::ListCommand < Gem::Commands::QueryCommand
def initialize
- super 'list', 'Display local gems whose name matches REGEXP'
- remove_option('--name-matches')
end
def arguments # :nodoc:
@@ -40,6 +40,11 @@ class Gem::Commands::PristineCommand < Gem::Command
options[:only_executables] = value
end
add_option('-E', '--[no-]env-shebang',
'Rewrite executables with a shebang',
'of /usr/bin/env') do |value, options|
@@ -126,14 +131,14 @@ extensions will be restored.
end
end
- unless spec.extensions.empty? or options[:extensions] or options[:only_executables]
say "Skipped #{spec.full_name}, it needs to compile an extension"
next
end
gem = spec.cache_file
- unless File.exist? gem or options[:only_executables]
require 'rubygems/remote_fetcher'
say "Cached gem for #{spec.full_name} not found, attempting to fetch..."
@@ -172,6 +177,9 @@ extensions will be restored.
if options[:only_executables]
installer = Gem::Installer.for_spec(spec, installer_options)
installer.generate_bin
else
installer = Gem::Installer.at(gem, installer_options)
installer.install
@@ -1,15 +1,17 @@
# frozen_string_literal: true
require 'rubygems/command'
-require 'rubygems/commands/query_command'
-class Gem::Commands::SearchCommand < Gem::Commands::QueryCommand
- def initialize
- super 'search', 'Display remote gems whose name matches REGEXP'
- remove_option '--name-matches'
- defaults[:domain] = :remote
end
def arguments # :nodoc:
@@ -20,7 +20,8 @@ class Gem::Commands::SetupCommand < Gem::Command
:force => true,
:site_or_vendor => 'sitelibdir',
:destdir => '', :prefix => '', :previous_version => '',
- :regenerate_binstubs => true
add_option '--previous-version=VERSION',
'Previous version of RubyGems',
@@ -89,6 +90,11 @@ class Gem::Commands::SetupCommand < Gem::Command
options[:regenerate_binstubs] = value
end
add_option '-f', '--[no-]force',
'Forcefully overwrite binstubs' do |value, options|
options[:force] = value
@@ -181,6 +187,7 @@ By default, this RubyGems will install gem as:
say "RubyGems #{Gem::VERSION} installed"
regenerate_binstubs if options[:regenerate_binstubs]
uninstall_old_gemcutter
@@ -626,6 +633,16 @@ abort "#{deprecation_message}"
command.invoke(*args)
end
private
def target_bin_path(bin_dir, bin_file)
@@ -136,7 +136,7 @@ RubyGems has been configured to serve gems via the following URLs through
its history:
* http://gems.rubyforge.org (RubyGems 1.3.6 and earlier)
-* http://rubygems.org (RubyGems 1.3.7 through 1.8.25)
* https://rubygems.org (RubyGems 2.0.1 and newer)
Since all of these sources point to the same set of gems you only need one
@@ -153,8 +153,8 @@ before it is added.
To remove a source use the --remove argument:
- $ gem sources --remove http://rubygems.org
- http://rubygems.org removed from sources
EOF
end
@@ -73,8 +73,6 @@ command to remove old versions.
say "Latest version already installed. Done."
terminate_interaction
end
-
- options[:user_install] = false
end
def check_update_arguments # :nodoc:
@@ -90,9 +88,10 @@ command to remove old versions.
return
end
- hig = highest_installed_gems
-
- gems_to_update = which_to_update hig, options[:args].uniq
if options[:explain]
say "Gems to update:"
@@ -137,6 +136,9 @@ command to remove old versions.
def highest_installed_gems # :nodoc:
hig = {} # highest installed gems
Gem::Specification.each do |spec|
if hig[spec.name].nil? or hig[spec.name].version < spec.version
hig[spec.name] = spec
@@ -168,11 +170,34 @@ command to remove old versions.
Dir.chdir update_dir do
say "Installing RubyGems #{version}"
- installed = system Gem.ruby, '--disable-gems', 'setup.rb', *args
say "RubyGems system software updated" if installed
end
end
def rubygems_target_version
version = options[:system]
update_latest = version == true
@@ -65,6 +65,22 @@ module Gem::Deprecate
end
end
- module_function :deprecate, :skip_during
end
@@ -26,6 +26,7 @@ class Gem::Doctor
['doc', ''],
['extensions', ''],
['gems', ''],
].freeze
missing =
@@ -112,6 +113,7 @@ class Gem::Doctor
next if installed_specs.include? basename
next if /^rubygems-\d/ =~ basename
next if 'specifications' == sub_directory and 'default' == basename
type = File.directory?(child) ? 'directory' : 'file'
@@ -5,18 +5,7 @@ require 'rubygems/deprecate'
##
# Base exception class for RubyGems. All exception raised by RubyGems are a
# subclass of this one.
-class Gem::Exception < RuntimeError
-
- ##
- #--
- # TODO: remove in RubyGems 4, nobody sets this
-
- attr_accessor :source_exception # :nodoc:
-
- extend Gem::Deprecate
- deprecate :source_exception, :none, 2018, 12
-
-end
class Gem::CommandLineError < Gem::Exception; end
@@ -26,13 +26,9 @@ Gem.load_env_plugins rescue nil
class Gem::GemRunner
- def initialize(options={})
- if !options.empty? && !Gem::Deprecate.skip
- Kernel.warn "NOTE: passing options to Gem::GemRunner.new is deprecated with no replacement. It will be removed on or after 2016-10-01."
- end
-
- @command_manager_class = options[:command_manager] || Gem::CommandManager
- @config_file_class = options[:config_file] || Gem::ConfigFile
end
##
@@ -6,6 +6,7 @@
#++
require 'rubygems/command'
require 'rubygems/exceptions'
require 'rubygems/deprecate'
require 'rubygems/package'
@@ -43,6 +44,8 @@ class Gem::Installer
include Gem::UserInteraction
##
# Filename of the gem being installed.
@@ -180,15 +183,7 @@ class Gem::Installer
require 'fileutils'
@options = options
- if package.is_a? String
- security_policy = options[:security_policy]
- @package = Gem::Package.new package, security_policy
- if $VERBOSE
- warn "constructing an Installer object with a string is deprecated. Please use Gem::Installer.at (called from: #{caller.first})"
- end
- else
- @package = package
- end
process_options
@@ -330,6 +325,7 @@ class Gem::Installer
end
generate_bin
unless @options[:install_as_default]
write_spec
@@ -520,7 +516,17 @@ class Gem::Installer
else
generate_bin_symlink filename, @bin_dir
end
end
end
@@ -810,7 +816,7 @@ TEXT
ruby_exe = "ruby.exe" if ruby_exe.empty?
if File.exist?(File.join bindir, ruby_exe)
- # stub & ruby.exe withing same folder. Portable
<<-TEXT
@ECHO OFF
@"%~dp0#{ruby_exe}" "%~dpn0" %*
@@ -845,18 +851,6 @@ TEXT
end
##
- # Logs the build +output+ in +build_dir+, then raises Gem::Ext::BuildError.
- #
- # TODO: Delete this for RubyGems 4. It remains for API compatibility
-
- def extension_build_error(build_dir, output, backtrace = nil) # :nodoc:
- builder = Gem::Ext::Builder.new spec, @build_args
-
- builder.build_error build_dir, output, backtrace
- end
- deprecate :extension_build_error, :none, 2018, 12
-
- ##
# Reads the file index and extracts each file into the gem directory.
#
# Ensures that files can't be installed outside the gem directory.
@@ -171,10 +171,10 @@ class Gem::InstallerTestCase < Gem::TestCase
##
# Sets up the base @gem, builds it and returns an installer for it.
#
- def util_setup_installer
@gem = setup_base_gem
- util_setup_gem
end
##
@@ -0,0 +1,24 @@
@@ -8,7 +8,8 @@
# Example using a Gem::Package
#
# Builds a .gem file given a Gem::Specification. A .gem file is a tarball
-# which contains a data.tar.gz and metadata.gz, and possibly signatures.
#
# require 'rubygems'
# require 'rubygems/package'
@@ -0,0 +1,362 @@
@@ -7,7 +7,6 @@ require 'rubygems/uri_formatter'
require 'rubygems/uri_parsing'
require 'rubygems/user_interaction'
require 'resolv'
-require 'rubygems/deprecate'
##
# RemoteFetcher handles the details of fetching gems and gem information from
@@ -16,8 +15,6 @@ require 'rubygems/deprecate'
class Gem::RemoteFetcher
include Gem::UserInteraction
- extend Gem::Deprecate
-
include Gem::UriParsing
##
@@ -310,17 +307,6 @@ class Gem::RemoteFetcher
end
##
- # Returns the size of +uri+ in bytes.
-
- def fetch_size(uri)
- response = fetch_path(uri, nil, true)
-
- response['content-length'].to_i
- end
-
- deprecate :fetch_size, :none, 2019, 12
-
- ##
# Performs a Net::HTTP request of type +request_class+ on +uri+ returning
# a Net::HTTP response object. request maintains a table of persistent
# connections to reduce connect overhead.
@@ -235,7 +235,7 @@ class Gem::RequestSet::GemDependencyAPI
return unless (groups & @without_groups).empty?
dependencies.each do |dep|
- @set.gem dep.name, *dep.requirement
end
end
@@ -23,7 +23,7 @@ class Gem::Resolver::APISet < Gem::Resolver::Set
##
# Creates a new APISet that will retrieve gems from +uri+ using the RubyGems
# API URL +dep_uri+ which is described at
- # http://guides.rubygems.org/rubygems-org-api
def initialize(dep_uri = 'https://rubygems.org/api/v1/dependencies')
super()
@@ -11,7 +11,7 @@ class Gem::Resolver::APISpecification < Gem::Resolver::Specification
# Creates an APISpecification for the given +set+ from the rubygems.org
# +api_data+.
#
- # See http://guides.rubygems.org/rubygems-org-api/#misc_methods for the
# format of the +api_data+.
def initialize(set, api_data)
@@ -62,11 +62,11 @@ end
#
# $ tar tf your-gem-1.0.gem
# metadata.gz
-# metadata.gz.sum
# metadata.gz.sig # metadata signature
# data.tar.gz
-# data.tar.gz.sum
# data.tar.gz.sig # data signature
#
# === Manually signing gems
#
@@ -161,6 +161,8 @@ end
# -K, --private-key KEY Key for --sign or --build
# -s, --sign CERT Signs CERT with the key from -K
# and the certificate from -C
#
# We've already covered the <code>--build</code> option, and the
# <code>--add</code>, <code>--list</code>, and <code>--remove</code> commands
@@ -265,7 +267,7 @@ end
# 2. Grab the public key from the gemspec
#
# gem spec some_signed_gem-1.0.gem cert_chain | \
-# ruby -ryaml -e 'puts YAML.load_documents($stdin)' > public_key.crt
#
# 3. Generate a SHA1 hash of the data.tar.gz
#
@@ -39,7 +39,7 @@ class Gem::Security::Signer
}.freeze
##
- # Attemps to re-sign an expired cert with a given private key
def self.re_sign_cert(expired_cert, expired_cert_path, private_key)
return unless expired_cert.not_after < Time.now
@@ -661,7 +661,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
"only_one_executable" => true,
"full_name" => "rubygems-#{Gem::VERSION}",
"has_deps" => false,
- "homepage" => "http://guides.rubygems.org/",
"name" => 'rubygems',
"ri_installed" => true,
"summary" => "RubyGems itself",
@@ -384,6 +384,7 @@ class Gem::Specification < Gem::BasicSpecification
# "mailing_list_uri" => "https://groups.example.com/bestgemever",
# "source_code_uri" => "https://example.com/user/bestgemever",
# "wiki_uri" => "https://example.com/user/bestgemever/wiki"
# }
#
# These links will be used on your gem's page on rubygems.org and must pass
@@ -1086,6 +1087,13 @@ class Gem::Specification < Gem::BasicSpecification
_latest_specs Gem::Specification._all, prerelease
end
def self._latest_specs(specs, prerelease = false) # :nodoc:
result = Hash.new { |h,k| h[k] = {} }
native = {}
@@ -1752,10 +1760,11 @@ class Gem::Specification < Gem::BasicSpecification
#
# [depending_gem, dependency, [list_of_gems_that_satisfy_dependency]]
- def dependent_gems
out = []
Gem::Specification.each do |spec|
- spec.dependencies.each do |dep|
if self.satisfies_requirement?(dep)
sats = []
find_all_satisfiers(dep) do |sat|
@@ -1847,29 +1856,23 @@ class Gem::Specification < Gem::BasicSpecification
end
##
- # Sets executables to +value+, ensuring it is an array. Don't
- # use this, push onto the array instead.
def executables=(value)
- # TODO: warn about setting instead of pushing
@executables = Array(value)
end
##
- # Sets extensions to +extensions+, ensuring it is an array. Don't
- # use this, push onto the array instead.
def extensions=(extensions)
- # TODO: warn about setting instead of pushing
@extensions = Array extensions
end
##
- # Sets extra_rdoc_files to +files+, ensuring it is an array. Don't
- # use this, push onto the array instead.
def extra_rdoc_files=(files)
- # TODO: warn about setting instead of pushing
@extra_rdoc_files = Array files
end
@@ -2245,11 +2248,9 @@ class Gem::Specification < Gem::BasicSpecification
end
##
- # Sets rdoc_options to +value+, ensuring it is an array. Don't
- # use this, push onto the array instead.
def rdoc_options=(options)
- # TODO: warn about setting instead of pushing
@rdoc_options = Array options
end
@@ -2268,11 +2269,9 @@ class Gem::Specification < Gem::BasicSpecification
end
##
- # Set requirements to +req+, ensuring it is an array. Don't
- # use this, push onto the array instead.
def requirements=(req)
- # TODO: warn about setting instead of pushing
@requirements = Array req
end
@@ -18,6 +18,7 @@ class Gem::SpecificationPolicy
mailing_list_uri
source_code_uri
wiki_uri
].freeze # :nodoc:
def initialize(specification)
@@ -421,7 +422,7 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li
end
def help_text # :nodoc:
- "See http://guides.rubygems.org/specification-reference/ for help"
end
end
@@ -169,20 +169,24 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
# original value when the block ends
#
def bindir(value)
- bindir = RbConfig::CONFIG['bindir']
- if value
- RbConfig::CONFIG['bindir'] = value
- else
- RbConfig::CONFIG.delete 'bindir'
- end
- yield
- ensure
- if bindir
- RbConfig::CONFIG['bindir'] = bindir
- else
- RbConfig::CONFIG.delete 'bindir'
end
end
@@ -321,6 +325,11 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
@tempdir.tap(&Gem::UNTAINT)
end
@gemhome = File.join @tempdir, 'gemhome'
@userhome = File.join @tempdir, 'userhome'
ENV["GEM_SPEC_CACHE"] = File.join @tempdir, 'spec_cache'
@@ -331,7 +340,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
ruby
end
- @git = ENV['GIT'] || 'git'
Gem.ensure_gem_subdirectories @gemhome
@@ -442,6 +451,10 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
ENV.replace(@orig_env)
Gem.ruby = @orig_ruby if @orig_ruby
if Gem.java_platform?
@@ -562,7 +575,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
def install_gem(spec, options = {})
require 'rubygems/installer'
- gem = File.join @tempdir, "gems", "#{spec.full_name}.gem"
unless File.exist? gem
use_ui Gem::MockGemUi.new do
@@ -571,7 +584,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
end
end
- gem = File.join(@tempdir, File.basename(spec.cache_file)).tap(&Gem::UNTAINT)
end
Gem::Installer.at(gem, options.merge({:wrappers => true})).install
@@ -667,8 +680,6 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
yield(s) if block_given?
end
- Gem::Specification.map # HACK: force specs to (re-)load before we write
-
written_path = write_file spec.spec_file do |io|
io.write spec.to_ruby_for_cache
end
@@ -833,9 +844,6 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
util_build_gem spec
- cache_file = File.join @tempdir, 'gems', "#{spec.full_name}.gem"
- FileUtils.mkdir_p File.dirname cache_file
- FileUtils.mv spec.cache_file, cache_file
FileUtils.rm spec.spec_file
end
@@ -1247,6 +1255,16 @@ Also, a list:
end
end
class << self
# :nodoc:
@@ -7,6 +7,7 @@
require 'fileutils'
require 'rubygems'
require 'rubygems/dependency_list'
require 'rubygems/rdoc'
require 'rubygems/user_interaction'
@@ -23,6 +24,8 @@ class Gem::Uninstaller
include Gem::UserInteraction
##
# The directory a gem's executables will be installed into
@@ -158,8 +161,11 @@ class Gem::Uninstaller
end
remove_executables @spec
remove @spec
Gem.post_uninstall_hooks.each do |hook|
hook.call self
end
@@ -168,11 +174,10 @@ class Gem::Uninstaller
end
##
- # Removes installed executables and batch files (windows only) for
- # +gemspec+.
def remove_executables(spec)
- return if spec.nil? or spec.executables.empty?
executables = spec.executables.clone
@@ -231,10 +236,6 @@ class Gem::Uninstaller
##
# spec:: the spec of the gem to be uninstalled
- # list:: the list of all such gems
- #
- # Warning: this method modifies the +list+ parameter. Once it has
- # uninstalled a gem, it is removed from that list.
def remove(spec)
unless path_ok?(@gem_home, spec) or
@@ -275,6 +276,25 @@ class Gem::Uninstaller
end
##
# Is +spec+ in +gem_dir+?
def path_ok?(gem_dir, spec)
@@ -317,7 +337,7 @@ class Gem::Uninstaller
s.name == spec.name && s.full_name != spec.full_name
end
- spec.dependent_gems.each do |dep_spec, dep, satlist|
unless siblings.any? { |s| s.satisfies_requirement? dep }
msg << "#{dep_spec.name}-#{dep_spec.version} depends on #{dep}"
end
@@ -359,14 +359,6 @@ class Gem::StreamUI
end
##
- # Display a debug message on the same location as error messages.
-
- def debug(statement)
- @errs.puts statement
- end
- deprecate :debug, :none, 2018, 12
-
- ##
# Terminate the application with exit code +status+, running any exit
# handlers that might have been defined.
@@ -151,7 +151,7 @@
class Gem::Version
- autoload :Requirement, 'rubygems/requirement'
include Comparable
@@ -77,4 +77,22 @@ class TestDeprecate < Gem::TestCase
assert_match(/on or after 2099-03-01/, err)
end
end
@@ -11,12 +11,6 @@ if File.exist?(File.join(Dir.tmpdir, "Gemfile"))
raise "rubygems/bundler tests do not work correctly if there is #{ File.join(Dir.tmpdir, "Gemfile") }"
end
-# TODO: push this up to test_case.rb once battle tested
-
-$LOAD_PATH.map! do |path|
- path.dup.tap(&Gem::UNTAINT)
-end
-
class TestGem < Gem::TestCase
PLUGINS_LOADED = [] # rubocop:disable Style/MutableConstant
@@ -161,10 +155,8 @@ class TestGem < Gem::TestCase
def test_self_install_permissions_with_format_executable_and_non_standard_ruby_install_name
Gem::Installer.exec_format = nil
- with_clean_path_to_ruby do
- ruby_install_name 'ruby27' do
- assert_self_install_permissions(format_executable: true)
- end
end
ensure
Gem::Installer.exec_format = nil
@@ -1024,21 +1016,17 @@ class TestGem < Gem::TestCase
end
def test_self_ruby_escaping_spaces_in_path
- with_clean_path_to_ruby do
- with_bindir_and_exeext("C:/Ruby 1.8/bin", ".exe") do
- ruby_install_name "ruby" do
- assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby
- end
end
end
end
def test_self_ruby_path_without_spaces
- with_clean_path_to_ruby do
- with_bindir_and_exeext("C:/Ruby18/bin", ".exe") do
- ruby_install_name "ruby" do
- assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby
- end
end
end
end
@@ -1090,7 +1078,7 @@ class TestGem < Gem::TestCase
util_restore_RUBY_VERSION
end
- def test_self_ruby_version_with_prerelease
util_set_RUBY_VERSION '2.6.0', -1, 63539, 'ruby 2.6.0preview2 (2018-05-31 trunk 63539) [x86_64-linux]'
assert_equal Gem::Version.new('2.6.0.preview2'), Gem.ruby_version
@@ -1098,6 +1086,14 @@ class TestGem < Gem::TestCase
util_restore_RUBY_VERSION
end
def test_self_ruby_version_with_non_mri_implementations_with_mri_prerelase_compatibility
util_set_RUBY_VERSION '2.6.0', -1, 63539, 'weirdjruby 9.2.0.0 (2.6.0preview2) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11 [linux-x86_64]', 'weirdjruby', '9.2.0.0'
@@ -1106,7 +1102,7 @@ class TestGem < Gem::TestCase
util_restore_RUBY_VERSION
end
- def test_self_ruby_version_with_trunk
util_set_RUBY_VERSION '1.9.2', -1, 23493, 'ruby 1.9.2dev (2009-05-20 trunk 23493) [x86_64-linux]'
assert_equal Gem::Version.new('1.9.2.dev'), Gem.ruby_version
@@ -1114,6 +1110,14 @@ class TestGem < Gem::TestCase
util_restore_RUBY_VERSION
end
def test_self_rubygems_version
assert_equal Gem::Version.new(Gem::VERSION), Gem.rubygems_version
end
@@ -1470,7 +1474,6 @@ class TestGem < Gem::TestCase
install_gem foo2
end
- Gem.searcher = nil
Gem::Specification.reset
gem 'foo'
@@ -1904,15 +1907,19 @@ You may need to `gem install -g` to install missing gems
end
def ruby_install_name(name)
- orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name']
- RbConfig::CONFIG['ruby_install_name'] = name
- yield
- ensure
- if orig_RUBY_INSTALL_NAME
- RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME
- else
- RbConfig::CONFIG.delete 'ruby_install_name'
end
end
@@ -1924,16 +1931,6 @@ You may need to `gem install -g` to install missing gems
end
end
- def with_clean_path_to_ruby
- orig_ruby = Gem.ruby
-
- Gem.instance_variable_set :@ruby, nil
-
- yield
- ensure
- Gem.instance_variable_set :@ruby, orig_ruby
- end
-
def with_plugin(path)
test_plugin_path = File.expand_path("test/rubygems/plugin/#{path}",
PROJECT_DIR)
@@ -224,26 +224,34 @@ class TestGemCommandManager < Gem::TestCase
end
#check defaults
- @command_manager.process_args %w[query]
assert_equal(//, check_options[:name])
assert_equal :local, check_options[:domain]
assert_equal false, check_options[:details]
#check settings
check_options = nil
- @command_manager.process_args %w[query --name foobar --local --details]
assert_equal(/foobar/i, check_options[:name])
assert_equal :local, check_options[:domain]
assert_equal true, check_options[:details]
#remote domain
check_options = nil
- @command_manager.process_args %w[query --remote]
assert_equal :remote, check_options[:domain]
#both (local/remote) domains
check_options = nil
- @command_manager.process_args %w[query --both]
assert_equal :both, check_options[:domain]
end
@@ -268,4 +276,29 @@ class TestGemCommandManager < Gem::TestCase
assert_equal Dir.pwd, check_options[:install_dir]
end
end
@@ -147,7 +147,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase
error = @ui.error.split "\n"
assert_equal "WARNING: licenses is empty, but is recommended. Use a license identifier from", error.shift
assert_equal "http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.", error.shift
- assert_equal "WARNING: See http://guides.rubygems.org/specification-reference/ for help", error.shift
assert_equal [], error
gem_file = File.join @tempdir, File.basename(@gem.cache_file)
@@ -215,7 +215,6 @@ class TestGemCommandsPristineCommand < Gem::TestCase
io.write "# extconf.rb\nrequire 'mkmf'; create_makefile 'a'"
end
- util_build_gem a
install_gem a
@cmd.options[:args] = %w[a]
@@ -491,6 +490,42 @@ class TestGemCommandsPristineCommand < Gem::TestCase
refute File.exist? gem_lib
end
def test_execute_bindir
a = util_spec 'a' do |s|
s.name = "test_gem"
@@ -1,857 +0,0 @@
-# frozen_string_literal: true
-require 'rubygems/test_case'
-require 'rubygems/commands/query_command'
-
-module TestGemCommandsQueryCommandSetup
- def setup
- super
-
- @cmd = Gem::Commands::QueryCommand.new
-
- @specs = add_gems_to_fetcher
- @stub_ui = Gem::MockGemUi.new
- @stub_fetcher = Gem::FakeFetcher.new
-
- @stub_fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do
- raise Gem::RemoteFetcher::FetchError
- end
- end
-end
-
-class TestGemCommandsQueryCommandWithInstalledGems < Gem::TestCase
-
- include TestGemCommandsQueryCommandSetup
-
- def test_execute
- spec_fetcher do |fetcher|
- fetcher.legacy_platform
- end
-
- @cmd.handle_options %w[-r]
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** REMOTE GEMS ***
-
-a (2)
-pl (1 i386-linux)
- EOF
-
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
- end
-
- def test_execute_all
- spec_fetcher do |fetcher|
- fetcher.legacy_platform
- end
-
- @cmd.handle_options %w[-r --all]
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** REMOTE GEMS ***
-
-a (2, 1)
-pl (1 i386-linux)
- EOF
-
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
- end
-
- def test_execute_all_prerelease
- spec_fetcher do |fetcher|
- fetcher.legacy_platform
- end
-
- @cmd.handle_options %w[-r --all --prerelease]
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** REMOTE GEMS ***
-
-a (3.a, 2, 1)
-pl (1 i386-linux)
- EOF
-
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
- end
-
- def test_execute_details
- spec_fetcher do |fetcher|
- fetcher.spec 'a', 2 do |s|
- s.summary = 'This is a lot of text. ' * 4
- s.authors = ['Abraham Lincoln', 'Hirohito']
- s.homepage = 'http://a.example.com/'
- end
-
- fetcher.legacy_platform
- end
-
- @cmd.handle_options %w[-r -d]
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** REMOTE GEMS ***
-
-a (2)
- Authors: Abraham Lincoln, Hirohito
- Homepage: http://a.example.com/
-
- This is a lot of text. This is a lot of text. This is a lot of text.
- This is a lot of text.
-
-pl (1)
- Platform: i386-linux
- Author: A User
- Homepage: http://example.com
-
- this is a summary
- EOF
-
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
- end
-
- def test_execute_details_cleans_text
- spec_fetcher do |fetcher|
- fetcher.spec 'a', 2 do |s|
- s.summary = 'This is a lot of text. ' * 4
- s.authors = ["Abraham Lincoln \x01", "\x02 Hirohito"]
- s.homepage = "http://a.example.com/\x03"
- end
-
- fetcher.legacy_platform
- end
-
- @cmd.handle_options %w[-r -d]
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** REMOTE GEMS ***
-
-a (2)
- Authors: Abraham Lincoln ., . Hirohito
- Homepage: http://a.example.com/.
-
- This is a lot of text. This is a lot of text. This is a lot of text.
- This is a lot of text.
-
-pl (1)
- Platform: i386-linux
- Author: A User
- Homepage: http://example.com
-
- this is a summary
- EOF
-
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
- end
-
- def test_execute_details_truncates_summary
- spec_fetcher do |fetcher|
- fetcher.spec 'a', 2 do |s|
- s.summary = 'This is a lot of text. ' * 10_000
- s.authors = ["Abraham Lincoln \x01", "\x02 Hirohito"]
- s.homepage = "http://a.example.com/\x03"
- end
-
- fetcher.legacy_platform
- end
-
- @cmd.handle_options %w[-r -d]
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** REMOTE GEMS ***
-
-a (2)
- Authors: Abraham Lincoln ., . Hirohito
- Homepage: http://a.example.com/.
-
- Truncating the summary for a-2 to 100,000 characters:
-#{" This is a lot of text. This is a lot of text. This is a lot of text.\n" * 1449} This is a lot of te
-
-pl (1)
- Platform: i386-linux
- Author: A User
- Homepage: http://example.com
-
- this is a summary
- EOF
-
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
- end
-
- def test_execute_installed
- @cmd.handle_options %w[-n a --installed]
-
- assert_raises Gem::MockGemUi::SystemExitException do
- use_ui @stub_ui do
- @cmd.execute
- end
- end
-
- assert_equal "true\n", @stub_ui.output
- assert_equal '', @stub_ui.error
- end
-
- def test_execute_installed_inverse
- @cmd.handle_options %w[-n a --no-installed]
-
- e = assert_raises Gem::MockGemUi::TermError do
- use_ui @stub_ui do
- @cmd.execute
- end
- end
-
- assert_equal "false\n", @stub_ui.output
- assert_equal '', @stub_ui.error
-
- assert_equal 1, e.exit_code
- end
-
- def test_execute_installed_inverse_not_installed
- @cmd.handle_options %w[-n not_installed --no-installed]
-
- assert_raises Gem::MockGemUi::SystemExitException do
- use_ui @stub_ui do
- @cmd.execute
- end
- end
-
- assert_equal "true\n", @stub_ui.output
- assert_equal '', @stub_ui.error
- end
-
- def test_execute_installed_no_name
- @cmd.handle_options %w[--installed]
-
- e = assert_raises Gem::MockGemUi::TermError do
- use_ui @stub_ui do
- @cmd.execute
- end
- end
-
- assert_equal '', @stub_ui.output
- assert_equal "ERROR: You must specify a gem name\n", @stub_ui.error
-
- assert_equal 4, e.exit_code
- end
-
- def test_execute_installed_not_installed
- @cmd.handle_options %w[-n not_installed --installed]
-
- e = assert_raises Gem::MockGemUi::TermError do
- use_ui @stub_ui do
- @cmd.execute
- end
- end
-
- assert_equal "false\n", @stub_ui.output
- assert_equal '', @stub_ui.error
-
- assert_equal 1, e.exit_code
- end
-
- def test_execute_installed_version
- @cmd.handle_options %w[-n a --installed --version 2]
-
- assert_raises Gem::MockGemUi::SystemExitException do
- use_ui @stub_ui do
- @cmd.execute
- end
- end
-
- assert_equal "true\n", @stub_ui.output
- assert_equal '', @stub_ui.error
- end
-
- def test_execute_installed_version_not_installed
- @cmd.handle_options %w[-n c --installed --version 2]
-
- e = assert_raises Gem::MockGemUi::TermError do
- use_ui @stub_ui do
- @cmd.execute
- end
- end
-
- assert_equal "false\n", @stub_ui.output
- assert_equal '', @stub_ui.error
-
- assert_equal 1, e.exit_code
- end
-
- def test_execute_local
- spec_fetcher do |fetcher|
- fetcher.legacy_platform
- end
-
- @cmd.options[:domain] = :local
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** LOCAL GEMS ***
-
-a (3.a, 2, 1)
-pl (1 i386-linux)
- EOF
-
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
- end
-
- def test_execute_local_notty
- spec_fetcher do |fetcher|
- fetcher.legacy_platform
- end
-
- @cmd.handle_options %w[]
-
- @stub_ui.outs.tty = false
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-a (3.a, 2, 1)
-pl (1 i386-linux)
- EOF
-
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
- end
-
- def test_execute_local_quiet
- spec_fetcher do |fetcher|
- fetcher.legacy_platform
- end
-
- @cmd.options[:domain] = :local
- Gem.configuration.verbose = false
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-a (3.a, 2, 1)
-pl (1 i386-linux)
- EOF
-
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
- end
-
- def test_execute_no_versions
- spec_fetcher do |fetcher|
- fetcher.legacy_platform
- end
-
- @cmd.handle_options %w[-r --no-versions]
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** REMOTE GEMS ***
-
-a
-pl
- EOF
-
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
- end
-
- def test_execute_notty
- spec_fetcher do |fetcher|
- fetcher.legacy_platform
- end
-
- @cmd.handle_options %w[-r]
-
- @stub_ui.outs.tty = false
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-a (2)
-pl (1 i386-linux)
- EOF
-
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
- end
-
- def test_execute_prerelease
- @cmd.handle_options %w[-r --prerelease]
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** REMOTE GEMS ***
-
-a (3.a)
- EOF
-
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
- end
-
- def test_execute_prerelease_local
- spec_fetcher do |fetcher|
- fetcher.legacy_platform
- end
-
- @cmd.handle_options %w[-l --prerelease]
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** LOCAL GEMS ***
-
-a (3.a, 2, 1)
-pl (1 i386-linux)
- EOF
-
- assert_equal expected, @stub_ui.output
- end
-
- def test_execute_no_prerelease_local
- spec_fetcher do |fetcher|
- fetcher.legacy_platform
- end
-
- @cmd.handle_options %w[-l --no-prerelease]
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** LOCAL GEMS ***
-
-a (2, 1)
-pl (1 i386-linux)
- EOF
-
- assert_equal expected, @stub_ui.output
- end
-
- def test_execute_remote
- spec_fetcher do |fetcher|
- fetcher.legacy_platform
- end
-
- @cmd.options[:domain] = :remote
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** REMOTE GEMS ***
-
-a (2)
-pl (1 i386-linux)
- EOF
-
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
- end
-
- def test_execute_remote_notty
- spec_fetcher do |fetcher|
- fetcher.legacy_platform
- end
-
- @cmd.handle_options %w[]
-
- @stub_ui.outs.tty = false
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-a (3.a, 2, 1)
-pl (1 i386-linux)
- EOF
-
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
- end
-
- def test_execute_remote_quiet
- spec_fetcher do |fetcher|
- fetcher.legacy_platform
- end
-
- @cmd.options[:domain] = :remote
- Gem.configuration.verbose = false
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-a (2)
-pl (1 i386-linux)
- EOF
-
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
- end
-
- def test_make_entry
- a_2_name = @specs['a-2'].original_name
-
- @stub_fetcher.data.delete \
- "#{@gem_repo}quick/Marshal.#{Gem.marshal_version}/#{a_2_name}.gemspec.rz"
-
- a2 = @specs['a-2']
- entry_tuples = [
- [Gem::NameTuple.new(a2.name, a2.version, a2.platform),
- Gem.sources.first],
- ]
-
- platforms = { a2.version => [a2.platform] }
-
- entry = @cmd.send :make_entry, entry_tuples, platforms
-
- assert_equal 'a (2)', entry
- end
-
- # Test for multiple args handling!
- def test_execute_multiple_args
- spec_fetcher do |fetcher|
- fetcher.legacy_platform
- end
-
- @cmd.handle_options %w[a pl]
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- assert_match %r%^a %, @stub_ui.output
- assert_match %r%^pl %, @stub_ui.output
- assert_equal '', @stub_ui.error
- end
-
- def test_show_gems
- @cmd.options[:name] = //
- @cmd.options[:domain] = :remote
-
- use_ui @stub_ui do
- @cmd.send :show_gems, /a/i
- end
-
- assert_match %r%^a %, @stub_ui.output
- refute_match %r%^pl %, @stub_ui.output
- assert_empty @stub_ui.error
- end
-
- private
-
- def add_gems_to_fetcher
- spec_fetcher do |fetcher|
- fetcher.spec 'a', 1
- fetcher.spec 'a', 2
- fetcher.spec 'a', '3.a'
- end
- end
-
-end
-
-class TestGemCommandsQueryCommandWithoutInstalledGems < Gem::TestCase
-
- include TestGemCommandsQueryCommandSetup
-
- def test_execute_platform
- spec_fetcher do |fetcher|
- fetcher.spec 'a', 1
- fetcher.spec 'a', 1 do |s|
- s.platform = 'x86-linux'
- end
-
- fetcher.spec 'a', 2 do |s|
- s.platform = 'universal-darwin'
- end
- end
-
- @cmd.handle_options %w[-r -a]
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** REMOTE GEMS ***
-
-a (2 universal-darwin, 1 ruby x86-linux)
- EOF
-
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
- end
-
- def test_execute_show_default_gems
- spec_fetcher { |fetcher| fetcher.spec 'a', 2 }
-
- a1 = new_default_spec 'a', 1
- install_default_specs a1
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** LOCAL GEMS ***
-
-a (2, default: 1)
-EOF
-
- assert_equal expected, @stub_ui.output
- end
-
- def test_execute_show_default_gems_with_platform
- a1 = new_default_spec 'a', 1
- a1.platform = 'java'
- install_default_specs a1
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** LOCAL GEMS ***
-
-a (default: 1 java)
-EOF
-
- assert_equal expected, @stub_ui.output
- end
-
- def test_execute_default_details
- spec_fetcher do |fetcher|
- fetcher.spec 'a', 2
- end
-
- a1 = new_default_spec 'a', 1
- install_default_specs a1
-
- @cmd.handle_options %w[-l -d]
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** LOCAL GEMS ***
-
-a (2, 1)
- Author: A User
- Homepage: http://example.com
- Installed at (2): #{@gemhome}
- (1, default): #{a1.base_dir}
-
- this is a summary
- EOF
-
- assert_equal expected, @stub_ui.output
- end
-
- def test_execute_local_details
- spec_fetcher do |fetcher|
- fetcher.spec 'a', 1 do |s|
- s.platform = 'x86-linux'
- end
-
- fetcher.spec 'a', 2 do |s|
- s.summary = 'This is a lot of text. ' * 4
- s.authors = ['Abraham Lincoln', 'Hirohito']
- s.homepage = 'http://a.example.com/'
- s.platform = 'universal-darwin'
- end
-
- fetcher.legacy_platform
- end
-
- @cmd.handle_options %w[-l -d]
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- str = @stub_ui.output
-
- str.gsub!(/\(\d\): [^\n]*/, "-")
- str.gsub!(/at: [^\n]*/, "at: -")
-
- expected = <<-EOF
-
-*** LOCAL GEMS ***
-
-a (2, 1)
- Platforms:
- 1: x86-linux
- 2: universal-darwin
- Authors: Abraham Lincoln, Hirohito
- Homepage: http://a.example.com/
- Installed at -
- -
-
- This is a lot of text. This is a lot of text. This is a lot of text.
- This is a lot of text.
-
-pl (1)
- Platform: i386-linux
- Author: A User
- Homepage: http://example.com
- Installed at: -
-
- this is a summary
- EOF
-
- assert_equal expected, @stub_ui.output
- end
-
- def test_execute_exact_remote
- spec_fetcher do |fetcher|
- fetcher.spec 'coolgem-omg', 3
- fetcher.spec 'coolgem', '4.2.1'
- fetcher.spec 'wow_coolgem', 1
- end
-
- @cmd.handle_options %w[--remote --exact coolgem]
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** REMOTE GEMS ***
-
-coolgem (4.2.1)
- EOF
-
- assert_equal expected, @stub_ui.output
- end
-
- def test_execute_exact_local
- spec_fetcher do |fetcher|
- fetcher.spec 'coolgem-omg', 3
- fetcher.spec 'coolgem', '4.2.1'
- fetcher.spec 'wow_coolgem', 1
- end
-
- @cmd.handle_options %w[--exact coolgem]
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** LOCAL GEMS ***
-
-coolgem (4.2.1)
- EOF
-
- assert_equal expected, @stub_ui.output
- end
-
- def test_execute_exact_multiple
- spec_fetcher do |fetcher|
- fetcher.spec 'coolgem-omg', 3
- fetcher.spec 'coolgem', '4.2.1'
- fetcher.spec 'wow_coolgem', 1
-
- fetcher.spec 'othergem-omg', 3
- fetcher.spec 'othergem', '1.2.3'
- fetcher.spec 'wow_othergem', 1
- end
-
- @cmd.handle_options %w[--exact coolgem othergem]
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** LOCAL GEMS ***
-
-coolgem (4.2.1)
-
-*** LOCAL GEMS ***
-
-othergem (1.2.3)
- EOF
-
- assert_equal expected, @stub_ui.output
- end
-
- private
-
- def add_gems_to_fetcher
- spec_fetcher do |fetcher|
- fetcher.download 'a', 1
- fetcher.download 'a', 2
- fetcher.download 'a', '3.a'
- end
- end
-
-end
@@ -98,6 +98,18 @@ class TestGemCommandsSetupCommand < Gem::TestCase
File.join @gemhome, 'bin', name
end
def test_execute_regenerate_binstubs
gem_bin_path = gem_install 'a'
write_file gem_bin_path do |io|
@@ -123,6 +135,31 @@ class TestGemCommandsSetupCommand < Gem::TestCase
assert_equal "I changed it!\n", File.read(gem_bin_path)
end
def test_execute_informs_about_installed_executables
use_ui @ui do
@cmd.execute
@@ -247,7 +247,7 @@ source http://gems.example.com/ already present in the cache
end
def test_execute_add_http_rubygems_org
- http_rubygems_org = 'http://rubygems.org'
spec_fetcher do |fetcher|
fetcher.spec 'a', 1
@@ -284,6 +284,44 @@ source http://gems.example.com/ already present in the cache
assert_empty @ui.error
end
def test_execute_add_bad_uri
@cmd.handle_options %w[--add beta-gems.example.com]
@@ -159,6 +159,44 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
assert_empty out
end
def test_execute_system_specifically_to_latest_version
spec_fetcher do |fetcher|
fetcher.download 'rubygems-update', 8 do |s|
@@ -359,10 +397,10 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
end
def test_execute_user_install
- spec_fetcher do |fetcher|
- fetcher.download 'a', 2
- fetcher.spec 'a', 1
- end
@cmd.handle_options %w[--user-install]
@@ -373,7 +411,13 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
installer = @cmd.installer
user_install = installer.instance_variable_get :@user_install
- assert user_install, 'user_install must be set on the installer'
end
def test_fetch_remote_gems
@@ -11,10 +11,6 @@ class TestGemConfigFile < Gem::TestCase
@cfg_args = %W[--config-file #{@temp_conf}]
- @orig_SYSTEM_WIDE_CONFIG_FILE = Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE
- Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE
- Gem::ConfigFile.send :const_set, :SYSTEM_WIDE_CONFIG_FILE,
- File.join(@tempdir, 'system-gemrc')
Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS.clear
Gem::ConfigFile::PLATFORM_DEFAULTS.clear
@@ -27,9 +23,6 @@ class TestGemConfigFile < Gem::TestCase
def teardown
Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS.clear
Gem::ConfigFile::PLATFORM_DEFAULTS.clear
- Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE
- Gem::ConfigFile.send :const_set, :SYSTEM_WIDE_CONFIG_FILE,
- @orig_SYSTEM_WIDE_CONFIG_FILE
ENV['GEMRC'] = @env_gemrc
@@ -440,7 +440,7 @@ class TestGemDependencyInstaller < Gem::TestCase
e1 = util_spec 'e', '1', nil, 'extconf.rb' do |s|
s.extensions << 'extconf.rb'
end
- e1_gem = File.join @tempdir, 'gems', "#{e1.full_name}.gem"
_, f1_gem = util_gem 'f', '1', 'e' => nil
@@ -153,6 +153,34 @@ This directory does not appear to be a RubyGems repository, skipping
assert true # count
end
def test_gem_repository_eh
doctor = Gem::Doctor.new @gemhome
@@ -67,4 +67,34 @@ class TestGemGemRunner < Gem::TestCase
assert_equal %w[--foo], args
end
end
@@ -744,6 +744,70 @@ gem 'other', version
assert_match(/#{default_shebang}/, shebang_line)
end
def test_initialize
spec = util_spec 'a' do |s|
s.platform = Gem::Platform.new 'mswin32'
@@ -940,7 +1004,13 @@ gem 'other', version
end
def test_install_creates_binstub_that_prefers_user_installed_gem_to_default
- install_default_gems new_default_spec('default', '2')
installer = util_setup_installer do |spec|
spec.name = 'default'
@@ -958,8 +1028,6 @@ gem 'other', version
end
end
- exe = File.join @gemhome, 'bin', 'executable'
-
e = assert_raises RuntimeError do
instance_eval File.read(exe)
end
@@ -153,20 +153,18 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
assert_equal proxy_uri, fetcher.instance_variable_get(:@proxy).to_s
end
- def test_fetch_size_bad_uri
fetcher = Gem::RemoteFetcher.new nil
@fetcher = fetcher
e = assert_raises ArgumentError do
- Gem::Deprecate.skip_during do
- fetcher.fetch_size 'gems.example.com/yaml'
- end
end
assert_equal 'uri scheme is invalid: nil', e.message
end
- def test_fetch_size_socket_error
fetcher = Gem::RemoteFetcher.new nil
@fetcher = fetcher
def fetcher.request(uri, request_class, last_modified = nil)
@@ -175,9 +173,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
uri = 'http://gems.example.com/yaml'
e = assert_raises Gem::RemoteFetcher::FetchError do
- Gem::Deprecate.skip_during do
- fetcher.fetch_size uri
- end
end
assert_equal "SocketError: oops (#{uri})", e.message
@@ -186,9 +182,8 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_no_proxy
use_ui @stub_ui do
assert_data_from_server @fetcher.fetch_path(@server_uri)
- Gem::Deprecate.skip_during do
- assert_equal SERVER_DATA.size, @fetcher.fetch_size(@server_uri)
- end
end
end
@@ -917,7 +912,6 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
end
def test_ssl_client_cert_auth_connection
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
skip 'openssl in jruby fails' if java_platform?
ssl_server = self.class.start_ssl_server({
@@ -935,8 +929,6 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
end
def test_do_not_allow_invalid_client_cert_auth_connection
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
-
ssl_server = self.class.start_ssl_server({
:SSLVerifyClient =>
OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT})
@@ -1083,9 +1075,6 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
DIR = File.expand_path(File.dirname(__FILE__))
def start_ssl_server(config = {})
- raise MiniTest::Skip, 'openssl not installed' unless
- defined?(OpenSSL::SSL)
-
null_logger = NilLog.new
server = WEBrick::HTTPServer.new({
:Port => 0,
@@ -1109,8 +1098,8 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
begin
server.start
rescue Exception => ex
- abort ex.message
puts "ERROR during server thread: #{ex.message}"
ensure
server.shutdown
end
@@ -183,6 +183,58 @@ DEPENDENCIES
assert_path_exists File.join @gemhome, 'specifications', 'b-1.gemspec'
end
def test_install_from_gemdeps_version_mismatch
spec_fetcher do |fetcher|
fetcher.gem 'a', 2
@@ -2784,7 +2784,7 @@ end
add_runtime_dependency 'l', '~> 1.2', '> 1.2.3'
#{w}: open-ended dependency on o (>= 0) is not recommended
use a bounded requirement, such as '~> x.y'
-#{w}: See http://guides.rubygems.org/specification-reference/ for help
EXPECTED
assert_equal expected, @ui.error, 'warning'
@@ -2816,7 +2816,7 @@ duplicate dependency on c (>= 1.2.3, development), (~> 1.2) use:
end
assert_equal <<-EXPECTED, @ui.error
-#{w}: See http://guides.rubygems.org/specification-reference/ for help
EXPECTED
end
end
@@ -2927,7 +2927,7 @@ duplicate dependency on c (>= 1.2.3, development), (~> 1.2) use:
end
end
- assert_match 'See http://guides.rubygems.org/specification-reference/ for help', @ui.error
end
def test_validate_executables
@@ -3100,7 +3100,7 @@ Please report a bug if this causes problems.
assert_equal '"ftp://rubygems.org" is not a valid HTTP URI', e.message
- @a1.homepage = 'http://rubygems.org'
assert_equal true, @a1.validate
@a1.homepage = 'https://rubygems.org'
@@ -3430,7 +3430,7 @@ Did you mean 'Ruby'?
@a1.validate
end
- assert_match 'See http://guides.rubygems.org/specification-reference/ for help', @ui.error
end
def test_version
@@ -3532,7 +3532,8 @@ Did you mean 'Ruby'?
s.metadata = {
"one" => "two",
"home" => "three",
- "homepage_uri" => "https://example.com/user/repo"
}
end
@@ -169,6 +169,41 @@ class TestGemUninstaller < Gem::InstallerTestCase
end
end
def test_path_ok_eh
uninstaller = Gem::Uninstaller.new nil
@@ -524,6 +559,35 @@ create_makefile '#{@spec.name}'
assert_match %r!Successfully uninstalled q-1!, lines.last
end
def test_uninstall_no_permission
uninstaller = Gem::Uninstaller.new @spec.name, :executables => true
@@ -542,4 +606,44 @@ create_makefile '#{@spec.name}'
end
end
end
@@ -236,7 +236,7 @@ class TestGemVersion < Gem::TestCase
assert_equal expected, v(version).approximate_recommendation
end
- # Assert that the "approximate" recommendation for +version+ satifies +version+.
def assert_approximate_satisfies_itself(version)
gem_version = v(version)