mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to RubyGems 1.3.1 r1909.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
17358af75b
commit
b61d8b6045
75 changed files with 424 additions and 404 deletions
ChangeLoggem_prelude.rb
lib
rubygems.rb
rubygems
test/rubygems
functional.rbgem_installer_test_case.rbgemutilities.rbtest_config.rbtest_gem.rbtest_gem_builder.rbtest_gem_command.rbtest_gem_command_manager.rbtest_gem_commands_build_command.rbtest_gem_commands_cert_command.rbtest_gem_commands_check_command.rbtest_gem_commands_contents_command.rbtest_gem_commands_dependency_command.rbtest_gem_commands_environment_command.rbtest_gem_commands_fetch_command.rbtest_gem_commands_generate_index_command.rbtest_gem_commands_install_command.rbtest_gem_commands_list_command.rbtest_gem_commands_lock_command.rbtest_gem_commands_mirror_command.rbtest_gem_commands_outdated_command.rbtest_gem_commands_pristine_command.rbtest_gem_commands_query_command.rbtest_gem_commands_server_command.rbtest_gem_commands_sources_command.rbtest_gem_commands_specification_command.rbtest_gem_commands_stale_command.rbtest_gem_commands_uninstall_command.rbtest_gem_commands_unpack_command.rbtest_gem_commands_update_command.rbtest_gem_config_file.rbtest_gem_dependency.rbtest_gem_dependency_installer.rbtest_gem_dependency_list.rbtest_gem_digest.rbtest_gem_doc_manager.rbtest_gem_ext_configure_builder.rbtest_gem_ext_ext_conf_builder.rbtest_gem_ext_rake_builder.rbtest_gem_format.rbtest_gem_gem_path_searcher.rbtest_gem_gem_runner.rbtest_gem_indexer.rbtest_gem_install_update_options.rbtest_gem_installer.rbtest_gem_local_remote_options.rbtest_gem_package_tar_reader_entry.rbtest_gem_package_tar_writer.rbtest_gem_platform.rbtest_gem_remote_fetcher.rbtest_gem_requirement.rbtest_gem_server.rbtest_gem_source_index.rbtest_gem_source_info_cache.rbtest_gem_source_info_cache_entry.rbtest_gem_spec_fetcher.rbtest_gem_specification.rbtest_gem_stream_ui.rbtest_gem_validator.rbtest_gem_version.rbtest_gem_version_option.rbtest_kernel.rb
|
@ -1,4 +1,8 @@
|
||||||
Sun Oct 26 07:35:56 2008 Ryan Davis <ryan@wrath.local>
|
Sun Oct 26 07:57:35 2008 Eric Hodel <drbrain@segment7.net>
|
||||||
|
|
||||||
|
* lib/rubygems*: Update to RubyGems 1.3.1 r1909.
|
||||||
|
|
||||||
|
Sun Oct 26 07:35:56 2008 Ryan Davis <ryand-ruby@zenspider.com>
|
||||||
|
|
||||||
* lib/minitest/unit.rb: Imported minitest 1.3.0 r4429.
|
* lib/minitest/unit.rb: Imported minitest 1.3.0 r4429.
|
||||||
* test/minitest/*: ditto.
|
* test/minitest/*: ditto.
|
||||||
|
|
|
@ -24,14 +24,6 @@ if defined?(Gem) then
|
||||||
:ruby_install_name => RbConfig::CONFIG["ruby_install_name"]
|
:ruby_install_name => RbConfig::CONFIG["ruby_install_name"]
|
||||||
}
|
}
|
||||||
|
|
||||||
def self.default_dir
|
|
||||||
if defined? RUBY_FRAMEWORK_VERSION
|
|
||||||
return File.join(File.dirname(ConfigMap[:sitedir]), "Gems")
|
|
||||||
else
|
|
||||||
File.join(ConfigMap[:libdir], 'ruby', 'gems', ConfigMap[:ruby_version])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.dir
|
def self.dir
|
||||||
@gem_home ||= nil
|
@gem_home ||= nil
|
||||||
set_home(ENV['GEM_HOME'] || default_dir) unless @gem_home
|
set_home(ENV['GEM_HOME'] || default_dir) unless @gem_home
|
||||||
|
@ -48,7 +40,22 @@ if defined?(Gem) then
|
||||||
@gem_path
|
@gem_path
|
||||||
end
|
end
|
||||||
|
|
||||||
# Set the Gem home directory (as reported by +dir+).
|
def self.post_install(&hook)
|
||||||
|
@post_install_hooks << hook
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.post_uninstall(&hook)
|
||||||
|
@post_uninstall_hooks << hook
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.pre_install(&hook)
|
||||||
|
@pre_install_hooks << hook
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.pre_uninstall(&hook)
|
||||||
|
@pre_uninstall_hooks << hook
|
||||||
|
end
|
||||||
|
|
||||||
def self.set_home(home)
|
def self.set_home(home)
|
||||||
@gem_home = home
|
@gem_home = home
|
||||||
ensure_gem_subdirectories(@gem_home)
|
ensure_gem_subdirectories(@gem_home)
|
||||||
|
@ -68,8 +75,25 @@ if defined?(Gem) then
|
||||||
def self.ensure_gem_subdirectories(path)
|
def self.ensure_gem_subdirectories(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Methods before this line will be removed when QuickLoader is replaced
|
||||||
|
# with the real RubyGems
|
||||||
|
|
||||||
GEM_PRELUDE_METHODS = Gem.methods(false)
|
GEM_PRELUDE_METHODS = Gem.methods(false)
|
||||||
|
|
||||||
|
require 'rubygems/defaults'
|
||||||
|
|
||||||
|
begin
|
||||||
|
require 'rubygems/defaults/operating_system'
|
||||||
|
rescue LoadError
|
||||||
|
end
|
||||||
|
|
||||||
|
if defined?(RUBY_ENGINE) then
|
||||||
|
begin
|
||||||
|
require 'rubygems/defaults/#{RUBY_ENGINE}'
|
||||||
|
rescue LoadError
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
module QuickLoader
|
module QuickLoader
|
||||||
|
|
||||||
def self.load_full_rubygems_library
|
def self.load_full_rubygems_library
|
||||||
|
|
|
@ -43,12 +43,14 @@ module Kernel
|
||||||
#
|
#
|
||||||
# GEM_SKIP=libA:libB ruby -I../libA -I../libB ./mycode.rb
|
# GEM_SKIP=libA:libB ruby -I../libA -I../libB ./mycode.rb
|
||||||
|
|
||||||
def gem(gem_name, *version_requirements)
|
def gem(gem_name, *version_requirements) # :doc:
|
||||||
skip_list = (ENV['GEM_SKIP'] || "").split(/:/)
|
skip_list = (ENV['GEM_SKIP'] || "").split(/:/)
|
||||||
raise Gem::LoadError, "skipping #{gem_name}" if skip_list.include? gem_name
|
raise Gem::LoadError, "skipping #{gem_name}" if skip_list.include? gem_name
|
||||||
Gem.activate(gem_name, *version_requirements)
|
Gem.activate(gem_name, *version_requirements)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private :gem
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -104,10 +106,10 @@ module Gem
|
||||||
@ruby = nil
|
@ruby = nil
|
||||||
@sources = []
|
@sources = []
|
||||||
|
|
||||||
@post_install_hooks = []
|
@post_install_hooks ||= []
|
||||||
@post_uninstall_hooks = []
|
@post_uninstall_hooks ||= []
|
||||||
@pre_uninstall_hooks = []
|
@pre_uninstall_hooks ||= []
|
||||||
@pre_install_hooks = []
|
@pre_install_hooks ||= []
|
||||||
|
|
||||||
##
|
##
|
||||||
# Activates an installed gem matching +gem+. The gem must satisfy
|
# Activates an installed gem matching +gem+. The gem must satisfy
|
||||||
|
@ -294,6 +296,7 @@ module Gem
|
||||||
# A Zlib::Deflate.deflate wrapper
|
# A Zlib::Deflate.deflate wrapper
|
||||||
|
|
||||||
def self.deflate(data)
|
def self.deflate(data)
|
||||||
|
require 'zlib'
|
||||||
Zlib::Deflate.deflate data
|
Zlib::Deflate.deflate data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -302,7 +305,7 @@ module Gem
|
||||||
|
|
||||||
def self.dir
|
def self.dir
|
||||||
@gem_home ||= nil
|
@gem_home ||= nil
|
||||||
set_home(ENV['GEM_HOME'] || default_dir) unless @gem_home
|
set_home(ENV['GEM_HOME'] || Gem.configuration.home || default_dir) unless @gem_home
|
||||||
@gem_home
|
@gem_home
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -395,6 +398,8 @@ module Gem
|
||||||
# Zlib::GzipReader wrapper that unzips +data+.
|
# Zlib::GzipReader wrapper that unzips +data+.
|
||||||
|
|
||||||
def self.gunzip(data)
|
def self.gunzip(data)
|
||||||
|
require 'stringio'
|
||||||
|
require 'zlib'
|
||||||
data = StringIO.new data
|
data = StringIO.new data
|
||||||
|
|
||||||
Zlib::GzipReader.new(data).read
|
Zlib::GzipReader.new(data).read
|
||||||
|
@ -404,6 +409,8 @@ module Gem
|
||||||
# Zlib::GzipWriter wrapper that zips +data+.
|
# Zlib::GzipWriter wrapper that zips +data+.
|
||||||
|
|
||||||
def self.gzip(data)
|
def self.gzip(data)
|
||||||
|
require 'stringio'
|
||||||
|
require 'zlib'
|
||||||
zipped = StringIO.new
|
zipped = StringIO.new
|
||||||
|
|
||||||
Zlib::GzipWriter.wrap zipped do |io| io.write data end
|
Zlib::GzipWriter.wrap zipped do |io| io.write data end
|
||||||
|
@ -415,6 +422,7 @@ module Gem
|
||||||
# A Zlib::Inflate#inflate wrapper
|
# A Zlib::Inflate#inflate wrapper
|
||||||
|
|
||||||
def self.inflate(data)
|
def self.inflate(data)
|
||||||
|
require 'zlib'
|
||||||
Zlib::Inflate.inflate data
|
Zlib::Inflate.inflate data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -479,13 +487,13 @@ module Gem
|
||||||
# The file name and line number of the caller of the caller of this method.
|
# The file name and line number of the caller of the caller of this method.
|
||||||
|
|
||||||
def self.location_of_caller
|
def self.location_of_caller
|
||||||
file, lineno = caller[1].split(':')
|
caller[1] =~ /(.*?):(\d+)$/i
|
||||||
lineno = lineno.to_i
|
file = $1
|
||||||
|
lineno = $2.to_i
|
||||||
|
|
||||||
[file, lineno]
|
[file, lineno]
|
||||||
end
|
end
|
||||||
|
|
||||||
private_class_method :location_of_caller
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# manage_gems is useless and deprecated. Don't call it anymore.
|
# manage_gems is useless and deprecated. Don't call it anymore.
|
||||||
|
|
||||||
|
@ -709,9 +717,11 @@ module Gem
|
||||||
|
|
||||||
@gem_path.uniq!
|
@gem_path.uniq!
|
||||||
@gem_path.each do |path|
|
@gem_path.each do |path|
|
||||||
if 0 == File.expand_path(path).index(Gem.user_home) and
|
if 0 == File.expand_path(path).index(Gem.user_home)
|
||||||
Etc.getpwuid.uid != File::Stat.new(Gem.user_home).uid then
|
unless win_platform? then
|
||||||
next # only create by matching user
|
# only create by matching user
|
||||||
|
next if Etc.getpwuid.uid != File::Stat.new(Gem.user_home).uid
|
||||||
|
end
|
||||||
end
|
end
|
||||||
ensure_gem_subdirectories path
|
ensure_gem_subdirectories path
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,7 +31,8 @@ class Gem::Commands::CheckCommand < Gem::Command
|
||||||
def execute
|
def execute
|
||||||
if options[:test]
|
if options[:test]
|
||||||
version = options[:version] || Gem::Requirement.default
|
version = options[:version] || Gem::Requirement.default
|
||||||
gem_spec = Gem::SourceIndex.from_installed_gems.search(get_one_gem_name, version).first
|
dep = Gem::Dependency.new get_one_gem_name, version
|
||||||
|
gem_spec = Gem::SourceIndex.from_installed_gems.search(dep).first
|
||||||
Gem::Validator.new.unit_test(gem_spec)
|
Gem::Validator.new.unit_test(gem_spec)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
||||||
basename = File.basename(path).sub(/\.gem$/, '')
|
basename = File.basename(path).sub(/\.gem$/, '')
|
||||||
target_dir = File.expand_path File.join(options[:target], basename)
|
target_dir = File.expand_path File.join(options[:target], basename)
|
||||||
FileUtils.mkdir_p target_dir
|
FileUtils.mkdir_p target_dir
|
||||||
Gem::Installer.new(path).unpack target_dir
|
Gem::Installer.new(path, :unpack => true).unpack target_dir
|
||||||
say "Unpacked gem: '#{target_dir}'"
|
say "Unpacked gem: '#{target_dir}'"
|
||||||
else
|
else
|
||||||
alert_error "Gem '#{gemname}' not installed."
|
alert_error "Gem '#{gemname}' not installed."
|
||||||
|
|
|
@ -54,11 +54,10 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
||||||
fail "No gem names are allowed with the --system option"
|
fail "No gem names are allowed with the --system option"
|
||||||
end
|
end
|
||||||
|
|
||||||
spec = Gem::Specification.new
|
rubygems_update = Gem::Specification.new
|
||||||
spec.name = 'rubygems-update'
|
rubygems_update.name = 'rubygems-update'
|
||||||
spec.version = Gem::Version.new Gem::RubyGemsVersion
|
rubygems_update.version = Gem::Version.new Gem::RubyGemsVersion
|
||||||
spec.version = Gem::Version.new '1.1.1'
|
hig['rubygems-update'] = rubygems_update
|
||||||
hig['rubygems-update'] = spec
|
|
||||||
|
|
||||||
options[:user_install] = false
|
options[:user_install] = false
|
||||||
else
|
else
|
||||||
|
|
|
@ -52,6 +52,8 @@ class Gem::ConfigFile
|
||||||
# Where to look for gems
|
# Where to look for gems
|
||||||
attr_accessor :path
|
attr_accessor :path
|
||||||
|
|
||||||
|
attr_accessor :home
|
||||||
|
|
||||||
# True if we print backtraces on errors.
|
# True if we print backtraces on errors.
|
||||||
attr_writer :backtrace
|
attr_writer :backtrace
|
||||||
|
|
||||||
|
@ -129,7 +131,8 @@ class Gem::ConfigFile
|
||||||
Gem.sources = @hash[:sources] if @hash.key? :sources
|
Gem.sources = @hash[:sources] if @hash.key? :sources
|
||||||
@verbose = @hash[:verbose] if @hash.key? :verbose
|
@verbose = @hash[:verbose] if @hash.key? :verbose
|
||||||
@update_sources = @hash[:update_sources] if @hash.key? :update_sources
|
@update_sources = @hash[:update_sources] if @hash.key? :update_sources
|
||||||
@path = @hash[:gempath]
|
@path = @hash[:gempath] if @hash.key? :gempath
|
||||||
|
@home = @hash[:gemhome] if @hash.key? :gemhome
|
||||||
|
|
||||||
handle_arguments arg_list
|
handle_arguments arg_list
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,11 +7,15 @@
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
|
|
||||||
module Kernel
|
module Kernel
|
||||||
alias gem_original_require require # :nodoc:
|
|
||||||
|
|
||||||
#
|
##
|
||||||
# We replace Ruby's require with our own, which is capable of
|
# The Kernel#require from before RubyGems was loaded.
|
||||||
# loading gems on demand.
|
|
||||||
|
alias gem_original_require require
|
||||||
|
|
||||||
|
##
|
||||||
|
# When RubyGems is required, Kernel#require is replaced with our own which
|
||||||
|
# is capable of loading gems on demand.
|
||||||
#
|
#
|
||||||
# When you call <tt>require 'x'</tt>, this is what happens:
|
# When you call <tt>require 'x'</tt>, this is what happens:
|
||||||
# * If the file can be loaded from the existing Ruby loadpath, it
|
# * If the file can be loaded from the existing Ruby loadpath, it
|
||||||
|
@ -22,8 +26,8 @@ module Kernel
|
||||||
#
|
#
|
||||||
# The normal <tt>require</tt> functionality of returning false if
|
# The normal <tt>require</tt> functionality of returning false if
|
||||||
# that file has already been loaded is preserved.
|
# that file has already been loaded is preserved.
|
||||||
#
|
|
||||||
def require(path) # :nodoc:
|
def require(path) # :doc:
|
||||||
gem_original_require path
|
gem_original_require path
|
||||||
rescue LoadError => load_error
|
rescue LoadError => load_error
|
||||||
if load_error.message =~ /#{Regexp.escape path}\z/ and
|
if load_error.message =~ /#{Regexp.escape path}\z/ and
|
||||||
|
@ -34,5 +38,9 @@ module Kernel
|
||||||
raise load_error
|
raise load_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # module Kernel
|
|
||||||
|
private :require
|
||||||
|
private :gem_original_require
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
module Gem
|
module Gem
|
||||||
|
|
||||||
|
@post_install_hooks ||= []
|
||||||
|
@post_uninstall_hooks ||= []
|
||||||
|
@pre_uninstall_hooks ||= []
|
||||||
|
@pre_install_hooks ||= []
|
||||||
|
|
||||||
##
|
##
|
||||||
# An Array of the default sources that come with RubyGems
|
# An Array of the default sources that come with RubyGems
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ class Gem::Installer
|
||||||
options[:user_install] = true
|
options[:user_install] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if options[:user_install] then
|
if options[:user_install] and not options[:unpack] then
|
||||||
@gem_home = Gem.user_dir
|
@gem_home = Gem.user_dir
|
||||||
|
|
||||||
user_bin_dir = File.join(@gem_home, 'bin')
|
user_bin_dir = File.join(@gem_home, 'bin')
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
# This file is auto-generated by build scripts.
|
# This file is auto-generated by build scripts.
|
||||||
# See: rake update_version
|
# See: rake update_version
|
||||||
module Gem
|
module Gem
|
||||||
RubyGemsVersion = '1.3.0'
|
RubyGemsVersion = '1.3.1'
|
||||||
end
|
end
|
||||||
|
|
|
@ -257,8 +257,7 @@ class Gem::SourceIndex
|
||||||
|
|
||||||
# TODO - Remove support and warning for legacy arguments after 2008/11
|
# TODO - Remove support and warning for legacy arguments after 2008/11
|
||||||
unless Gem::Dependency === gem_pattern
|
unless Gem::Dependency === gem_pattern
|
||||||
warn "Gem::SourceIndex#search support for #{gem_pattern.class} patterns is deprecated"
|
warn "#{Gem.location_of_caller.join ':'}:Warning: Gem::SourceIndex#search support for #{gem_pattern.class} patterns is deprecated"
|
||||||
warn "#{caller[0]} is outdated"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
case gem_pattern
|
case gem_pattern
|
||||||
|
|
|
@ -10,118 +10,130 @@ require 'rubygems/digest/md5'
|
||||||
require 'rubygems/format'
|
require 'rubygems/format'
|
||||||
require 'rubygems/installer'
|
require 'rubygems/installer'
|
||||||
|
|
||||||
module Gem
|
##
|
||||||
|
# Validator performs various gem file and gem database validation
|
||||||
|
|
||||||
|
class Gem::Validator
|
||||||
|
|
||||||
|
include Gem::UserInteraction
|
||||||
|
|
||||||
##
|
##
|
||||||
# Validator performs various gem file and gem database validation
|
# Given a gem file's contents, validates against its own MD5 checksum
|
||||||
class Validator
|
# gem_data:: [String] Contents of the gem file
|
||||||
include UserInteraction
|
|
||||||
|
|
||||||
##
|
def verify_gem(gem_data)
|
||||||
# Given a gem file's contents, validates against its own MD5 checksum
|
raise Gem::VerificationError, 'empty gem file' if gem_data.size == 0
|
||||||
# gem_data:: [String] Contents of the gem file
|
|
||||||
def verify_gem(gem_data)
|
|
||||||
raise VerificationError, 'empty gem file' if gem_data.size == 0
|
|
||||||
|
|
||||||
unless gem_data =~ /MD5SUM/ then
|
unless gem_data =~ /MD5SUM/ then
|
||||||
return # Don't worry about it...this sucks. Need to fix MD5 stuff for
|
return # Don't worry about it...this sucks. Need to fix MD5 stuff for
|
||||||
# new format
|
# new format
|
||||||
# FIXME
|
# FIXME
|
||||||
end
|
|
||||||
|
|
||||||
sum_data = gem_data.gsub(/MD5SUM = "([a-z0-9]+)"/,
|
|
||||||
"MD5SUM = \"#{"F" * 32}\"")
|
|
||||||
|
|
||||||
unless Gem::MD5.hexdigest(sum_data) == $1.to_s then
|
|
||||||
raise VerificationError, 'invalid checksum for gem file'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
sum_data = gem_data.gsub(/MD5SUM = "([a-z0-9]+)"/,
|
||||||
# Given the path to a gem file, validates against its own MD5 checksum
|
"MD5SUM = \"#{"F" * 32}\"")
|
||||||
#
|
|
||||||
# gem_path:: [String] Path to gem file
|
unless Gem::MD5.hexdigest(sum_data) == $1.to_s then
|
||||||
def verify_gem_file(gem_path)
|
raise Gem::VerificationError, 'invalid checksum for gem file'
|
||||||
open gem_path, Gem.binary_mode do |file|
|
end
|
||||||
gem_data = file.read
|
end
|
||||||
verify_gem gem_data
|
|
||||||
|
##
|
||||||
|
# Given the path to a gem file, validates against its own MD5 checksum
|
||||||
|
#
|
||||||
|
# gem_path:: [String] Path to gem file
|
||||||
|
|
||||||
|
def verify_gem_file(gem_path)
|
||||||
|
open gem_path, Gem.binary_mode do |file|
|
||||||
|
gem_data = file.read
|
||||||
|
verify_gem gem_data
|
||||||
|
end
|
||||||
|
rescue Errno::ENOENT
|
||||||
|
raise Gem::VerificationError, "missing gem file #{gem_path}"
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def find_files_for_gem(gem_directory)
|
||||||
|
installed_files = []
|
||||||
|
Find.find(gem_directory) {|file_name|
|
||||||
|
fn = file_name.slice((gem_directory.size)..(file_name.size-1)).sub(/^\//, "")
|
||||||
|
if(!(fn =~ /CVS/ || File.directory?(fn) || fn == "")) then
|
||||||
|
installed_files << fn
|
||||||
end
|
end
|
||||||
rescue Errno::ENOENT
|
|
||||||
raise Gem::VerificationError.new("missing gem file #{gem_path}")
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
}
|
||||||
def find_files_for_gem(gem_directory)
|
installed_files
|
||||||
installed_files = []
|
end
|
||||||
Find.find(gem_directory) {|file_name|
|
|
||||||
fn = file_name.slice((gem_directory.size)..(file_name.size-1)).sub(/^\//, "")
|
|
||||||
if(!(fn =~ /CVS/ || File.directory?(fn) || fn == "")) then
|
|
||||||
installed_files << fn
|
|
||||||
end
|
|
||||||
|
|
||||||
}
|
|
||||||
installed_files
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
public
|
public
|
||||||
ErrorData = Struct.new(:path, :problem)
|
|
||||||
|
|
||||||
##
|
ErrorData = Struct.new :path, :problem
|
||||||
# Checks the gem directory for the following potential
|
|
||||||
# inconsistencies/problems:
|
|
||||||
# * Checksum gem itself
|
|
||||||
# * For each file in each gem, check consistency of installed versions
|
|
||||||
# * Check for files that aren't part of the gem but are in the gems directory
|
|
||||||
# * 1 cache - 1 spec - 1 directory.
|
|
||||||
#
|
|
||||||
# returns a hash of ErrorData objects, keyed on the problem gem's name.
|
|
||||||
def alien
|
|
||||||
errors = {}
|
|
||||||
Gem::SourceIndex.from_installed_gems.each do |gem_name, gem_spec|
|
|
||||||
errors[gem_name] ||= []
|
|
||||||
gem_path = File.join(Gem.dir, "cache", gem_spec.full_name) + ".gem"
|
|
||||||
spec_path = File.join(Gem.dir, "specifications", gem_spec.full_name) + ".gemspec"
|
|
||||||
gem_directory = File.join(Gem.dir, "gems", gem_spec.full_name)
|
|
||||||
installed_files = find_files_for_gem(gem_directory)
|
|
||||||
|
|
||||||
if(!File.exist?(spec_path)) then
|
|
||||||
errors[gem_name] << ErrorData.new(spec_path, "Spec file doesn't exist for installed gem")
|
|
||||||
end
|
|
||||||
|
|
||||||
begin
|
|
||||||
verify_gem_file(gem_path)
|
|
||||||
open gem_path, Gem.binary_mode do |file|
|
|
||||||
format = Gem::Format.from_file_by_path(gem_path)
|
|
||||||
format.file_entries.each do |entry, data|
|
|
||||||
# Found this file. Delete it from list
|
|
||||||
installed_files.delete remove_leading_dot_dir(entry['path'])
|
|
||||||
|
|
||||||
next unless data # HACK `gem check -a mkrf`
|
##
|
||||||
|
# Checks the gem directory for the following potential
|
||||||
|
# inconsistencies/problems:
|
||||||
|
#
|
||||||
|
# * Checksum gem itself
|
||||||
|
# * For each file in each gem, check consistency of installed versions
|
||||||
|
# * Check for files that aren't part of the gem but are in the gems directory
|
||||||
|
# * 1 cache - 1 spec - 1 directory.
|
||||||
|
#
|
||||||
|
# returns a hash of ErrorData objects, keyed on the problem gem's name.
|
||||||
|
|
||||||
open File.join(gem_directory, entry['path']), Gem.binary_mode do |f|
|
def alien
|
||||||
unless Gem::MD5.hexdigest(f.read).to_s ==
|
errors = {}
|
||||||
Gem::MD5.hexdigest(data).to_s then
|
|
||||||
errors[gem_name] << ErrorData.new(entry['path'], "installed file doesn't match original from gem")
|
Gem::SourceIndex.from_installed_gems.each do |gem_name, gem_spec|
|
||||||
end
|
errors[gem_name] ||= []
|
||||||
|
|
||||||
|
gem_path = File.join(Gem.dir, "cache", gem_spec.full_name) + ".gem"
|
||||||
|
spec_path = File.join(Gem.dir, "specifications", gem_spec.full_name) + ".gemspec"
|
||||||
|
gem_directory = File.join(Gem.dir, "gems", gem_spec.full_name)
|
||||||
|
|
||||||
|
installed_files = find_files_for_gem(gem_directory)
|
||||||
|
|
||||||
|
unless File.exist? spec_path then
|
||||||
|
errors[gem_name] << ErrorData.new(spec_path, "Spec file doesn't exist for installed gem")
|
||||||
|
end
|
||||||
|
|
||||||
|
begin
|
||||||
|
verify_gem_file(gem_path)
|
||||||
|
|
||||||
|
open gem_path, Gem.binary_mode do |file|
|
||||||
|
format = Gem::Format.from_file_by_path(gem_path)
|
||||||
|
format.file_entries.each do |entry, data|
|
||||||
|
# Found this file. Delete it from list
|
||||||
|
installed_files.delete remove_leading_dot_dir(entry['path'])
|
||||||
|
|
||||||
|
next unless data # HACK `gem check -a mkrf`
|
||||||
|
|
||||||
|
open File.join(gem_directory, entry['path']), Gem.binary_mode do |f|
|
||||||
|
unless Gem::MD5.hexdigest(f.read).to_s ==
|
||||||
|
Gem::MD5.hexdigest(data).to_s then
|
||||||
|
errors[gem_name] << ErrorData.new(entry['path'], "installed file doesn't match original from gem")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue VerificationError => e
|
|
||||||
errors[gem_name] << ErrorData.new(gem_path, e.message)
|
|
||||||
end
|
|
||||||
# Clean out directories that weren't explicitly included in the gemspec
|
|
||||||
# FIXME: This still allows arbitrary incorrect directories.
|
|
||||||
installed_files.delete_if {|potential_directory|
|
|
||||||
File.directory?(File.join(gem_directory, potential_directory))
|
|
||||||
}
|
|
||||||
if(installed_files.size > 0) then
|
|
||||||
errors[gem_name] << ErrorData.new(gem_path, "Unmanaged files in gem: #{installed_files.inspect}")
|
|
||||||
end
|
end
|
||||||
|
rescue Gem::VerificationError => e
|
||||||
|
errors[gem_name] << ErrorData.new(gem_path, e.message)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Clean out directories that weren't explicitly included in the gemspec
|
||||||
|
# FIXME: This still allows arbitrary incorrect directories.
|
||||||
|
installed_files.delete_if {|potential_directory|
|
||||||
|
File.directory?(File.join(gem_directory, potential_directory))
|
||||||
|
}
|
||||||
|
if(installed_files.size > 0) then
|
||||||
|
errors[gem_name] << ErrorData.new(gem_path, "Unmanaged files in gem: #{installed_files.inspect}")
|
||||||
end
|
end
|
||||||
errors
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
errors
|
||||||
|
end
|
||||||
|
|
||||||
|
if RUBY_VERSION < '1.9' then
|
||||||
class TestRunner
|
class TestRunner
|
||||||
def initialize(suite, ui)
|
def initialize(suite, ui)
|
||||||
@suite = suite
|
@suite = suite
|
||||||
|
@ -147,40 +159,50 @@ module Gem
|
||||||
end
|
end
|
||||||
|
|
||||||
autoload :TestRunner, 'test/unit/ui/testrunnerutilities'
|
autoload :TestRunner, 'test/unit/ui/testrunnerutilities'
|
||||||
|
end
|
||||||
##
|
|
||||||
# Runs unit tests for a given gem specification
|
##
|
||||||
def unit_test(gem_spec)
|
# Runs unit tests for a given gem specification
|
||||||
start_dir = Dir.pwd
|
|
||||||
Dir.chdir(gem_spec.full_gem_path)
|
def unit_test(gem_spec)
|
||||||
$: << File.join(Gem.dir, "gems", gem_spec.full_name)
|
start_dir = Dir.pwd
|
||||||
# XXX: why do we need this gem_spec when we've already got 'spec'?
|
Dir.chdir(gem_spec.full_gem_path)
|
||||||
test_files = gem_spec.test_files
|
$: << File.join(Gem.dir, "gems", gem_spec.full_name)
|
||||||
if test_files.empty?
|
# XXX: why do we need this gem_spec when we've already got 'spec'?
|
||||||
say "There are no unit tests to run for #{gem_spec.full_name}"
|
test_files = gem_spec.test_files
|
||||||
require 'test/unit/ui/console/testrunner'
|
|
||||||
return Test::Unit::TestResult.new
|
if test_files.empty? then
|
||||||
end
|
say "There are no unit tests to run for #{gem_spec.full_name}"
|
||||||
gem gem_spec.name, "= #{gem_spec.version.version}"
|
return nil
|
||||||
test_files.each do |f| require f end
|
end
|
||||||
|
|
||||||
|
gem gem_spec.name, "= #{gem_spec.version.version}"
|
||||||
|
|
||||||
|
test_files.each do |f| require f end
|
||||||
|
|
||||||
|
if RUBY_VERSION < '1.9' then
|
||||||
suite = Test::Unit::TestSuite.new("#{gem_spec.name}-#{gem_spec.version}")
|
suite = Test::Unit::TestSuite.new("#{gem_spec.name}-#{gem_spec.version}")
|
||||||
|
|
||||||
ObjectSpace.each_object(Class) do |klass|
|
ObjectSpace.each_object(Class) do |klass|
|
||||||
suite << klass.suite if (klass < Test::Unit::TestCase)
|
suite << klass.suite if (klass < Test::Unit::TestCase)
|
||||||
end
|
end
|
||||||
result = TestRunner.run(suite, ui())
|
|
||||||
unless result.passed?
|
result = TestRunner.run suite, ui
|
||||||
alert_error(result.to_s)
|
|
||||||
#unless ask_yes_no(result.to_s + "...keep Gem?", true) then
|
alert_error result.to_s unless result.passed?
|
||||||
#Gem::Uninstaller.new(gem_spec.name, gem_spec.version.version).uninstall
|
else
|
||||||
#end
|
result = MiniTest::Unit.new
|
||||||
end
|
result.run
|
||||||
result
|
|
||||||
ensure
|
|
||||||
Dir.chdir(start_dir)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_leading_dot_dir(path)
|
result
|
||||||
path.sub(/^\.\//, "")
|
ensure
|
||||||
end
|
Dir.chdir(start_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remove_leading_dot_dir(path)
|
||||||
|
path.sub(/^\.\//, "")
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,14 @@
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'test/unit'
|
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
|
require 'minitest/unit'
|
||||||
require 'test/insure_session'
|
require 'test/insure_session'
|
||||||
require 'rubygems/format'
|
require 'rubygems/format'
|
||||||
require 'rubygems/command_manager'
|
require 'rubygems/command_manager'
|
||||||
|
|
||||||
class FunctionalTest < Test::Unit::TestCase
|
class FunctionalTest < MiniTest::Unit::TestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@gem_path = File.expand_path("bin/gem")
|
@gem_path = File.expand_path("bin/gem")
|
||||||
lib_path = File.expand_path("lib")
|
lib_path = File.expand_path("lib")
|
||||||
|
@ -93,3 +94,6 @@ class FunctionalTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
MiniTest::Unit.autorun
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require 'test/unit'
|
require 'minitest/unit'
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/installer'
|
require 'rubygems/installer'
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#!/usr/bin/env ruby
|
|
||||||
#--
|
#--
|
||||||
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
|
@ -9,8 +8,14 @@ at_exit { $SAFE = 1 }
|
||||||
|
|
||||||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||||||
|
|
||||||
|
require 'rubygems'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
require 'test/unit'
|
begin
|
||||||
|
require 'minitest/unit'
|
||||||
|
rescue LoadError
|
||||||
|
warn "Install minitest gem"
|
||||||
|
raise
|
||||||
|
end
|
||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
require 'uri'
|
require 'uri'
|
||||||
require 'rubygems/package'
|
require 'rubygems/package'
|
||||||
|
@ -36,7 +41,7 @@ module Gem
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class RubyGemTestCase < Test::Unit::TestCase
|
class RubyGemTestCase < MiniTest::Unit::TestCase
|
||||||
|
|
||||||
include Gem::DefaultUserInteraction
|
include Gem::DefaultUserInteraction
|
||||||
|
|
||||||
|
@ -430,8 +435,6 @@ class RubyGemTestCase < Test::Unit::TestCase
|
||||||
Gem.module_eval {@ruby = ruby}
|
Gem.module_eval {@ruby = ruby}
|
||||||
env_rake = ENV["rake"]
|
env_rake = ENV["rake"]
|
||||||
ENV["rake"] = @@rake
|
ENV["rake"] = @@rake
|
||||||
argv = ARGV.dup
|
|
||||||
ARGV.clear
|
|
||||||
yield @@rake
|
yield @@rake
|
||||||
ensure
|
ensure
|
||||||
Gem.module_eval {@ruby = gem_ruby}
|
Gem.module_eval {@ruby = gem_ruby}
|
||||||
|
@ -440,7 +443,6 @@ class RubyGemTestCase < Test::Unit::TestCase
|
||||||
else
|
else
|
||||||
ENV.delete("rake")
|
ENV.delete("rake")
|
||||||
end
|
end
|
||||||
ARGV.replace(argv) if argv
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.rubybin
|
def self.rubybin
|
||||||
|
@ -482,3 +484,5 @@ class RubyGemTestCase < Test::Unit::TestCase
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
MiniTest::Unit.autorun
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
#!/usr/bin/env ruby
|
|
||||||
#--
|
#--
|
||||||
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
|
|
|
@ -65,8 +65,8 @@ class TestGem < RubyGemTestCase
|
||||||
|
|
||||||
assert_equal nil, Gem.instance_variable_get(:@gem_home)
|
assert_equal nil, Gem.instance_variable_get(:@gem_home)
|
||||||
assert_equal nil, Gem.instance_variable_get(:@gem_path)
|
assert_equal nil, Gem.instance_variable_get(:@gem_path)
|
||||||
assert_not_equal searcher, Gem.searcher
|
refute_equal searcher, Gem.searcher
|
||||||
assert_not_equal source_index.object_id, Gem.source_index.object_id
|
refute_equal source_index.object_id, Gem.source_index.object_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_configuration
|
def test_self_configuration
|
||||||
|
@ -214,10 +214,10 @@ class TestGem < RubyGemTestCase
|
||||||
orig_Gem_ssl_available = Gem.ssl_available?
|
orig_Gem_ssl_available = Gem.ssl_available?
|
||||||
|
|
||||||
Gem.ssl_available = true
|
Gem.ssl_available = true
|
||||||
assert_nothing_raised do Gem.ensure_ssl_available end
|
Gem.ensure_ssl_available
|
||||||
|
|
||||||
Gem.ssl_available = false
|
Gem.ssl_available = false
|
||||||
e = assert_raise Gem::Exception do Gem.ensure_ssl_available end
|
e = assert_raises Gem::Exception do Gem.ensure_ssl_available end
|
||||||
assert_equal 'SSL is not installed on this system', e.message
|
assert_equal 'SSL is not installed on this system', e.message
|
||||||
ensure
|
ensure
|
||||||
Gem.ssl_available = orig_Gem_ssl_available
|
Gem.ssl_available = orig_Gem_ssl_available
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/builder'
|
require 'rubygems/builder'
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/command'
|
require 'rubygems/command'
|
||||||
|
|
||||||
|
@ -63,7 +62,7 @@ class TestGemCommand < RubyGemTestCase
|
||||||
|
|
||||||
assert_match %r|-x, --zip|, @cmd.parser.to_s
|
assert_match %r|-x, --zip|, @cmd.parser.to_s
|
||||||
assert_match %r|-z, --exe|, @cmd.parser.to_s
|
assert_match %r|-z, --exe|, @cmd.parser.to_s
|
||||||
assert_no_match %r|-x, --exe|, @cmd.parser.to_s
|
refute_match %r|-x, --exe|, @cmd.parser.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_basic_accessors
|
def test_basic_accessors
|
||||||
|
@ -109,7 +108,7 @@ class TestGemCommand < RubyGemTestCase
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.when_invoked do true end
|
@cmd.when_invoked do true end
|
||||||
|
|
||||||
ex = assert_raise(OptionParser::InvalidOption) do
|
ex = assert_raises OptionParser::InvalidOption do
|
||||||
@cmd.invoke('-zzz')
|
@cmd.invoke('-zzz')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/command_manager'
|
require 'rubygems/command_manager'
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/commands/build_command'
|
require 'rubygems/commands/build_command'
|
||||||
require 'rubygems/format'
|
require 'rubygems/format'
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
|
|
||||||
require 'rubygems/commands/cert_command'
|
require 'rubygems/commands/cert_command'
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/commands/check_command'
|
require 'rubygems/commands/check_command'
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/commands/contents_command'
|
require 'rubygems/commands/contents_command'
|
||||||
|
|
||||||
|
@ -28,7 +27,7 @@ class TestGemCommandsContentsCommand < RubyGemTestCase
|
||||||
def test_execute_bad_gem
|
def test_execute_bad_gem
|
||||||
@cmd.options[:args] = %w[foo]
|
@cmd.options[:args] = %w[foo]
|
||||||
|
|
||||||
assert_raise MockGemUi::TermError do
|
assert_raises MockGemUi::TermError do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
@ -71,7 +70,7 @@ class TestGemCommandsContentsCommand < RubyGemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_match %r|lib/foo\.rb|, @ui.output
|
assert_match %r|lib/foo\.rb|, @ui.output
|
||||||
assert_no_match %r|Rakefile|, @ui.output
|
refute_match %r|Rakefile|, @ui.output
|
||||||
|
|
||||||
assert_equal "", @ui.error
|
assert_equal "", @ui.error
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/commands/dependency_command'
|
require 'rubygems/commands/dependency_command'
|
||||||
|
|
||||||
|
@ -61,7 +60,7 @@ Gem pl-1-x86-linux
|
||||||
def test_execute_no_match
|
def test_execute_no_match
|
||||||
@cmd.options[:args] = %w[foo]
|
@cmd.options[:args] = %w[foo]
|
||||||
|
|
||||||
assert_raise MockGemUi::TermError do
|
assert_raises MockGemUi::TermError do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
@ -146,7 +145,7 @@ Gem foo-2
|
||||||
@cmd.options[:reverse_dependencies] = true
|
@cmd.options[:reverse_dependencies] = true
|
||||||
@cmd.options[:domain] = :remote
|
@cmd.options[:domain] = :remote
|
||||||
|
|
||||||
assert_raise MockGemUi::TermError do
|
assert_raises MockGemUi::TermError do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/commands/environment_command'
|
require 'rubygems/commands/environment_command'
|
||||||
|
|
||||||
|
@ -109,7 +108,7 @@ class TestGemCommandsEnvironmentCommand < RubyGemTestCase
|
||||||
def test_execute_unknown
|
def test_execute_unknown
|
||||||
@cmd.send :handle_options, %w[unknown]
|
@cmd.send :handle_options, %w[unknown]
|
||||||
|
|
||||||
assert_raise Gem::CommandLineError do
|
assert_raises Gem::CommandLineError do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/package'
|
require 'rubygems/package'
|
||||||
require 'rubygems/security'
|
require 'rubygems/security'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require 'test/unit'
|
require 'minitest/unit'
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/indexer'
|
require 'rubygems/indexer'
|
||||||
require 'rubygems/commands/generate_index_command'
|
require 'rubygems/commands/generate_index_command'
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/commands/install_command'
|
require 'rubygems/commands/install_command'
|
||||||
|
|
||||||
|
@ -16,7 +15,7 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
|
||||||
@cmd.options[:include_dependencies] = true
|
@cmd.options[:include_dependencies] = true
|
||||||
@cmd.options[:args] = []
|
@cmd.options[:args] = []
|
||||||
|
|
||||||
assert_raise Gem::CommandLineError do
|
assert_raises Gem::CommandLineError do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
@ -79,7 +78,7 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
|
||||||
def test_execute_no_gem
|
def test_execute_no_gem
|
||||||
@cmd.options[:args] = %w[]
|
@cmd.options[:args] = %w[]
|
||||||
|
|
||||||
assert_raise Gem::CommandLineError do
|
assert_raises Gem::CommandLineError do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/commands/list_command'
|
require 'rubygems/commands/list_command'
|
||||||
|
|
||||||
|
@ -21,7 +20,7 @@ class TestGemCommandsListCommand < RubyGemTestCase
|
||||||
def test_execute_installed
|
def test_execute_installed
|
||||||
@cmd.handle_options %w[c --installed]
|
@cmd.handle_options %w[c --installed]
|
||||||
|
|
||||||
e = assert_raise Gem::SystemExitException do
|
e = assert_raises Gem::SystemExitException do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/commands/lock_command'
|
require 'rubygems/commands/lock_command'
|
||||||
|
|
||||||
|
@ -56,7 +55,7 @@ gem 'd', '= 1'
|
||||||
def test_execute_strict
|
def test_execute_strict
|
||||||
@cmd.handle_options %w[c-1 --strict]
|
@cmd.handle_options %w[c-1 --strict]
|
||||||
|
|
||||||
e = assert_raise Gem::Exception do
|
e = assert_raises Gem::Exception do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/indexer'
|
require 'rubygems/indexer'
|
||||||
require 'rubygems/commands/mirror_command'
|
require 'rubygems/commands/mirror_command'
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/commands/outdated_command'
|
require 'rubygems/commands/outdated_command'
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/commands/pristine_command'
|
require 'rubygems/commands/pristine_command'
|
||||||
|
|
||||||
|
@ -96,7 +95,7 @@ class TestGemCommandsPristineCommand < RubyGemTestCase
|
||||||
def test_execute_no_gem
|
def test_execute_no_gem
|
||||||
@cmd.options[:args] = %w[]
|
@cmd.options[:args] = %w[]
|
||||||
|
|
||||||
e = assert_raise Gem::CommandLineError do
|
e = assert_raises Gem::CommandLineError do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/commands/query_command'
|
require 'rubygems/commands/query_command'
|
||||||
|
|
||||||
|
@ -99,7 +98,7 @@ pl (1)
|
||||||
def test_execute_installed
|
def test_execute_installed
|
||||||
@cmd.handle_options %w[-n c --installed]
|
@cmd.handle_options %w[-n c --installed]
|
||||||
|
|
||||||
e = assert_raise Gem::SystemExitException do
|
e = assert_raises Gem::SystemExitException do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
@ -115,7 +114,7 @@ pl (1)
|
||||||
def test_execute_installed_no_name
|
def test_execute_installed_no_name
|
||||||
@cmd.handle_options %w[--installed]
|
@cmd.handle_options %w[--installed]
|
||||||
|
|
||||||
e = assert_raise Gem::SystemExitException do
|
e = assert_raises Gem::SystemExitException do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
@ -130,7 +129,7 @@ pl (1)
|
||||||
def test_execute_installed_not_installed
|
def test_execute_installed_not_installed
|
||||||
@cmd.handle_options %w[-n not_installed --installed]
|
@cmd.handle_options %w[-n not_installed --installed]
|
||||||
|
|
||||||
e = assert_raise Gem::SystemExitException do
|
e = assert_raises Gem::SystemExitException do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
@ -145,7 +144,7 @@ pl (1)
|
||||||
def test_execute_installed_version
|
def test_execute_installed_version
|
||||||
@cmd.handle_options %w[-n c --installed --version 1.2]
|
@cmd.handle_options %w[-n c --installed --version 1.2]
|
||||||
|
|
||||||
e = assert_raise Gem::SystemExitException do
|
e = assert_raises Gem::SystemExitException do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
@ -160,7 +159,7 @@ pl (1)
|
||||||
def test_execute_installed_version_not_installed
|
def test_execute_installed_version_not_installed
|
||||||
@cmd.handle_options %w[-n c --installed --version 2]
|
@cmd.handle_options %w[-n c --installed --version 2]
|
||||||
|
|
||||||
e = assert_raise Gem::SystemExitException do
|
e = assert_raises Gem::SystemExitException do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/commands/server_command'
|
require 'rubygems/commands/server_command'
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/commands/sources_command'
|
require 'rubygems/commands/sources_command'
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/commands/specification_command'
|
require 'rubygems/commands/specification_command'
|
||||||
|
|
||||||
|
@ -46,7 +45,7 @@ class TestGemCommandsSpecificationCommand < RubyGemTestCase
|
||||||
def test_execute_bad_name
|
def test_execute_bad_name
|
||||||
@cmd.options[:args] = %w[foo]
|
@cmd.options[:args] = %w[foo]
|
||||||
|
|
||||||
assert_raise MockGemUi::TermError do
|
assert_raises MockGemUi::TermError do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/commands/stale_command'
|
require 'rubygems/commands/stale_command'
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)),
|
require File.join(File.expand_path(File.dirname(__FILE__)),
|
||||||
'gem_installer_test_case')
|
'gem_installer_test_case')
|
||||||
|
@ -48,7 +47,7 @@ class TestGemCommandsUninstallCommand < GemInstallerTestCase
|
||||||
|
|
||||||
def test_execute_not_installed
|
def test_execute_not_installed
|
||||||
@cmd.options[:args] = ["foo"]
|
@cmd.options[:args] = ["foo"]
|
||||||
e = assert_raise(Gem::InstallError) do
|
e = assert_raises Gem::InstallError do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/commands/unpack_command'
|
require 'rubygems/commands/unpack_command'
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/commands/update_command'
|
require 'rubygems/commands/update_command'
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
#!/usr/bin/env ruby
|
|
||||||
#--
|
#--
|
||||||
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/config_file'
|
require 'rubygems/config_file'
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/version'
|
require 'rubygems/version'
|
||||||
|
|
||||||
|
@ -70,7 +69,7 @@ class TestGemDependency < RubyGemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_type_is_restricted
|
def test_type_is_restricted
|
||||||
assert_raise(ArgumentError) do
|
assert_raises ArgumentError do
|
||||||
Gem::Dependency.new("pkg", [:sometimes])
|
Gem::Dependency.new("pkg", [:sometimes])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -79,21 +78,21 @@ class TestGemDependency < RubyGemTestCase
|
||||||
assert_equal @pkg1_0, @pkg1_0.dup
|
assert_equal @pkg1_0, @pkg1_0.dup
|
||||||
assert_equal @pkg1_0.dup, @pkg1_0
|
assert_equal @pkg1_0.dup, @pkg1_0
|
||||||
|
|
||||||
assert_not_equal @pkg1_0, @pkg1_1, "requirements different"
|
refute_equal @pkg1_0, @pkg1_1, "requirements different"
|
||||||
assert_not_equal @pkg1_1, @pkg1_0, "requirements different"
|
refute_equal @pkg1_1, @pkg1_0, "requirements different"
|
||||||
|
|
||||||
assert_not_equal @pkg1_0, @oth1_0, "names different"
|
refute_equal @pkg1_0, @oth1_0, "names different"
|
||||||
assert_not_equal @oth1_0, @pkg1_0, "names different"
|
refute_equal @oth1_0, @pkg1_0, "names different"
|
||||||
|
|
||||||
assert_not_equal @pkg1_0, Object.new
|
refute_equal @pkg1_0, Object.new
|
||||||
assert_not_equal Object.new, @pkg1_0
|
refute_equal Object.new, @pkg1_0
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_equals2_type
|
def test_equals2_type
|
||||||
runtime = Gem::Dependency.new("pkg", [])
|
runtime = Gem::Dependency.new("pkg", [])
|
||||||
development = Gem::Dependency.new("pkg", [], :development)
|
development = Gem::Dependency.new("pkg", [], :development)
|
||||||
|
|
||||||
assert_not_equal(runtime, development)
|
refute_equal(runtime, development)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_equals_tilde
|
def test_equals_tilde
|
||||||
|
@ -123,18 +122,18 @@ class TestGemDependency < RubyGemTestCase
|
||||||
assert_equal @pkg1_0.hash, @pkg1_0.dup.hash
|
assert_equal @pkg1_0.hash, @pkg1_0.dup.hash
|
||||||
assert_equal @pkg1_0.dup.hash, @pkg1_0.hash
|
assert_equal @pkg1_0.dup.hash, @pkg1_0.hash
|
||||||
|
|
||||||
assert_not_equal @pkg1_0.hash, @pkg1_1.hash, "requirements different"
|
refute_equal @pkg1_0.hash, @pkg1_1.hash, "requirements different"
|
||||||
assert_not_equal @pkg1_1.hash, @pkg1_0.hash, "requirements different"
|
refute_equal @pkg1_1.hash, @pkg1_0.hash, "requirements different"
|
||||||
|
|
||||||
assert_not_equal @pkg1_0.hash, @oth1_0.hash, "names different"
|
refute_equal @pkg1_0.hash, @oth1_0.hash, "names different"
|
||||||
assert_not_equal @oth1_0.hash, @pkg1_0.hash, "names different"
|
refute_equal @oth1_0.hash, @pkg1_0.hash, "names different"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_hash_type
|
def test_hash_type
|
||||||
runtime = Gem::Dependency.new("pkg", [])
|
runtime = Gem::Dependency.new("pkg", [])
|
||||||
development = Gem::Dependency.new("pkg", [], :development)
|
development = Gem::Dependency.new("pkg", [], :development)
|
||||||
|
|
||||||
assert_not_equal(runtime.hash, development.hash)
|
refute_equal(runtime.hash, development.hash)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/dependency_installer'
|
require 'rubygems/dependency_installer'
|
||||||
|
|
||||||
|
@ -360,7 +359,7 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
||||||
Gem.source_index.gems.delete @a1.full_name
|
Gem.source_index.gems.delete @a1.full_name
|
||||||
|
|
||||||
Dir.chdir @tempdir do
|
Dir.chdir @tempdir do
|
||||||
e = assert_raise Gem::InstallError do
|
e = assert_raises Gem::InstallError do
|
||||||
inst = Gem::DependencyInstaller.new :domain => :local
|
inst = Gem::DependencyInstaller.new :domain => :local
|
||||||
inst.install 'b'
|
inst.install 'b'
|
||||||
end
|
end
|
||||||
|
@ -498,7 +497,7 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
||||||
policy = Gem::Security::HighSecurity
|
policy = Gem::Security::HighSecurity
|
||||||
inst = Gem::DependencyInstaller.new :security_policy => policy
|
inst = Gem::DependencyInstaller.new :security_policy => policy
|
||||||
|
|
||||||
e = assert_raise Gem::Exception do
|
e = assert_raises Gem::Exception do
|
||||||
inst.install 'b'
|
inst.install 'b'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -516,8 +515,8 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
||||||
inst = Gem::DependencyInstaller.new :wrappers => false
|
inst = Gem::DependencyInstaller.new :wrappers => false
|
||||||
inst.install 'a'
|
inst.install 'a'
|
||||||
|
|
||||||
assert_no_match(%r|This file was generated by RubyGems.|,
|
refute_match(%r|This file was generated by RubyGems.|,
|
||||||
File.read(File.join(@gemhome, 'bin', 'a_bin')))
|
File.read(File.join(@gemhome, 'bin', 'a_bin')))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
#!/usr/bin/env ruby
|
|
||||||
#--
|
#--
|
||||||
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
|
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/dependency_list'
|
require 'rubygems/dependency_list'
|
||||||
|
|
||||||
|
|
|
@ -1,44 +1,46 @@
|
||||||
#!/usr/bin/env ruby
|
|
||||||
#--
|
#--
|
||||||
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require "test/unit"
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require "rubygems/digest/md5"
|
require "rubygems/digest/md5"
|
||||||
require "rubygems/digest/sha1"
|
require "rubygems/digest/sha1"
|
||||||
require "rubygems/digest/sha2"
|
require "rubygems/digest/sha2"
|
||||||
|
|
||||||
class TestRubygemsGemDigest < Test::Unit::TestCase
|
class TestRubygemsGemDigest < RubyGemTestCase
|
||||||
|
|
||||||
def test_sha256_hex_digest_works
|
def test_sha256_hex_digest_works
|
||||||
digester = Gem::SHA256.new
|
digester = Gem::SHA256.new
|
||||||
assert_equal "b5d4045c3f466fa91fe2cc6abe79232a1a57cdf104f7a26e716e0a1e2789df78", digester.hexdigest("ABC")
|
assert_equal "b5d4045c3f466fa91fe2cc6abe79232a1a57cdf104f7a26e716e0a1e2789df78", digester.hexdigest("ABC")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sha256_digest_works
|
def test_sha256_digest_works
|
||||||
digester = Gem::SHA256.new
|
digester = Gem::SHA256.new
|
||||||
assert_equal "\265\324\004\\?Fo\251\037\342\314j\276y#*\032W\315\361\004\367\242nqn\n\036'\211\337x",
|
assert_equal "\265\324\004\\?Fo\251\037\342\314j\276y#*\032W\315\361\004\367\242nqn\n\036'\211\337x",
|
||||||
digester.digest("ABC")
|
digester.digest("ABC")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sha1_hex_digest_works
|
def test_sha1_hex_digest_works
|
||||||
digester = Gem::SHA1.new
|
digester = Gem::SHA1.new
|
||||||
assert_equal "3c01bdbb26f358bab27f267924aa2c9a03fcfdb8", digester.hexdigest("ABC")
|
assert_equal "3c01bdbb26f358bab27f267924aa2c9a03fcfdb8", digester.hexdigest("ABC")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sha1_digest_works
|
def test_sha1_digest_works
|
||||||
digester = Gem::SHA1.new
|
digester = Gem::SHA1.new
|
||||||
assert_equal "<\001\275\273&\363X\272\262\177&y$\252,\232\003\374\375\270", digester.digest("ABC")
|
assert_equal "<\001\275\273&\363X\272\262\177&y$\252,\232\003\374\375\270", digester.digest("ABC")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_md5_hex_digest_works
|
def test_md5_hex_digest_works
|
||||||
digester = Gem::MD5.new
|
digester = Gem::MD5.new
|
||||||
assert_equal "902fbdd2b1df0c4f70b4a5d23525e932", digester.hexdigest("ABC")
|
assert_equal "902fbdd2b1df0c4f70b4a5d23525e932", digester.hexdigest("ABC")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_md5_digest_works
|
def test_md5_digest_works
|
||||||
digester = Gem::MD5.new
|
digester = Gem::MD5.new
|
||||||
assert_equal "\220/\275\322\261\337\fOp\264\245\3225%\3512", digester.digest("ABC")
|
assert_equal "\220/\275\322\261\337\fOp\264\245\3225%\3512", digester.digest("ABC")
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/doc_manager'
|
require 'rubygems/doc_manager'
|
||||||
|
|
||||||
|
@ -21,7 +20,7 @@ class TestGemDocManager < RubyGemTestCase
|
||||||
orig_mode = File.stat(@spec.installation_path).mode
|
orig_mode = File.stat(@spec.installation_path).mode
|
||||||
File.chmod 0, @spec.installation_path
|
File.chmod 0, @spec.installation_path
|
||||||
|
|
||||||
assert_raise Gem::FilePermissionError do
|
assert_raises Gem::FilePermissionError do
|
||||||
@manager.uninstall_doc
|
@manager.uninstall_doc
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/ext'
|
require 'rubygems/ext'
|
||||||
|
|
||||||
|
@ -41,7 +40,7 @@ class TestGemExtConfigureBuilder < RubyGemTestCase
|
||||||
return if RUBY_PLATFORM =~ /mswin/ # HACK
|
return if RUBY_PLATFORM =~ /mswin/ # HACK
|
||||||
output = []
|
output = []
|
||||||
|
|
||||||
error = assert_raise Gem::InstallError do
|
error = assert_raises Gem::InstallError do
|
||||||
Dir.chdir @ext do
|
Dir.chdir @ext do
|
||||||
Gem::Ext::ConfigureBuilder.build nil, nil, @dest_path, output
|
Gem::Ext::ConfigureBuilder.build nil, nil, @dest_path, output
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/ext'
|
require 'rubygems/ext'
|
||||||
|
|
||||||
|
@ -55,7 +54,7 @@ class TestGemExtExtConfBuilder < RubyGemTestCase
|
||||||
|
|
||||||
output = []
|
output = []
|
||||||
|
|
||||||
error = assert_raise Gem::InstallError do
|
error = assert_raises Gem::InstallError do
|
||||||
Dir.chdir @ext do
|
Dir.chdir @ext do
|
||||||
Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
|
Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
|
||||||
end
|
end
|
||||||
|
@ -103,7 +102,7 @@ install:
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_class_make_no_Makefile
|
def test_class_make_no_Makefile
|
||||||
error = assert_raise Gem::InstallError do
|
error = assert_raises Gem::InstallError do
|
||||||
Dir.chdir @ext do
|
Dir.chdir @ext do
|
||||||
Gem::Ext::ExtConfBuilder.make @ext, ['output']
|
Gem::Ext::ExtConfBuilder.make @ext, ['output']
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/ext'
|
require 'rubygems/ext'
|
||||||
|
|
||||||
|
@ -41,7 +40,7 @@ class TestGemExtRakeBuilder < RubyGemTestCase
|
||||||
"(in #{realdir})\n"
|
"(in #{realdir})\n"
|
||||||
]
|
]
|
||||||
|
|
||||||
assert_no_match %r%^rake failed:%, output
|
refute_match %r%^rake failed:%, output
|
||||||
assert_match %r%^#{Regexp.escape @@ruby} mkrf_conf\.rb%, output
|
assert_match %r%^#{Regexp.escape @@ruby} mkrf_conf\.rb%, output
|
||||||
assert_match %r%^#{Regexp.escape @@rake} RUBYARCHDIR=#{Regexp.escape @dest_path} RUBYLIBDIR=#{Regexp.escape @dest_path}%, output
|
assert_match %r%^#{Regexp.escape @@rake} RUBYARCHDIR=#{Regexp.escape @dest_path} RUBYLIBDIR=#{Regexp.escape @dest_path}%, output
|
||||||
end
|
end
|
||||||
|
@ -57,7 +56,7 @@ class TestGemExtRakeBuilder < RubyGemTestCase
|
||||||
|
|
||||||
output = []
|
output = []
|
||||||
|
|
||||||
error = assert_raise Gem::InstallError do
|
error = assert_raises Gem::InstallError do
|
||||||
build_rake_in do
|
build_rake_in do
|
||||||
Dir.chdir @ext do
|
Dir.chdir @ext do
|
||||||
Gem::Ext::RakeBuilder.build "mkrf_conf.rb", nil, @dest_path, output
|
Gem::Ext::RakeBuilder.build "mkrf_conf.rb", nil, @dest_path, output
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'simple_gem')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'simple_gem')
|
||||||
require 'rubygems/format'
|
require 'rubygems/format'
|
||||||
|
@ -36,27 +35,27 @@ class TestGemFormat < RubyGemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_from_file_by_path_nonexistent
|
def test_from_file_by_path_nonexistent
|
||||||
assert_raise Gem::Exception do
|
assert_raises Gem::Exception do
|
||||||
Gem::Format.from_file_by_path '/nonexistent'
|
Gem::Format.from_file_by_path '/nonexistent'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_from_io_garbled
|
def test_from_io_garbled
|
||||||
e = assert_raise Gem::Package::FormatError do
|
e = assert_raises Gem::Package::FormatError do
|
||||||
# subtly bogus input
|
# subtly bogus input
|
||||||
Gem::Format.from_io(StringIO.new(@simple_gem.upcase))
|
Gem::Format.from_io(StringIO.new(@simple_gem.upcase))
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal 'No metadata found!', e.message
|
assert_equal 'No metadata found!', e.message
|
||||||
|
|
||||||
e = assert_raise Gem::Package::FormatError do
|
e = assert_raises Gem::Package::FormatError do
|
||||||
# Totally bogus input
|
# Totally bogus input
|
||||||
Gem::Format.from_io(StringIO.new(@simple_gem.reverse))
|
Gem::Format.from_io(StringIO.new(@simple_gem.reverse))
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal 'No metadata found!', e.message
|
assert_equal 'No metadata found!', e.message
|
||||||
|
|
||||||
e = assert_raise Gem::Package::FormatError do
|
e = assert_raises Gem::Package::FormatError do
|
||||||
# This was intentionally screws up YAML parsing.
|
# This was intentionally screws up YAML parsing.
|
||||||
Gem::Format.from_io(StringIO.new(@simple_gem.gsub(/:/, "boom")))
|
Gem::Format.from_io(StringIO.new(@simple_gem.gsub(/:/, "boom")))
|
||||||
end
|
end
|
||||||
|
@ -66,4 +65,3 @@ class TestGemFormat < RubyGemTestCase
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/gem_path_searcher'
|
require 'rubygems/gem_path_searcher'
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/gem_runner'
|
require 'rubygems/gem_runner'
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
|
|
||||||
require 'rubygems/indexer'
|
require 'rubygems/indexer'
|
||||||
|
@ -217,8 +216,8 @@ Compressing indicies
|
||||||
assert_same specs[0].last, specs[1].last,
|
assert_same specs[0].last, specs[1].last,
|
||||||
'identical platforms not identical'
|
'identical platforms not identical'
|
||||||
|
|
||||||
assert_not_same specs[1][1], specs[5][1],
|
refute_same specs[1][1], specs[5][1],
|
||||||
'different versions not different'
|
'different versions not different'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generate_index_latest_specs
|
def test_generate_index_latest_specs
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)),
|
require File.join(File.expand_path(File.dirname(__FILE__)),
|
||||||
'gem_installer_test_case')
|
'gem_installer_test_case')
|
||||||
|
@ -31,7 +30,7 @@ class TestGemInstallUpdateOptions < GemInstallerTestCase
|
||||||
def test_security_policy_unknown
|
def test_security_policy_unknown
|
||||||
@cmd.add_install_update_options
|
@cmd.add_install_update_options
|
||||||
|
|
||||||
assert_raise OptionParser::InvalidArgument do
|
assert_raises OptionParser::InvalidArgument do
|
||||||
@cmd.handle_options %w[-P UnknownSecurity]
|
@cmd.handle_options %w[-P UnknownSecurity]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -52,7 +52,7 @@ load 'my_exec'
|
||||||
def test_build_extensions_extconf_bad
|
def test_build_extensions_extconf_bad
|
||||||
@spec.extensions << 'extconf.rb'
|
@spec.extensions << 'extconf.rb'
|
||||||
|
|
||||||
e = assert_raise Gem::Installer::ExtensionBuildError do
|
e = assert_raises Gem::Installer::ExtensionBuildError do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@installer.build_extensions
|
@installer.build_extensions
|
||||||
end
|
end
|
||||||
|
@ -79,7 +79,7 @@ load 'my_exec'
|
||||||
def test_build_extensions_unsupported
|
def test_build_extensions_unsupported
|
||||||
@spec.extensions << nil
|
@spec.extensions << nil
|
||||||
|
|
||||||
e = assert_raise Gem::Installer::ExtensionBuildError do
|
e = assert_raises Gem::Installer::ExtensionBuildError do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@installer.build_extensions
|
@installer.build_extensions
|
||||||
end
|
end
|
||||||
|
@ -101,7 +101,7 @@ load 'my_exec'
|
||||||
assert @installer.ensure_dependency(@spec, dep)
|
assert @installer.ensure_dependency(@spec, dep)
|
||||||
|
|
||||||
dep = Gem::Dependency.new 'b', '> 2'
|
dep = Gem::Dependency.new 'b', '> 2'
|
||||||
e = assert_raise Gem::InstallError do
|
e = assert_raises Gem::InstallError do
|
||||||
@installer.ensure_dependency @spec, dep
|
@installer.ensure_dependency @spec, dep
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ load 'my_exec'
|
||||||
def test_extract_files_bad_dest
|
def test_extract_files_bad_dest
|
||||||
@installer.gem_dir = 'somedir'
|
@installer.gem_dir = 'somedir'
|
||||||
@installer.format = nil
|
@installer.format = nil
|
||||||
e = assert_raise ArgumentError do
|
e = assert_raises ArgumentError do
|
||||||
@installer.extract_files
|
@installer.extract_files
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ load 'my_exec'
|
||||||
|
|
||||||
@installer.format = format
|
@installer.format = format
|
||||||
|
|
||||||
e = assert_raise Gem::InstallError do
|
e = assert_raises Gem::InstallError do
|
||||||
@installer.extract_files
|
@installer.extract_files
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ load 'my_exec'
|
||||||
|
|
||||||
@installer.format = format
|
@installer.format = format
|
||||||
|
|
||||||
e = assert_raise Gem::InstallError do
|
e = assert_raises Gem::InstallError do
|
||||||
@installer.extract_files
|
@installer.extract_files
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -342,8 +342,8 @@ load 'my_exec'
|
||||||
|
|
||||||
assert_match %r|generated by RubyGems|, File.read(installed_exec)
|
assert_match %r|generated by RubyGems|, File.read(installed_exec)
|
||||||
|
|
||||||
assert_no_match %r|generated by RubyGems|, File.read(real_exec),
|
refute_match %r|generated by RubyGems|, File.read(real_exec),
|
||||||
'real executable overwritten'
|
'real executable overwritten'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generate_bin_symlink
|
def test_generate_bin_symlink
|
||||||
|
@ -581,7 +581,7 @@ load 'my_exec'
|
||||||
gem_data = File.open gem, 'rb' do |fp| fp.read 1024 end
|
gem_data = File.open gem, 'rb' do |fp| fp.read 1024 end
|
||||||
File.open gem, 'wb' do |fp| fp.write gem_data end
|
File.open gem, 'wb' do |fp| fp.write gem_data end
|
||||||
|
|
||||||
e = assert_raise Gem::InstallError do
|
e = assert_raises Gem::InstallError do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@installer = Gem::Installer.new gem
|
@installer = Gem::Installer.new gem
|
||||||
@installer.install
|
@installer.install
|
||||||
|
@ -596,7 +596,7 @@ load 'my_exec'
|
||||||
util_setup_gem
|
util_setup_gem
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
assert_raise Gem::InstallError do
|
assert_raises Gem::InstallError do
|
||||||
@installer.install
|
@installer.install
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -739,7 +739,7 @@ load 'my_exec'
|
||||||
def test_install_wrong_ruby_version
|
def test_install_wrong_ruby_version
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
installer = Gem::Installer.new old_ruby_required
|
installer = Gem::Installer.new old_ruby_required
|
||||||
e = assert_raise Gem::InstallError do
|
e = assert_raises Gem::InstallError do
|
||||||
installer.install
|
installer.install
|
||||||
end
|
end
|
||||||
assert_equal 'old_ruby_required requires Ruby version = 1.4.6',
|
assert_equal 'old_ruby_required requires Ruby version = 1.4.6',
|
||||||
|
@ -758,7 +758,7 @@ load 'my_exec'
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@installer = Gem::Installer.new gem
|
@installer = Gem::Installer.new gem
|
||||||
e = assert_raise Gem::InstallError do
|
e = assert_raises Gem::InstallError do
|
||||||
@installer.install
|
@installer.install
|
||||||
end
|
end
|
||||||
assert_equal 'old_rubygems_required requires RubyGems version < 0',
|
assert_equal 'old_rubygems_required requires RubyGems version < 0',
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/local_remote_options'
|
require 'rubygems/local_remote_options'
|
||||||
require 'rubygems/command'
|
require 'rubygems/command'
|
||||||
|
@ -86,7 +85,7 @@ class TestGemLocalRemoteOptions < RubyGemTestCase
|
||||||
|
|
||||||
s1 = 'htp://more-gems.example.com'
|
s1 = 'htp://more-gems.example.com'
|
||||||
|
|
||||||
assert_raise OptionParser::InvalidArgument do
|
assert_raises OptionParser::InvalidArgument do
|
||||||
@cmd.handle_options %W[--source #{s1}]
|
@cmd.handle_options %W[--source #{s1}]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -36,19 +36,19 @@ class TestGemPackageTarReaderEntry < TarTestCase
|
||||||
|
|
||||||
assert @entry.bytes_read
|
assert @entry.bytes_read
|
||||||
|
|
||||||
e = assert_raise IOError do @entry.eof? end
|
e = assert_raises IOError do @entry.eof? end
|
||||||
assert_equal 'closed Gem::Package::TarReader::Entry', e.message
|
assert_equal 'closed Gem::Package::TarReader::Entry', e.message
|
||||||
|
|
||||||
e = assert_raise IOError do @entry.getc end
|
e = assert_raises IOError do @entry.getc end
|
||||||
assert_equal 'closed Gem::Package::TarReader::Entry', e.message
|
assert_equal 'closed Gem::Package::TarReader::Entry', e.message
|
||||||
|
|
||||||
e = assert_raise IOError do @entry.pos end
|
e = assert_raises IOError do @entry.pos end
|
||||||
assert_equal 'closed Gem::Package::TarReader::Entry', e.message
|
assert_equal 'closed Gem::Package::TarReader::Entry', e.message
|
||||||
|
|
||||||
e = assert_raise IOError do @entry.read end
|
e = assert_raises IOError do @entry.read end
|
||||||
assert_equal 'closed Gem::Package::TarReader::Entry', e.message
|
assert_equal 'closed Gem::Package::TarReader::Entry', e.message
|
||||||
|
|
||||||
e = assert_raise IOError do @entry.rewind end
|
e = assert_raises IOError do @entry.rewind end
|
||||||
assert_equal 'closed Gem::Package::TarReader::Entry', e.message
|
assert_equal 'closed Gem::Package::TarReader::Entry', e.message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ class TestTarWriter < TarTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_add_file_simple_size
|
def test_add_file_simple_size
|
||||||
assert_raise Gem::Package::TarWriter::FileOverflow do
|
assert_raises Gem::Package::TarWriter::FileOverflow do
|
||||||
@tar_writer.add_file_simple("lib/foo/bar", 0, 10) do |io|
|
@tar_writer.add_file_simple("lib/foo/bar", 0, 10) do |io|
|
||||||
io.write "1" * 11
|
io.write "1" * 11
|
||||||
end
|
end
|
||||||
|
@ -69,7 +69,7 @@ class TestTarWriter < TarTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_add_file_unseekable
|
def test_add_file_unseekable
|
||||||
assert_raise Gem::Package::NonSeekableIO do
|
assert_raises Gem::Package::NonSeekableIO do
|
||||||
Gem::Package::TarWriter.new(Object.new).add_file 'x', 0
|
Gem::Package::TarWriter.new(Object.new).add_file 'x', 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -79,27 +79,27 @@ class TestTarWriter < TarTestCase
|
||||||
|
|
||||||
assert_equal "\0" * 1024, @io.string
|
assert_equal "\0" * 1024, @io.string
|
||||||
|
|
||||||
e = assert_raise IOError do
|
e = assert_raises IOError do
|
||||||
@tar_writer.close
|
@tar_writer.close
|
||||||
end
|
end
|
||||||
assert_equal 'closed Gem::Package::TarWriter', e.message
|
assert_equal 'closed Gem::Package::TarWriter', e.message
|
||||||
|
|
||||||
e = assert_raise IOError do
|
e = assert_raises IOError do
|
||||||
@tar_writer.flush
|
@tar_writer.flush
|
||||||
end
|
end
|
||||||
assert_equal 'closed Gem::Package::TarWriter', e.message
|
assert_equal 'closed Gem::Package::TarWriter', e.message
|
||||||
|
|
||||||
e = assert_raise IOError do
|
e = assert_raises IOError do
|
||||||
@tar_writer.add_file 'x', 0
|
@tar_writer.add_file 'x', 0
|
||||||
end
|
end
|
||||||
assert_equal 'closed Gem::Package::TarWriter', e.message
|
assert_equal 'closed Gem::Package::TarWriter', e.message
|
||||||
|
|
||||||
e = assert_raise IOError do
|
e = assert_raises IOError do
|
||||||
@tar_writer.add_file_simple 'x', 0, 0
|
@tar_writer.add_file_simple 'x', 0, 0
|
||||||
end
|
end
|
||||||
assert_equal 'closed Gem::Package::TarWriter', e.message
|
assert_equal 'closed Gem::Package::TarWriter', e.message
|
||||||
|
|
||||||
e = assert_raise IOError do
|
e = assert_raises IOError do
|
||||||
@tar_writer.mkdir 'x', 0
|
@tar_writer.mkdir 'x', 0
|
||||||
end
|
end
|
||||||
assert_equal 'closed Gem::Package::TarWriter', e.message
|
assert_equal 'closed Gem::Package::TarWriter', e.message
|
||||||
|
@ -125,7 +125,7 @@ class TestTarWriter < TarTestCase
|
||||||
name = File.join 'a', 'b' * 100
|
name = File.join 'a', 'b' * 100
|
||||||
assert_equal ['b' * 100, 'a'], @tar_writer.split_name(name)
|
assert_equal ['b' * 100, 'a'], @tar_writer.split_name(name)
|
||||||
|
|
||||||
assert_raise Gem::Package::TooLongFileName do
|
assert_raises Gem::Package::TooLongFileName do
|
||||||
name = File.join 'a', 'b' * 101
|
name = File.join 'a', 'b' * 101
|
||||||
@tar_writer.split_name name
|
@tar_writer.split_name name
|
||||||
end
|
end
|
||||||
|
@ -135,14 +135,14 @@ class TestTarWriter < TarTestCase
|
||||||
name = File.join 'a' * 155, 'b'
|
name = File.join 'a' * 155, 'b'
|
||||||
assert_equal ['b', 'a' * 155], @tar_writer.split_name(name)
|
assert_equal ['b', 'a' * 155], @tar_writer.split_name(name)
|
||||||
|
|
||||||
assert_raise Gem::Package::TooLongFileName do
|
assert_raises Gem::Package::TooLongFileName do
|
||||||
name = File.join 'a' * 156, 'b'
|
name = File.join 'a' * 156, 'b'
|
||||||
@tar_writer.split_name name
|
@tar_writer.split_name name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_split_name_too_long_total
|
def test_split_name_too_long_total
|
||||||
assert_raise Gem::Package::TooLongFileName do
|
assert_raises Gem::Package::TooLongFileName do
|
||||||
@tar_writer.split_name 'a' * 257
|
@tar_writer.split_name 'a' * 257
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'test/unit'
|
|
||||||
require 'rubygems/platform'
|
require 'rubygems/platform'
|
||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
|
|
||||||
|
@ -147,8 +146,8 @@ class TestGemPlatform < RubyGemTestCase
|
||||||
other = Gem::Platform.new %w[cpu other_platform 1]
|
other = Gem::Platform.new %w[cpu other_platform 1]
|
||||||
|
|
||||||
assert_equal my, my
|
assert_equal my, my
|
||||||
assert_not_equal my, other
|
refute_equal my, other
|
||||||
assert_not_equal other, my
|
refute_equal other, my
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_equals3
|
def test_equals3
|
||||||
|
@ -205,10 +204,10 @@ class TestGemPlatform < RubyGemTestCase
|
||||||
# oddballs
|
# oddballs
|
||||||
assert_match 'i386-mswin32-mq5.3', Gem::Platform.local
|
assert_match 'i386-mswin32-mq5.3', Gem::Platform.local
|
||||||
assert_match 'i386-mswin32-mq6', Gem::Platform.local
|
assert_match 'i386-mswin32-mq6', Gem::Platform.local
|
||||||
deny_match 'win32-1.8.2-VC7', Gem::Platform.local
|
refute_match 'win32-1.8.2-VC7', Gem::Platform.local
|
||||||
deny_match 'win32-1.8.4-VC6', Gem::Platform.local
|
refute_match 'win32-1.8.4-VC6', Gem::Platform.local
|
||||||
deny_match 'win32-source', Gem::Platform.local
|
refute_match 'win32-source', Gem::Platform.local
|
||||||
deny_match 'windows', Gem::Platform.local
|
refute_match 'windows', Gem::Platform.local
|
||||||
|
|
||||||
util_set_arch 'i686-linux'
|
util_set_arch 'i686-linux'
|
||||||
assert_match 'i486-linux', Gem::Platform.local
|
assert_match 'i486-linux', Gem::Platform.local
|
||||||
|
@ -236,17 +235,5 @@ class TestGemPlatform < RubyGemTestCase
|
||||||
assert_match 'sparc-solaris2.8-mq5.3', Gem::Platform.local
|
assert_match 'sparc-solaris2.8-mq5.3', Gem::Platform.local
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_match(pattern, platform, message = '')
|
|
||||||
full_message = build_message message, "<?> expected to be =~\n<?>.",
|
|
||||||
platform, pattern
|
|
||||||
assert_block(full_message) { platform =~ pattern }
|
|
||||||
end
|
|
||||||
|
|
||||||
def deny_match(pattern, platform, message = '')
|
|
||||||
full_message = build_message message, "<?> expected to be !~\n<?>.",
|
|
||||||
platform, pattern
|
|
||||||
assert_block(full_message) { platform !~ pattern }
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
#!/usr/bin/env ruby
|
|
||||||
#--
|
#--
|
||||||
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'webrick'
|
require 'webrick'
|
||||||
require 'zlib'
|
require 'zlib'
|
||||||
|
@ -111,9 +109,14 @@ gems:
|
||||||
@fetcher = Gem::RemoteFetcher.fetcher
|
@fetcher = Gem::RemoteFetcher.fetcher
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def teardown
|
||||||
|
super
|
||||||
|
Gem.configuration[:http_proxy] = nil
|
||||||
|
end
|
||||||
|
|
||||||
def test_self_fetcher
|
def test_self_fetcher
|
||||||
fetcher = Gem::RemoteFetcher.fetcher
|
fetcher = Gem::RemoteFetcher.fetcher
|
||||||
assert_not_nil fetcher
|
refute_nil fetcher
|
||||||
assert_kind_of Gem::RemoteFetcher, fetcher
|
assert_kind_of Gem::RemoteFetcher, fetcher
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -124,7 +127,7 @@ gems:
|
||||||
|
|
||||||
fetcher = Gem::RemoteFetcher.fetcher
|
fetcher = Gem::RemoteFetcher.fetcher
|
||||||
|
|
||||||
assert_not_nil fetcher
|
refute_nil fetcher
|
||||||
assert_kind_of Gem::RemoteFetcher, fetcher
|
assert_kind_of Gem::RemoteFetcher, fetcher
|
||||||
assert_equal proxy_uri, fetcher.instance_variable_get(:@proxy_uri).to_s
|
assert_equal proxy_uri, fetcher.instance_variable_get(:@proxy_uri).to_s
|
||||||
end
|
end
|
||||||
|
@ -132,8 +135,11 @@ gems:
|
||||||
def test_self_fetcher_with_proxy_URI
|
def test_self_fetcher_with_proxy_URI
|
||||||
proxy_uri = URI.parse 'http://proxy.example.com'
|
proxy_uri = URI.parse 'http://proxy.example.com'
|
||||||
Gem.configuration[:http_proxy] = proxy_uri
|
Gem.configuration[:http_proxy] = proxy_uri
|
||||||
|
Gem::RemoteFetcher.fetcher = nil
|
||||||
|
|
||||||
fetcher = Gem::RemoteFetcher.fetcher
|
fetcher = Gem::RemoteFetcher.fetcher
|
||||||
assert_not_nil fetcher
|
refute_nil fetcher
|
||||||
|
|
||||||
assert_kind_of Gem::RemoteFetcher, fetcher
|
assert_kind_of Gem::RemoteFetcher, fetcher
|
||||||
assert_equal proxy_uri, fetcher.instance_variable_get(:@proxy_uri)
|
assert_equal proxy_uri, fetcher.instance_variable_get(:@proxy_uri)
|
||||||
end
|
end
|
||||||
|
@ -141,7 +147,7 @@ gems:
|
||||||
def test_fetch_size_bad_uri
|
def test_fetch_size_bad_uri
|
||||||
fetcher = Gem::RemoteFetcher.new nil
|
fetcher = Gem::RemoteFetcher.new nil
|
||||||
|
|
||||||
e = assert_raise ArgumentError do
|
e = assert_raises ArgumentError do
|
||||||
fetcher.fetch_size 'gems.example.com/yaml'
|
fetcher.fetch_size 'gems.example.com/yaml'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -155,7 +161,7 @@ gems:
|
||||||
end
|
end
|
||||||
|
|
||||||
uri = 'http://gems.example.com/yaml'
|
uri = 'http://gems.example.com/yaml'
|
||||||
e = assert_raise Gem::RemoteFetcher::FetchError do
|
e = assert_raises Gem::RemoteFetcher::FetchError do
|
||||||
fetcher.fetch_size uri
|
fetcher.fetch_size uri
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -310,7 +316,7 @@ gems:
|
||||||
def test_download_unsupported
|
def test_download_unsupported
|
||||||
inst = Gem::RemoteFetcher.fetcher
|
inst = Gem::RemoteFetcher.fetcher
|
||||||
|
|
||||||
e = assert_raise Gem::InstallError do
|
e = assert_raises Gem::InstallError do
|
||||||
inst.download @a1, 'ftp://gems.rubyforge.org'
|
inst.download @a1, 'ftp://gems.rubyforge.org'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -408,7 +414,7 @@ gems:
|
||||||
raise EOFError
|
raise EOFError
|
||||||
end
|
end
|
||||||
|
|
||||||
e = assert_raise Gem::RemoteFetcher::FetchError do
|
e = assert_raises Gem::RemoteFetcher::FetchError do
|
||||||
fetcher.fetch_path 'uri'
|
fetcher.fetch_path 'uri'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -423,7 +429,7 @@ gems:
|
||||||
raise SocketError
|
raise SocketError
|
||||||
end
|
end
|
||||||
|
|
||||||
e = assert_raise Gem::RemoteFetcher::FetchError do
|
e = assert_raises Gem::RemoteFetcher::FetchError do
|
||||||
fetcher.fetch_path 'uri'
|
fetcher.fetch_path 'uri'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -438,7 +444,7 @@ gems:
|
||||||
raise Errno::ECONNREFUSED, 'connect(2)'
|
raise Errno::ECONNREFUSED, 'connect(2)'
|
||||||
end
|
end
|
||||||
|
|
||||||
e = assert_raise Gem::RemoteFetcher::FetchError do
|
e = assert_raises Gem::RemoteFetcher::FetchError do
|
||||||
fetcher.fetch_path 'uri'
|
fetcher.fetch_path 'uri'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -546,7 +552,7 @@ gems:
|
||||||
conn = { 'gems.example.com:80' => conn }
|
conn = { 'gems.example.com:80' => conn }
|
||||||
fetcher.instance_variable_set :@connections, conn
|
fetcher.instance_variable_set :@connections, conn
|
||||||
|
|
||||||
e = assert_raise Gem::RemoteFetcher::FetchError do
|
e = assert_raises Gem::RemoteFetcher::FetchError do
|
||||||
fetcher.open_uri_or_path 'http://gems.example.com/redirect'
|
fetcher.open_uri_or_path 'http://gems.example.com/redirect'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/version'
|
require 'rubygems/version'
|
||||||
|
|
||||||
|
@ -32,19 +31,19 @@ class TestGemRequirement < RubyGemTestCase
|
||||||
assert_equal @r1_2, @r1_2.dup
|
assert_equal @r1_2, @r1_2.dup
|
||||||
assert_equal @r1_2.dup, @r1_2
|
assert_equal @r1_2.dup, @r1_2
|
||||||
|
|
||||||
assert_not_equal @r1_3, @r1_2
|
refute_equal @r1_3, @r1_2
|
||||||
assert_not_equal @r1_2, @r1_3
|
refute_equal @r1_2, @r1_3
|
||||||
|
|
||||||
assert_not_equal Object.new, @r1_2
|
refute_equal Object.new, @r1_2
|
||||||
assert_not_equal @r1_2, Object.new
|
refute_equal @r1_2, Object.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_hash
|
def test_hash
|
||||||
assert_equal @r1_2.hash, @r1_2.dup.hash
|
assert_equal @r1_2.hash, @r1_2.dup.hash
|
||||||
assert_equal @r1_2.dup.hash, @r1_2.hash
|
assert_equal @r1_2.dup.hash, @r1_2.hash
|
||||||
|
|
||||||
assert_not_equal @r1_2.hash, @r1_3.hash
|
refute_equal @r1_2.hash, @r1_3.hash
|
||||||
assert_not_equal @r1_3.hash, @r1_2.hash
|
refute_equal @r1_3.hash, @r1_2.hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# We may get some old gems that have requirements in old formats.
|
# We may get some old gems that have requirements in old formats.
|
||||||
|
@ -80,13 +79,13 @@ class TestGemRequirement < RubyGemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_parse_illformed
|
def test_parse_illformed
|
||||||
e = assert_raise ArgumentError do
|
e = assert_raises ArgumentError do
|
||||||
@r1_2.parse(nil)
|
@r1_2.parse(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal 'Illformed requirement [nil]', e.message
|
assert_equal 'Illformed requirement [nil]', e.message
|
||||||
|
|
||||||
e = assert_raise ArgumentError do
|
e = assert_raises ArgumentError do
|
||||||
@r1_2.parse('')
|
@r1_2.parse('')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -139,7 +138,7 @@ class TestGemRequirement < RubyGemTestCase
|
||||||
assert_equal false, r1_2.satisfied_by?(v1_2)
|
assert_equal false, r1_2.satisfied_by?(v1_2)
|
||||||
assert_equal true, r1_2.satisfied_by?(v1_3)
|
assert_equal true, r1_2.satisfied_by?(v1_3)
|
||||||
|
|
||||||
assert_raise NoMethodError do
|
assert_raises NoMethodError do
|
||||||
assert_equal true, r1_2.satisfied_by?(nil)
|
assert_equal true, r1_2.satisfied_by?(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -154,7 +153,7 @@ class TestGemRequirement < RubyGemTestCase
|
||||||
assert_equal true, r1_2.satisfied_by?(v1_2)
|
assert_equal true, r1_2.satisfied_by?(v1_2)
|
||||||
assert_equal true, r1_2.satisfied_by?(v1_3)
|
assert_equal true, r1_2.satisfied_by?(v1_3)
|
||||||
|
|
||||||
assert_raise NoMethodError do
|
assert_raises NoMethodError do
|
||||||
assert_equal true, r1_2.satisfied_by?(nil)
|
assert_equal true, r1_2.satisfied_by?(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -169,7 +168,7 @@ class TestGemRequirement < RubyGemTestCase
|
||||||
assert_equal true, r.satisfied_by?(v1_2)
|
assert_equal true, r.satisfied_by?(v1_2)
|
||||||
assert_equal false, r.satisfied_by?(v1_3)
|
assert_equal false, r.satisfied_by?(v1_3)
|
||||||
|
|
||||||
assert_raise NoMethodError do
|
assert_raises NoMethodError do
|
||||||
assert_equal true, r.satisfied_by?(nil)
|
assert_equal true, r.satisfied_by?(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -184,7 +183,7 @@ class TestGemRequirement < RubyGemTestCase
|
||||||
assert_equal false, r1_2.satisfied_by?(v1_2)
|
assert_equal false, r1_2.satisfied_by?(v1_2)
|
||||||
assert_equal false, r1_2.satisfied_by?(v1_3)
|
assert_equal false, r1_2.satisfied_by?(v1_3)
|
||||||
|
|
||||||
assert_raise NoMethodError do
|
assert_raises NoMethodError do
|
||||||
assert_equal true, r1_2.satisfied_by?(nil)
|
assert_equal true, r1_2.satisfied_by?(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -199,7 +198,7 @@ class TestGemRequirement < RubyGemTestCase
|
||||||
assert_equal true, r1_2.satisfied_by?(v1_2)
|
assert_equal true, r1_2.satisfied_by?(v1_2)
|
||||||
assert_equal false, r1_2.satisfied_by?(v1_3)
|
assert_equal false, r1_2.satisfied_by?(v1_3)
|
||||||
|
|
||||||
assert_raise NoMethodError do
|
assert_raises NoMethodError do
|
||||||
assert_equal true, r1_2.satisfied_by?(nil)
|
assert_equal true, r1_2.satisfied_by?(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -214,7 +213,7 @@ class TestGemRequirement < RubyGemTestCase
|
||||||
assert_equal true, r1_2.satisfied_by?(v1_2)
|
assert_equal true, r1_2.satisfied_by?(v1_2)
|
||||||
assert_equal true, r1_2.satisfied_by?(v1_3)
|
assert_equal true, r1_2.satisfied_by?(v1_3)
|
||||||
|
|
||||||
assert_raise NoMethodError do
|
assert_raises NoMethodError do
|
||||||
assert_equal true, r1_2.satisfied_by?(nil)
|
assert_equal true, r1_2.satisfied_by?(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/server'
|
require 'rubygems/server'
|
||||||
require 'stringio'
|
require 'stringio'
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/source_index'
|
require 'rubygems/source_index'
|
||||||
require 'rubygems/config_file'
|
require 'rubygems/config_file'
|
||||||
|
@ -150,7 +149,7 @@ WARNING: Invalid .gemspec format in '#{spec_file}'
|
||||||
end
|
end
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
assert_raise Interrupt do
|
assert_raises Interrupt do
|
||||||
Gem::SourceIndex.load_specification(spec_file)
|
Gem::SourceIndex.load_specification(spec_file)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -192,7 +191,7 @@ WARNING: Invalid .gemspec format in '#{spec_file}'
|
||||||
end
|
end
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
assert_raise SystemExit do
|
assert_raises SystemExit do
|
||||||
Gem::SourceIndex.load_specification(spec_file)
|
Gem::SourceIndex.load_specification(spec_file)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -232,7 +231,7 @@ WARNING: Invalid .gemspec format in '#{spec_file}'
|
||||||
@fetcher.data["#{@gem_repo}yaml.Z"] = proc { raise SocketError }
|
@fetcher.data["#{@gem_repo}yaml.Z"] = proc { raise SocketError }
|
||||||
@fetcher.data["#{@gem_repo}yaml"] = proc { raise SocketError }
|
@fetcher.data["#{@gem_repo}yaml"] = proc { raise SocketError }
|
||||||
|
|
||||||
e = assert_raise Gem::RemoteSourceException do
|
e = assert_raises Gem::RemoteSourceException do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@source_index.fetch_bulk_index @uri
|
@source_index.fetch_bulk_index @uri
|
||||||
end
|
end
|
||||||
|
@ -357,7 +356,7 @@ WARNING: Invalid .gemspec format in '#{spec_file}'
|
||||||
@fetcher.data["#{@gem_repo}quick/index.rz"] =
|
@fetcher.data["#{@gem_repo}quick/index.rz"] =
|
||||||
proc { raise Exception }
|
proc { raise Exception }
|
||||||
|
|
||||||
e = assert_raise Gem::OperationNotSupportedError do
|
e = assert_raises Gem::OperationNotSupportedError do
|
||||||
@source_index.fetch_quick_index @uri, true
|
@source_index.fetch_quick_index @uri, true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -613,7 +612,7 @@ WARNING: Invalid .gemspec format in '#{spec_file}'
|
||||||
def test_refresh_bang_not_from_dir
|
def test_refresh_bang_not_from_dir
|
||||||
source_index = Gem::SourceIndex.new
|
source_index = Gem::SourceIndex.new
|
||||||
|
|
||||||
e = assert_raise RuntimeError do
|
e = assert_raises RuntimeError do
|
||||||
source_index.refresh!
|
source_index.refresh!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
#!/usr/bin/env ruby
|
|
||||||
#--
|
#--
|
||||||
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/source_info_cache'
|
require 'rubygems/source_info_cache'
|
||||||
|
|
||||||
|
@ -49,7 +47,7 @@ class TestGemSourceInfoCache < RubyGemTestCase
|
||||||
Gem.sources.replace %W[#{@gem_repo}]
|
Gem.sources.replace %W[#{@gem_repo}]
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
assert_not_nil Gem::SourceInfoCache.cache
|
refute_nil Gem::SourceInfoCache.cache
|
||||||
assert_kind_of Gem::SourceInfoCache, Gem::SourceInfoCache.cache
|
assert_kind_of Gem::SourceInfoCache, Gem::SourceInfoCache.cache
|
||||||
assert_equal Gem::SourceInfoCache.cache.object_id,
|
assert_equal Gem::SourceInfoCache.cache.object_id,
|
||||||
Gem::SourceInfoCache.cache.object_id
|
Gem::SourceInfoCache.cache.object_id
|
||||||
|
@ -68,11 +66,11 @@ class TestGemSourceInfoCache < RubyGemTestCase
|
||||||
Gem.sources.replace %w[#{@gem_repo}]
|
Gem.sources.replace %w[#{@gem_repo}]
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
assert_not_nil Gem::SourceInfoCache.cache
|
refute_nil Gem::SourceInfoCache.cache
|
||||||
assert_kind_of Gem::SourceInfoCache, Gem::SourceInfoCache.cache
|
assert_kind_of Gem::SourceInfoCache, Gem::SourceInfoCache.cache
|
||||||
assert_equal Gem::SourceInfoCache.cache.object_id,
|
assert_equal Gem::SourceInfoCache.cache.object_id,
|
||||||
Gem::SourceInfoCache.cache.object_id
|
Gem::SourceInfoCache.cache.object_id
|
||||||
assert_no_match %r|Bulk updating|, @ui.output
|
refute_match %r|Bulk updating|, @ui.output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -147,7 +145,7 @@ class TestGemSourceInfoCache < RubyGemTestCase
|
||||||
def test_cache_data_none_writable
|
def test_cache_data_none_writable
|
||||||
FileUtils.chmod 0444, @sic.system_cache_file
|
FileUtils.chmod 0444, @sic.system_cache_file
|
||||||
FileUtils.chmod 0444, @sic.user_cache_file
|
FileUtils.chmod 0444, @sic.user_cache_file
|
||||||
e = assert_raise RuntimeError do
|
e = assert_raises RuntimeError do
|
||||||
@sic.cache_data
|
@sic.cache_data
|
||||||
end
|
end
|
||||||
assert_equal 'unable to locate a writable cache file', e.message
|
assert_equal 'unable to locate a writable cache file', e.message
|
||||||
|
@ -202,7 +200,7 @@ class TestGemSourceInfoCache < RubyGemTestCase
|
||||||
def test_cache_file_none_writable
|
def test_cache_file_none_writable
|
||||||
FileUtils.chmod 0444, @sic.system_cache_file
|
FileUtils.chmod 0444, @sic.system_cache_file
|
||||||
FileUtils.chmod 0444, @sic.user_cache_file
|
FileUtils.chmod 0444, @sic.user_cache_file
|
||||||
e = assert_raise RuntimeError do
|
e = assert_raises RuntimeError do
|
||||||
@sic.cache_file
|
@sic.cache_file
|
||||||
end
|
end
|
||||||
assert_equal 'unable to locate a writable cache file', e.message
|
assert_equal 'unable to locate a writable cache file', e.message
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/source_info_cache_entry'
|
require 'rubygems/source_info_cache_entry'
|
||||||
|
|
||||||
|
@ -56,7 +55,7 @@ class TestGemSourceInfoCacheEntry < RubyGemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_refresh_bad_uri
|
def test_refresh_bad_uri
|
||||||
assert_raise URI::BadURIError do
|
assert_raises URI::BadURIError do
|
||||||
@sic_e.refresh 'gems.example.com', true
|
@sic_e.refresh 'gems.example.com', true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/spec_fetcher'
|
require 'rubygems/spec_fetcher'
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'stringio'
|
require 'stringio'
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/specification'
|
require 'rubygems/specification'
|
||||||
|
|
||||||
|
@ -336,8 +335,8 @@ end
|
||||||
def test_equals2
|
def test_equals2
|
||||||
assert_equal @a1, @a1
|
assert_equal @a1, @a1
|
||||||
assert_equal @a1, @a1.dup
|
assert_equal @a1, @a1.dup
|
||||||
assert_not_equal @a1, @a2
|
refute_equal @a1, @a2
|
||||||
assert_not_equal @a1, Object.new
|
refute_equal @a1, Object.new
|
||||||
end
|
end
|
||||||
|
|
||||||
# The cgikit specification was reported to be causing trouble in at least
|
# The cgikit specification was reported to be causing trouble in at least
|
||||||
|
@ -369,16 +368,16 @@ end
|
||||||
spec = @a1.dup
|
spec = @a1.dup
|
||||||
spec.default_executable = 'xx'
|
spec.default_executable = 'xx'
|
||||||
|
|
||||||
assert_not_equal @a1, spec
|
refute_equal @a1, spec
|
||||||
assert_not_equal spec, @a1
|
refute_equal spec, @a1
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_equals2_extensions
|
def test_equals2_extensions
|
||||||
spec = @a1.dup
|
spec = @a1.dup
|
||||||
spec.extensions = 'xx'
|
spec.extensions = 'xx'
|
||||||
|
|
||||||
assert_not_equal @a1, spec
|
refute_equal @a1, spec
|
||||||
assert_not_equal spec, @a1
|
refute_equal spec, @a1
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_executables
|
def test_executables
|
||||||
|
@ -506,7 +505,7 @@ end
|
||||||
def test_hash
|
def test_hash
|
||||||
assert_equal @a1.hash, @a1.hash
|
assert_equal @a1.hash, @a1.hash
|
||||||
assert_equal @a1.hash, @a1.dup.hash
|
assert_equal @a1.hash, @a1.dup.hash
|
||||||
assert_not_equal @a1.hash, @a2.hash
|
refute_equal @a1.hash, @a2.hash
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_lib_files
|
def test_lib_files
|
||||||
|
@ -815,7 +814,7 @@ end
|
||||||
|
|
||||||
@a1.authors = [Object.new]
|
@a1.authors = [Object.new]
|
||||||
|
|
||||||
e = assert_raise Gem::InvalidSpecificationException do
|
e = assert_raises Gem::InvalidSpecificationException do
|
||||||
@a1.validate
|
@a1.validate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -849,7 +848,7 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_validate_empty
|
def test_validate_empty
|
||||||
e = assert_raise Gem::InvalidSpecificationException do
|
e = assert_raises Gem::InvalidSpecificationException do
|
||||||
Gem::Specification.new.validate
|
Gem::Specification.new.validate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -872,7 +871,7 @@ end
|
||||||
|
|
||||||
def test_validate_empty_require_paths
|
def test_validate_empty_require_paths
|
||||||
@a1.require_paths = []
|
@a1.require_paths = []
|
||||||
e = assert_raise Gem::InvalidSpecificationException do
|
e = assert_raises Gem::InvalidSpecificationException do
|
||||||
@a1.validate
|
@a1.validate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -932,7 +931,7 @@ end
|
||||||
|
|
||||||
def test_validate_rubygems_version
|
def test_validate_rubygems_version
|
||||||
@a1.rubygems_version = "3"
|
@a1.rubygems_version = "3"
|
||||||
e = assert_raise Gem::InvalidSpecificationException do
|
e = assert_raises Gem::InvalidSpecificationException do
|
||||||
@a1.validate
|
@a1.validate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/user_interaction'
|
require 'rubygems/user_interaction'
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'simple_gem')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'simple_gem')
|
||||||
require 'rubygems/validator'
|
require 'rubygems/validator'
|
||||||
|
@ -26,7 +25,7 @@ class TestGemValidator < RubyGemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_verify_gem_file_empty
|
def test_verify_gem_file_empty
|
||||||
e = assert_raise Gem::VerificationError do
|
e = assert_raises Gem::VerificationError do
|
||||||
@validator.verify_gem_file ''
|
@validator.verify_gem_file ''
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -35,7 +34,7 @@ class TestGemValidator < RubyGemTestCase
|
||||||
|
|
||||||
def test_verify_gem_file_nonexistent
|
def test_verify_gem_file_nonexistent
|
||||||
file = '/nonexistent/nonexistent.gem'
|
file = '/nonexistent/nonexistent.gem'
|
||||||
e = assert_raise Gem::VerificationError do
|
e = assert_raises Gem::VerificationError do
|
||||||
@validator.verify_gem_file file
|
@validator.verify_gem_file file
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -47,7 +46,7 @@ class TestGemValidator < RubyGemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_verify_gem_empty
|
def test_verify_gem_empty
|
||||||
e = assert_raise Gem::VerificationError do
|
e = assert_raises Gem::VerificationError do
|
||||||
@validator.verify_gem ''
|
@validator.verify_gem ''
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -55,7 +54,7 @@ class TestGemValidator < RubyGemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_verify_gem_invalid_checksum
|
def test_verify_gem_invalid_checksum
|
||||||
e = assert_raise Gem::VerificationError do
|
e = assert_raises Gem::VerificationError do
|
||||||
@validator.verify_gem @simple_gem.upcase
|
@validator.verify_gem @simple_gem.upcase
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/version'
|
require 'rubygems/version'
|
||||||
|
|
||||||
|
@ -29,10 +28,10 @@ class TestGemVersion < RubyGemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_class_create_malformed
|
def test_class_create_malformed
|
||||||
e = assert_raise ArgumentError do Gem::Version.create("junk") end
|
e = assert_raises ArgumentError do Gem::Version.create("junk") end
|
||||||
assert_equal "Malformed version number string junk", e.message
|
assert_equal "Malformed version number string junk", e.message
|
||||||
|
|
||||||
e = assert_raise ArgumentError do Gem::Version.create("1.0\n2.0") end
|
e = assert_raises ArgumentError do Gem::Version.create("1.0\n2.0") end
|
||||||
assert_equal "Malformed version number string 1.0\n2.0", e.message
|
assert_equal "Malformed version number string 1.0\n2.0", e.message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -90,8 +89,8 @@ class TestGemVersion < RubyGemTestCase
|
||||||
assert_equal v, @v1_2
|
assert_equal v, @v1_2
|
||||||
assert_equal @v1_2, v
|
assert_equal @v1_2, v
|
||||||
|
|
||||||
assert_not_equal @v1_2, @v1_3
|
refute_equal @v1_2, @v1_3
|
||||||
assert_not_equal @v1_3, @v1_2
|
refute_equal @v1_3, @v1_2
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_hash
|
def test_hash
|
||||||
|
@ -100,16 +99,16 @@ class TestGemVersion < RubyGemTestCase
|
||||||
|
|
||||||
assert_equal v1_2.hash, @v1_2.hash
|
assert_equal v1_2.hash, @v1_2.hash
|
||||||
|
|
||||||
assert_not_equal v1_2_0.hash, @v1_2.hash
|
refute_equal v1_2_0.hash, @v1_2.hash
|
||||||
|
|
||||||
assert_not_equal @v1_2.hash, @v1_3.hash
|
refute_equal @v1_2.hash, @v1_3.hash
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_illformed_requirements
|
def test_illformed_requirements
|
||||||
[ ">>> 1.3.5", "> blah" ].each do |rq|
|
[ ">>> 1.3.5", "> blah" ].each do |rq|
|
||||||
assert_raises(ArgumentError, "req [#{rq}] should fail") {
|
assert_raises ArgumentError, "req [#{rq}] should fail" do
|
||||||
Gem::Version::Requirement.new(rq)
|
Gem::Version::Requirement.new rq
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/command'
|
require 'rubygems/command'
|
||||||
require 'rubygems/version_option'
|
require 'rubygems/version_option'
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
#!/usr/bin/env ruby
|
|
||||||
#--
|
#--
|
||||||
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/package'
|
require 'rubygems/package'
|
||||||
|
|
||||||
|
@ -48,7 +46,7 @@ class TestKernel < RubyGemTestCase
|
||||||
def test_gem_conflicting
|
def test_gem_conflicting
|
||||||
assert gem('a', '= 1'), "Should load"
|
assert gem('a', '= 1'), "Should load"
|
||||||
|
|
||||||
ex = assert_raise Gem::Exception do
|
ex = assert_raises Gem::Exception do
|
||||||
gem 'a', '= 2'
|
gem 'a', '= 2'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue