Import rubygems 1.5.0 (release candidate @ 09893d9)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ryan 2011-01-28 23:46:47 +00:00
Родитель b511e1bfbe
Коммит 934f537b45
87 изменённых файлов: 570 добавлений и 331 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Sat Jan 29 08:43:23 2011 Ryan Davis <ryand-ruby@zenspider.com>
* lib/rubygems*: Import rubygems 1.5.0 (release candidate @ 09893d9)
* test/rubygems: Ditto
Sat Jan 29 02:02:37 2011 Yusuke Endoh <mame@tsg.ne.jp>
* variable.c (rb_mod_const_of, sv_i): Module#constant should exclude
@ -32,7 +37,7 @@ Sat Jan 29 01:19:17 2011 Yusuke Endoh <mame@tsg.ne.jp>
rb_public_const_get_* and rb_public_const_defined_* are introduced,
which raise an exception when the referring constant is private.
see [ruby-core:32912].
* vm_insnhelper.c (vm_get_ev_const): use rb_public_const_get_* instead
of rb_const_get_* to follow the constant visibility when user code
refers a constant.

Просмотреть файл

@ -1,3 +1,9 @@
######################################################################
# This file is imported from the rubygems project.
# DO NOT make modifications in this repo. They _will_ be reverted!
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
# -*- ruby -*-
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
@ -5,15 +11,20 @@
# See LICENSE.txt for permissions.
#++
# TODO: remove when 1.9.1 no longer supported
QUICKLOADER_SUCKAGE = RUBY_VERSION >= "1.9.1" and RUBY_VERSION < "1.9.2"
# TODO: remove when 1.9.2 no longer supported
GEM_PRELUDE_SUCKAGE = RUBY_VERSION >= "1.9.2" and RUBY_VERSION < "1.9.3"
module Gem
QUICKLOADER_SUCKAGE = RUBY_VERSION =~ /^1\.9\.1/
GEM_PRELUDE_SUCKAGE = RUBY_VERSION =~ /^1\.9\.2/
end
gem_preluded = GEM_PRELUDE_SUCKAGE and defined? Gem
if Gem::GEM_PRELUDE_SUCKAGE and defined?(Gem::QuickLoader) then
Gem::QuickLoader.remove
if GEM_PRELUDE_SUCKAGE and defined?(Gem::QuickLoader) then
Gem::QuickLoader.load_full_rubygems_library
$LOADED_FEATURES.delete Gem::QuickLoader.path_to_full_rubygems_library
if $LOADED_FEATURES.any? do |path| path.end_with? '/rubygems.rb' end then
# TODO path does not exist here
raise LoadError, "another rubygems is already loaded from #{path}"
end
class << Gem
remove_method :try_activate if Gem.respond_to?(:try_activate, true)
@ -1165,7 +1176,7 @@ end
module Kernel
remove_method :gem if respond_to? :gem # defined in gem_prelude.rb on 1.9
remove_method :gem if 'method' == defined? gem # from gem_prelude.rb on 1.9
##
# Use Kernel#gem to activate a specific version of +gem_name+.
@ -1217,6 +1228,7 @@ end
require 'rubygems/exceptions'
gem_preluded = Gem::GEM_PRELUDE_SUCKAGE and defined? Gem
unless gem_preluded then # TODO: remove guard after 1.9.2 dropped
begin
##
@ -1240,7 +1252,7 @@ end
##
# Enables the require hook for RubyGems.
require 'rubygems/custom_require'
require 'rubygems/custom_require' unless Gem::GEM_PRELUDE_SUCKAGE
Gem.clear_paths

Просмотреть файл

@ -19,7 +19,7 @@ class Gem::Commands::EnvironmentCommand < Gem::Command
gempath display path used to search for gems
version display the gem format version
remotesources display the remote gem servers
platform display the supporte gem platforms
platform display the supported gem platforms
<omitted> display everything
EOF
return args.gsub(/^\s+/, '')
@ -48,7 +48,7 @@ Example:
install: --no-wrappers
update: --no-wrappers
RubyGems' default local repository can be overriden with the GEM_PATH and
RubyGems' default local repository can be overridden with the GEM_PATH and
GEM_HOME environment variables. GEM_HOME sets the default repository to
install into. GEM_PATH allows multiple local repositories to be searched for
gems.
@ -126,7 +126,7 @@ lib/rubygems/defaults/operating_system.rb
end
else
raise Gem::CommandLineError, "Unknown enviroment option [#{arg}]"
raise Gem::CommandLineError, "Unknown environment option [#{arg}]"
end
say out
true

Просмотреть файл

@ -56,7 +56,7 @@ class Gem::Dependency
@type = type
@prerelease = false
# This is for Marshal backwards compatability. See the comments in
# This is for Marshal backwards compatibility. See the comments in
# +requirement+ for the dirty details.
@version_requirements = @requirement

Просмотреть файл

@ -84,7 +84,7 @@ class Gem::DependencyInstaller
##
# Returns a list of pairs of gemspecs and source_uris that match
# Gem::Dependency +dep+ from both local (Dir.pwd) and remote (Gem.sources)
# sources. Gems are sorted with newer gems prefered over older gems, and
# sources. Gems are sorted with newer gems preferred over older gems, and
# local gems preferred over remote gems.
def find_gems_with_sources(dep)

Просмотреть файл

@ -194,7 +194,9 @@ class Gem::DocManager
rescue Errno::EACCES => e
dirname = File.dirname e.message.split("-")[1].strip
raise Gem::FilePermissionError.new(dirname)
rescue RuntimeError => ex
rescue Interrupt => e
raise e
rescue Exception => ex
alert_error "While generating documentation for #{@spec.full_name}"
ui.errs.puts "... MESSAGE: #{ex}"
ui.errs.puts "... RDOC args: #{args.join(' ')}"

Просмотреть файл

@ -28,7 +28,7 @@ class Gem::Ext::Builder
File.open('Makefile', 'wb') {|f| f.print mf}
# try to find make program from Ruby configue arguments first
# try to find make program from Ruby configure arguments first
RbConfig::CONFIG['configure_args'] =~ /with-make-prog\=(\w+)/
make_program = $1 || ENV['make']
unless make_program then

Просмотреть файл

@ -25,8 +25,16 @@ class Gem::Ext::RakeBuilder < Gem::Ext::Builder
# Deal with possible spaces in the path, e.g. C:/Program Files
dest_path = '"' + dest_path + '"' if dest_path.include?(' ')
cmd = ENV['rake'] || "\"#{Gem.ruby}\" -rubygems #{Gem.bin_path('rake')}" rescue Gem.default_exec_format % 'rake'
cmd += " RUBYARCHDIR=#{dest_path} RUBYLIBDIR=#{dest_path}" # ENV is frozen
rake = ENV['rake']
rake ||= begin
"\"#{Gem.ruby}\" -rubygems #{Gem.bin_path('rake')}"
rescue Gem::Exception
end
rake ||= Gem.default_exec_format % 'rake'
cmd = "#{rake} RUBYARCHDIR=#{dest_path} RUBYLIBDIR=#{dest_path}" # ENV is frozen
run cmd, results

Просмотреть файл

@ -22,8 +22,6 @@ class Gem::Format
attr_accessor :file_entries
attr_accessor :gem_path
extend Gem::UserInteraction
##
# Constructs a Format representing the gem's data which came from +gem_path+

Просмотреть файл

@ -63,7 +63,7 @@ class Gem::Indexer
require 'tmpdir'
require 'zlib'
unless ''.respond_to? :to_xs then
unless defined?(Builder::XChar) then
raise "Gem::Indexer requires that the XML Builder library be installed:" \
"\n\tgem install builder"
end
@ -555,10 +555,18 @@ class Gem::Indexer
# Sanitize a single string.
def sanitize_string(string)
return string unless string
# HACK the #to_s is in here because RSpec has an Array of Arrays of
# Strings for authors. Need a way to disallow bad values on gempsec
# Strings for authors. Need a way to disallow bad values on gemspec
# generation. (Probably won't happen.)
string ? string.to_s.to_xs : string
string = string.to_s
begin
Builder::XChar.encode string
rescue NameError, NoMethodError
string.to_xs
end
end
##

Просмотреть файл

@ -14,6 +14,7 @@ require 'rubygems/format'
require 'rubygems/exceptions'
require 'rubygems/ext'
require 'rubygems/require_paths_builder'
require 'rubygems/user_interaction'
##
# The installer class processes RubyGem .gem files and installs the files
@ -44,7 +45,7 @@ class Gem::Installer
include Gem::UserInteraction
include Gem::RequirePathsBuilder if QUICKLOADER_SUCKAGE
include Gem::RequirePathsBuilder if Gem::QUICKLOADER_SUCKAGE
##
# The directory a gem's executables will be installed into
@ -176,7 +177,7 @@ class Gem::Installer
generate_bin
write_spec
write_require_paths_file_if_needed if QUICKLOADER_SUCKAGE
write_require_paths_file_if_needed if Gem::QUICKLOADER_SUCKAGE
# HACK remove? Isn't this done in multiple places?
cached_gem = File.join @gem_home, "cache", @gem.split(/\//).pop
@ -481,7 +482,6 @@ TEXT
def build_extensions
return if @spec.extensions.empty?
say "Building native extensions. This could take a while..."
start_dir = Dir.pwd
dest_path = File.join @gem_dir, @spec.require_paths.first
ran_rake = false # only run rake once
@ -502,29 +502,37 @@ TEXT
nil
end
extension_dir = begin
File.join @gem_dir, File.dirname(extension)
rescue TypeError # extension == nil
@gem_dir
end
begin
Dir.chdir File.join(@gem_dir, File.dirname(extension))
results = builder.build(extension, @gem_dir, dest_path, results)
say results.join("\n") if Gem.configuration.really_verbose
Dir.chdir extension_dir do
results = builder.build(extension, @gem_dir, dest_path, results)
say results.join("\n") if Gem.configuration.really_verbose
end
rescue
results = results.join "\n"
File.open('gem_make.out', 'wb') { |f| f.puts results }
gem_make_out = File.join extension_dir, 'gem_make.out'
open gem_make_out, 'wb' do |io| io.puts results end
message = <<-EOF
ERROR: Failed to build gem native extension.
#{results}
#{results}
Gem files will remain installed in #{@gem_dir} for inspection.
Results logged to #{File.join(Dir.pwd, 'gem_make.out')}
EOF
Results logged to #{gem_make_out}
EOF
raise ExtensionBuildError, message
ensure
Dir.chdir start_dir
end
end
end

Просмотреть файл

@ -4,28 +4,67 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/installer'
class Gem::Installer
##
# Available through requiring rubygems/installer_test_case
attr_accessor :gem_dir
##
# Available through requiring rubygems/installer_test_case
attr_writer :format
##
# Available through requiring rubygems/installer_test_case
attr_writer :gem_home
##
# Available through requiring rubygems/installer_test_case
attr_writer :env_shebang
##
# Available through requiring rubygems/installer_test_case
attr_writer :ignore_dependencies
##
# Available through requiring rubygems/installer_test_case
attr_writer :format_executable
##
# Available through requiring rubygems/installer_test_case
attr_writer :security_policy
##
# Available through requiring rubygems/installer_test_case
attr_writer :spec
##
# Available through requiring rubygems/installer_test_case
attr_writer :wrappers
end
class GemInstallerTestCase < RubyGemTestCase
##
# A test case for Gem::Installer.
class Gem::InstallerTestCase < Gem::TestCase
def setup
super
@spec = quick_gem 'a'
@gem = File.join @tempdir, @spec.file_name
@installer = util_installer @spec, @gem, @gemhome

Просмотреть файл

@ -7,7 +7,11 @@
require 'stringio'
require 'rubygems/user_interaction'
class MockGemUi < Gem::StreamUI
##
# This Gem::StreamUI subclass records input and output to StringIO for
# retrieval during tests.
class Gem::MockGemUi < Gem::StreamUI
class TermError < RuntimeError; end
module TTY

Просмотреть файл

@ -4,10 +4,13 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/package'
class TarTestCase < RubyGemTestCase
##
# A test case for Gem::Package::Tar* classes
class Gem::Package::TarTestCase < Gem::TestCase
def ASCIIZ(str, length)
str + "\0" * (length - str.length)

Просмотреть файл

@ -20,5 +20,5 @@ module Gem::RequirePathsBuilder
file.puts spec.bindir if spec.bindir
end
end
end if QUICKLOADER_SUCKAGE
end if Gem::QUICKLOADER_SUCKAGE

Просмотреть файл

@ -336,7 +336,7 @@ class Gem::Specification
end
##
# List of depedencies that will automatically be activated at runtime.
# List of dependencies that will automatically be activated at runtime.
def runtime_dependencies
dependencies.select { |d| d.type == :runtime || d.type == nil }

Просмотреть файл

@ -6,15 +6,19 @@
at_exit { $SAFE = 1 }
# $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
if defined? Gem::QuickLoader
Gem::QuickLoader.load_full_rubygems_library
else
require 'rubygems'
end
require 'fileutils'
begin
gem 'minitest'
rescue Gem::LoadError
end
require 'minitest/autorun'
require 'fileutils'
require 'tmpdir'
require 'uri'
require 'rubygems/package'
@ -35,44 +39,84 @@ end
require 'rdoc/rdoc'
require "test/rubygems/mockgemui"
require 'rubygems/mock_gem_ui'
module Gem
##
# Allows setting the gem path searcher. This method is available when
# requiring 'rubygems/test_case'
def self.searcher=(searcher)
@searcher = searcher
end
##
# Allows setting the default SourceIndex. This method is available when
# requiring 'rubygems/test_case'
def self.source_index=(si)
@@source_index = si
end
##
# Allows toggling Windows behavior. This method is available when requiring
# 'rubygems/test_case'
def self.win_platform=(val)
@@win_platform = val
end
##
# Allows setting path to ruby. This method is available when requiring
# 'rubygems/test_case'
def self.ruby= ruby
@ruby = ruby
end
##
# When rubygems/test_case is required the default user interaction is a
# MockGemUi.
module DefaultUserInteraction
@ui = MockGemUi.new
@ui = Gem::MockGemUi.new
end
end
class RubyGemTestCase < MiniTest::Unit::TestCase
##
# RubyGemTestCase provides a variety of methods for testing rubygems and
# gem-related behavior in a sandbox. Through RubyGemTestCase you can install
# and uninstall gems, fetch remote gems through a stub fetcher and be assured
# your normal set of gems is not affected.
#
# Tests are always run at a safe level of 1.
class Gem::TestCase < MiniTest::Unit::TestCase
include Gem::DefaultUserInteraction
undef_method :default_test if instance_methods.include? 'default_test' or
instance_methods.include? :default_test
##
# #setup prepares a sandboxed location to install gems. All installs are
# directed to a temporary directory. All install plugins are removed.
#
# If the +RUBY+ environment variable is set the given path is used for
# Gem::ruby. The local platform is set to <tt>i386-mswin32</tt> for Windows
# or <tt>i686-darwin8.10.1</tt> otherwise.
#
# If the +KEEP_FILES+ environment variable is set the files will not be
# removed from <tt>/tmp/test_rubygems_#{$$}.#{Time.now.to_i}</tt>.
def setup
super
@orig_gem_home = ENV['GEM_HOME']
@orig_gem_path = ENV['GEM_PATH']
@orig_gem_home = ENV['GEM_HOME']
@orig_gem_path = ENV['GEM_PATH']
@ui = MockGemUi.new
@ui = Gem::MockGemUi.new
tmpdir = nil
Dir.chdir Dir.tmpdir do tmpdir = Dir.pwd end # HACK OSX /private/tmp
if ENV['KEEP_FILES'] then
@ -125,10 +169,10 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
@marshal_version = "#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}"
@private_key = File.expand_path File.join(File.dirname(__FILE__),
'private_key.pem')
@public_cert = File.expand_path File.join(File.dirname(__FILE__),
'public_cert.pem')
@private_key = File.expand_path('../../../test/rubygems/private_key.pem',
__FILE__)
@public_cert = File.expand_path('../../../test/rubygems/public_cert.pem',
__FILE__)
Gem.post_build_hooks.clear
Gem.post_install_hooks.clear
@ -161,6 +205,10 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
@orig_LOAD_PATH = $LOAD_PATH.dup
end
##
# #teardown restores the process to its original state and removes the
# tempdir unless the +KEEP_FILES+ environment variable was set.
def teardown
$LOAD_PATH.replace @orig_LOAD_PATH
@ -188,27 +236,36 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
end
end
def install_gem gem
##
# Builds and installs the Gem::Specification +spec+
def install_gem spec
require 'rubygems/installer'
use_ui MockGemUi.new do
use_ui Gem::MockGemUi.new do
Dir.chdir @tempdir do
Gem::Builder.new(gem).build
Gem::Builder.new(spec).build
end
end
gem = File.join(@tempdir, gem.file_name).untaint
gem = File.join(@tempdir, spec.file_name).untaint
Gem::Installer.new(gem, :wrappers => true).install
end
def uninstall_gem gem
##
# Uninstalls the Gem::Specification +spec+
def uninstall_gem spec
require 'rubygems/uninstaller'
uninstaller = Gem::Uninstaller.new gem.name, :executables => true,
uninstaller = Gem::Uninstaller.new spec.name, :executables => true,
:user_install => true
uninstaller.uninstall
end
##
# Enables pretty-print for all tests
def mu_pp(obj)
s = ''
s = PP.pp obj, s
@ -216,33 +273,8 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
s.chomp
end
def prep_cache_files(lc)
@usr_si ||= Gem::SourceIndex.new
@usr_sice ||= Gem::SourceInfoCacheEntry.new @usr_si, 0
@sys_si ||= Gem::SourceIndex.new
@sys_sice ||= Gem::SourceInfoCacheEntry.new @sys_si, 0
latest_si = Gem::SourceIndex.new
latest_si.add_specs(*@sys_si.latest_specs)
latest_sys_sice = Gem::SourceInfoCacheEntry.new latest_si, 0
latest_si = Gem::SourceIndex.new
latest_si.add_specs(*@usr_si.latest_specs)
latest_usr_sice = Gem::SourceInfoCacheEntry.new latest_si, 0
[ [lc.system_cache_file, @sys_sice],
[lc.latest_system_cache_file, latest_sys_sice],
[lc.user_cache_file, @usr_sice],
[lc.latest_user_cache_file, latest_usr_sice],
].each do |filename, data|
FileUtils.mkdir_p File.dirname(filename).untaint
open filename.dup.untaint, 'wb' do |f|
f.write Marshal.dump({ @gem_repo => data })
end
end
end
##
# Reads a Marshal file at +path+
def read_cache(path)
open path.dup.untaint, 'rb' do |io|
@ -250,28 +282,45 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
end
end
##
# Reads a binary file at +path+
def read_binary(path)
Gem.read_binary path
end
##
# Writes a binary file to +path+ which is relative to +@gemhome+
def write_file(path)
path = File.join(@gemhome, path)
path = File.join @gemhome, path
dir = File.dirname path
FileUtils.mkdir_p dir
open path, 'wb' do |io|
yield io
yield io if block_given?
end
path
end
def quick_gem(gemname, version='2')
##
# Creates a Gem::Specification with a minimum of extra work. +name+ and
# +version+ are the gem's name and version, platform, author, email,
# homepage, summary and description are defaulted. The specification is
# yielded for customization.
#
# The gem is added to the installed gems in +@gemhome+ and to the current
# source_index.
#
# Use this with #write_file to build an installed gem.
def quick_gem(name, version='2')
require 'rubygems/specification'
spec = Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = gemname
s.name = name
s.version = version
s.author = 'A User'
s.email = 'example@example.com'
@ -295,6 +344,10 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
return spec
end
##
# Builds a gem from +spec+ and places it in <tt>File.join @gemhome,
# 'cache'</tt>. Automatically creates files based on +spec.files+
def util_build_gem(spec)
dir = File.join(@gemhome, 'gems', spec.full_name)
FileUtils.mkdir_p dir
@ -306,7 +359,7 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
File.open file, 'w' do |fp| fp.puts "# #{file}" end
end
use_ui MockGemUi.new do
use_ui Gem::MockGemUi.new do
Gem::Builder.new(spec).build
end
@ -315,14 +368,23 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
end
end
##
# Removes all installed gems from +@gemhome+.
def util_clear_gems
FileUtils.rm_r File.join(@gemhome, 'gems')
FileUtils.rm_r File.join(@gemhome, 'specifications')
Gem.source_index.refresh!
end
##
# Creates a gem with +name+, +version+ and +deps+. The specification will
# be yielded before gem creation for customization. The gem will be placed
# in <tt>File.join @tempdir, 'gems'</tt>. The specification and .gem file
# location are returned.
def util_gem(name, version, deps = nil, &block)
if deps then # fuck you eric
if deps then
block = proc do |s|
deps.each do |n, req|
s.add_dependency n, (req || '>= 0')
@ -345,6 +407,9 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
[spec, cache_file]
end
##
# Gzips +data+.
def util_gzip(data)
out = StringIO.new
@ -355,6 +420,23 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
out.string
end
##
# Creates several default gems which all have a lib/code.rb file. The gems
# are not installed but are available in the cache dir.
#
# +@a1+:: gem a version 1, this is the best-described gem.
# +@a2+:: gem a version 2
# +@a3a:: gem a version 3.a
# +@a_evil9+:: gem a_evil version 9, use this to ensure similarly-named gems
# don't collide with a.
# +@b2+:: gem b version 2
# +@c1_2+:: gem c version 1.2
# +@pl1+:: gem pl version 1, this gem has a legacy platform of i386-linux.
#
# Additional +prerelease+ gems may also be created:
#
# +@a2_pre+:: gem a version 2.a
def util_make_gems(prerelease = false)
@a1 = quick_gem 'a', '1' do |s|
s.files = %w[lib/code.rb]
@ -391,17 +473,16 @@ Also, a list:
if prerelease
@a2_pre = quick_gem('a', '2.a', &init)
write_file File.join(*%W[gems #{@a2_pre.original_name} lib code.rb]) do
end
write_file File.join(*%W[gems #{@a2_pre.original_name} lib code.rb])
util_build_gem @a2_pre
end
write_file File.join(*%W[gems #{@a1.original_name} lib code.rb]) do end
write_file File.join(*%W[gems #{@a2.original_name} lib code.rb]) do end
write_file File.join(*%W[gems #{@a3a.original_name} lib code.rb]) do end
write_file File.join(*%W[gems #{@b2.original_name} lib code.rb]) do end
write_file File.join(*%W[gems #{@c1_2.original_name} lib code.rb]) do end
write_file File.join(*%W[gems #{@pl1.original_name} lib code.rb]) do end
write_file File.join(*%W[gems #{@a1.original_name} lib code.rb])
write_file File.join(*%W[gems #{@a2.original_name} lib code.rb])
write_file File.join(*%W[gems #{@a3a.original_name} lib code.rb])
write_file File.join(*%W[gems #{@b2.original_name} lib code.rb])
write_file File.join(*%W[gems #{@c1_2.original_name} lib code.rb])
write_file File.join(*%W[gems #{@pl1.original_name} lib code.rb])
[@a1, @a2, @a3a, @a_evil9, @b2, @c1_2, @pl1].each do |spec|
util_build_gem spec
@ -425,6 +506,12 @@ Also, a list:
platform
end
##
# Sets up a fake fetcher using the gems from #util_make_gems. Optionally
# additional +prerelease+ gems may be included.
#
# Gems created by this method may be fetched using Gem::RemoteFetcher.
def util_setup_fake_fetcher(prerelease = false)
require 'zlib'
require 'socket'
@ -451,6 +538,10 @@ Also, a list:
Gem::RemoteFetcher.fetcher = @fetcher
end
##
# Sets up Gem::SpecFetcher to return information from the gems in +specs+.
# Best used with +@all_gems+ from #util_setup_fake_fetcher.
def util_setup_spec_fetcher(*specs)
specs = Hash[*specs.map { |spec| [spec.full_name, spec] }.flatten]
si = Gem::SourceIndex.new specs
@ -485,65 +576,87 @@ Also, a list:
si
end
##
# Deflates +data+
def util_zip(data)
Zlib::Deflate.deflate data
end
##
# Is this test being run on a Windows platform?
def self.win_platform?
Gem.win_platform?
end
##
# Is this test being run on a Windows platform?
def win_platform?
Gem.win_platform?
end
##
# Returns whether or not we're on a version of Ruby built with VC++ (or
# Borland) versus Cygwin, Mingw, etc.
#
def self.vc_windows?
RUBY_PLATFORM.match('mswin')
end
##
# Returns whether or not we're on a version of Ruby built with VC++ (or
# Borland) versus Cygwin, Mingw, etc.
#
def vc_windows?
RUBY_PLATFORM.match('mswin')
end
##
# Returns the make command for the current platform. For versions of Ruby
# built on MS Windows with VC++ or Borland it will return 'nmake'. On all
# other platforms, including Cygwin, it will return 'make'.
#
def self.make_command
ENV["make"] || (vc_windows? ? 'nmake' : 'make')
end
##
# Returns the make command for the current platform. For versions of Ruby
# built on MS Windows with VC++ or Borland it will return 'nmake'. On all
# other platforms, including Cygwin, it will return 'make'.
#
def make_command
ENV["make"] || (vc_windows? ? 'nmake' : 'make')
end
##
# Returns whether or not the nmake command could be found.
#
def nmake_found?
system('nmake /? 1>NUL 2>&1')
end
# NOTE Allow tests to use a random (but controlled) port number instead of
##
# Allows tests to use a random (but controlled) port number instead of
# a hardcoded one. This helps CI tools when running parallels builds on
# the same builder slave.
def self.process_based_port
@@process_based_port ||= 8000 + $$ % 1000
end
##
# See ::process_based_port
def process_based_port
self.class.process_based_port
end
##
# Allows the proper version of +rake+ to be used for the test.
def build_rake_in
gem_ruby = Gem.ruby
Gem.ruby = @@ruby
@ -559,6 +672,9 @@ Also, a list:
end
end
##
# Finds the path to the ruby executable
def self.rubybin
ruby = ENV["RUBY"]
return ruby if ruby
@ -604,7 +720,7 @@ Also, a list:
end
##
# Construct a new Gem::Requirement.
# Constructs a new Gem::Requirement.
def req *requirements
return requirements.first if Gem::Requirement === requirements.first
@ -612,7 +728,7 @@ Also, a list:
end
##
# Construct a new Gem::Specification.
# Constructs a new Gem::Specification.
def spec name, version, &block
Gem::Specification.new name, v(version), &block

Просмотреть файл

@ -127,43 +127,42 @@ class Gem::Uninstaller
# +gemspec+.
def remove_executables(spec)
return if spec.nil?
return if spec.nil? or spec.executables.empty?
unless spec.executables.empty? then
bindir = @bin_dir ? @bin_dir : Gem.bindir(spec.installation_path)
bindir = @bin_dir ? @bin_dir : Gem.bindir(spec.installation_path)
list = @source_index.find_name(spec.name).delete_if { |s|
s.version == spec.version
}
list = @source_index.find_name(spec.name).delete_if { |s|
s.version == spec.version
}
executables = spec.executables.clone
executables = spec.executables.clone
list.each do |s|
s.executables.each do |exe_name|
executables.delete exe_name
end
list.each do |s|
s.executables.each do |exe_name|
executables.delete exe_name
end
end
return if executables.empty?
return if executables.empty?
answer = if @force_executables.nil? then
ask_yes_no("Remove executables:\n" \
"\t#{spec.executables.join(", ")}\n\nin addition to the gem?",
true) # " # appease ruby-mode - don't ask
else
@force_executables
end
remove = if @force_executables.nil? then
ask_yes_no("Remove executables:\n" \
"\t#{spec.executables.join ', '}\n\n" \
"in addition to the gem?",
true)
else
@force_executables
end
unless answer then
say "Executables and scripts will remain installed."
else
raise Gem::FilePermissionError, bindir unless File.writable? bindir
unless remove then
say "Executables and scripts will remain installed."
else
raise Gem::FilePermissionError, bindir unless File.writable? bindir
spec.executables.each do |exe_name|
say "Removing #{exe_name}"
FileUtils.rm_f File.join(bindir, exe_name)
FileUtils.rm_f File.join(bindir, "#{exe_name}.bat")
end
spec.executables.each do |exe_name|
say "Removing #{exe_name}"
FileUtils.rm_f File.join(bindir, exe_name)
FileUtils.rm_f File.join(bindir, "#{exe_name}.bat")
end
end
end

Просмотреть файл

@ -72,7 +72,7 @@ module Gem::DefaultUserInteraction
end
##
# Make the default UI accessable without the "ui." prefix. Classes
# Make the default UI accessible without the "ui." prefix. Classes
# including this module may use the interaction methods on the default UI
# directly. Classes may also reference the ui and ui= methods.
#
@ -224,7 +224,7 @@ class Gem::StreamUI
result
end
if RUBY_VERSION >= "1.9" then
if RUBY_VERSION > '1.9.2' then
##
# Ask for a password. Does not echo response to terminal.
@ -477,12 +477,20 @@ class Gem::StreamUI
end
def fetch(file_name, total_bytes)
@file_name, @total_bytes = file_name, total_bytes
@file_name = file_name
@total_bytes = total_bytes.to_i
@units = @total_bytes.zero? ? 'B' : '%'
update_display(false)
end
def update(bytes)
new_progress = ((bytes.to_f * 100) / total_bytes.to_f).ceil
new_progress = if @units == 'B' then
bytes
else
((bytes.to_f * 100) / total_bytes.to_f).ceil
end
return if new_progress == @progress
@progress = new_progress
@ -490,7 +498,7 @@ class Gem::StreamUI
end
def done
@progress = 100
@progress = 100 if @units == '%'
update_display(true, true)
end
@ -498,8 +506,9 @@ class Gem::StreamUI
def update_display(show_progress = true, new_line = false)
return unless @out.tty?
if show_progress
@out.print "\rFetching: %s (%3d%%)" % [@file_name, @progress]
if show_progress then
@out.print "\rFetching: %s (%3d%s)" % [@file_name, @progress, @units]
else
@out.print "Fetching: %s" % @file_name
end

Просмотреть файл

@ -5,7 +5,7 @@
######################################################################
SIMPLE_GEM = <<-GEMDATA
MD5SUM = "b12a4d48febeb2289c539c2574c4b6f8"
MD5SUM = "989bf34a1cbecd52e0ea66b662b3a405"
if $0 == __FILE__
require 'optparse'
@ -13,7 +13,7 @@ SIMPLE_GEM = <<-GEMDATA
ARGV.options do |opts|
opts.on_tail("--help", "show this message") {puts opts; exit}
opts.on('--dir=DIRNAME', "Installation directory for the Gem") {|options[:directory]|}
opts.on('--force', "Force Gem to intall, bypassing dependency checks") {|options[:force]|}
opts.on('--force', "Force Gem to install, bypassing dependency checks") {|options[:force]|}
opts.on('--gen-rdoc', "Generate RDoc documentation for the Gem") {|options[:gen_rdoc]|}
opts.parse!
end

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems'
class TestConfig < RubyGemTestCase
class TestConfig < Gem::TestCase
def test_datadir
_, err = capture_io do

Просмотреть файл

@ -4,14 +4,14 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems'
require 'rubygems/gem_openssl'
require 'rubygems/installer'
require 'pathname'
require 'tmpdir'
class TestGem < RubyGemTestCase
class TestGem < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/builder'
class TestGemBuilder < RubyGemTestCase
class TestGemBuilder < Gem::TestCase
def test_build
builder = Gem::Builder.new quick_gem('a')

Просмотреть файл

@ -4,14 +4,14 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/command'
class Gem::Command
public :parser
end
class TestGemCommand < RubyGemTestCase
class TestGemCommand < Gem::TestCase
def setup
super
@ -93,7 +93,7 @@ class TestGemCommand < RubyGemTestCase
assert done
end
def test_invode_with_bad_options
def test_invoke_with_bad_options
use_ui @ui do
@cmd.when_invoked do true end

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/command_manager'
class TestGemCommandManager < RubyGemTestCase
class TestGemCommandManager < Gem::TestCase
def setup
super
@ -21,7 +21,7 @@ class TestGemCommandManager < RubyGemTestCase
Gem.load_env_plugins
use_ui @ui do
assert_raises MockGemUi::TermError do
assert_raises Gem::MockGemUi::TermError do
@command_manager.run 'interrupt'
end
assert_equal '', ui.output
@ -37,7 +37,7 @@ class TestGemCommandManager < RubyGemTestCase
@command_manager.register_command :crash
use_ui @ui do
assert_raises MockGemUi::TermError do
assert_raises Gem::MockGemUi::TermError do
@command_manager.run 'crash'
end
assert_equal '', ui.output
@ -50,9 +50,9 @@ class TestGemCommandManager < RubyGemTestCase
def test_process_args_bad_arg
use_ui @ui do
assert_raises(MockGemUi::TermError) {
assert_raises Gem::MockGemUi::TermError do
@command_manager.process_args("--bad-arg")
}
end
end
assert_match(/invalid option: --bad-arg/i, @ui.error)

Просмотреть файл

@ -4,11 +4,11 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/build_command'
require 'rubygems/format'
class TestGemCommandsBuildCommand < RubyGemTestCase
class TestGemCommandsBuildCommand < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,14 +4,14 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/cert_command'
unless defined? OpenSSL then
warn "`gem cert` tests are being skipped, module OpenSSL not found"
end
class TestGemCommandsCertCommand < RubyGemTestCase
class TestGemCommandsCertCommand < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/check_command'
class TestGemCommandsCheckCommand < RubyGemTestCase
class TestGemCommandsCheckCommand < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/contents_command'
class TestGemCommandsContentsCommand < RubyGemTestCase
class TestGemCommandsContentsCommand < Gem::TestCase
def setup
super
@ -54,7 +54,7 @@ class TestGemCommandsContentsCommand < RubyGemTestCase
def test_execute_bad_gem
@cmd.options[:args] = %w[foo]
assert_raises MockGemUi::TermError do
assert_raises Gem::MockGemUi::TermError do
use_ui @ui do
@cmd.execute
end

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/dependency_command'
class TestGemCommandsDependencyCommand < RubyGemTestCase
class TestGemCommandsDependencyCommand < Gem::TestCase
def setup
super
@ -72,7 +72,7 @@ Gem pl-1-x86-linux
def test_execute_no_match
@cmd.options[:args] = %w[foo]
assert_raises MockGemUi::TermError do
assert_raises Gem::MockGemUi::TermError do
use_ui @ui do
@cmd.execute
end
@ -161,7 +161,7 @@ Gem foo-2
@cmd.options[:reverse_dependencies] = true
@cmd.options[:domain] = :remote
assert_raises MockGemUi::TermError do
assert_raises Gem::MockGemUi::TermError do
use_ui @ui do
@cmd.execute
end

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/environment_command'
class TestGemCommandsEnvironmentCommand < RubyGemTestCase
class TestGemCommandsEnvironmentCommand < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,12 +4,12 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/package'
require 'rubygems/security'
require 'rubygems/commands/fetch_command'
class TestGemCommandsFetchCommand < RubyGemTestCase
class TestGemCommandsFetchCommand < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,11 +4,11 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/indexer'
require 'rubygems/commands/generate_index_command'
class TestGemCommandsGenerateIndexCommand < RubyGemTestCase
class TestGemCommandsGenerateIndexCommand < Gem::TestCase
def setup
super
@ -35,7 +35,7 @@ class TestGemCommandsGenerateIndexCommand < RubyGemTestCase
@cmd.options[:rss_gems_host] = 'gems.example.com'
use_ui @ui do
assert_raises MockGemUi::TermError do
assert_raises Gem::MockGemUi::TermError do
@cmd.execute
end
end

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/install_command'
class TestGemCommandsInstallCommand < RubyGemTestCase
class TestGemCommandsInstallCommand < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/list_command'
class TestGemCommandsListCommand < RubyGemTestCase
class TestGemCommandsListCommand < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/lock_command'
class TestGemCommandsLockCommand < RubyGemTestCase
class TestGemCommandsLockCommand < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/outdated_command'
class TestGemCommandsOutdatedCommand < RubyGemTestCase
class TestGemCommandsOutdatedCommand < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/owner_command'
class TestGemCommandsOwnerCommand < RubyGemTestCase
class TestGemCommandsOwnerCommand < Gem::TestCase
def setup
super
@ -44,7 +44,7 @@ EOF
response = "You don't have permission to push to this gem"
@fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 403, 'Forbidden']
assert_raises MockGemUi::TermError do
assert_raises Gem::MockGemUi::TermError do
use_ui @ui do
@cmd.show_owners("freewill")
end
@ -72,7 +72,7 @@ EOF
response = "You don't have permission to push to this gem"
@fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 403, 'Forbidden']
assert_raises MockGemUi::TermError do
assert_raises Gem::MockGemUi::TermError do
use_ui @ui do
@cmd.add_owners("freewill", ["user-new1@example.com"])
end
@ -100,7 +100,7 @@ EOF
response = "You don't have permission to push to this gem"
@fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 403, 'Forbidden']
assert_raises MockGemUi::TermError do
assert_raises Gem::MockGemUi::TermError do
use_ui @ui do
@cmd.remove_owners("freewill", ["user-remove1@example.com"])
end

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/pristine_command'
class TestGemCommandsPristineCommand < RubyGemTestCase
class TestGemCommandsPristineCommand < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/push_command'
class TestGemCommandsPushCommand < RubyGemTestCase
class TestGemCommandsPushCommand < Gem::TestCase
def setup
super
@ -74,7 +74,7 @@ class TestGemCommandsPushCommand < RubyGemTestCase
response = "You don't have permission to push to this gem"
@fetcher.data["#{Gem.host}/api/v1/gems"] = [response, 403, 'Forbidden']
assert_raises MockGemUi::TermError do
assert_raises Gem::MockGemUi::TermError do
use_ui @ui do
@cmd.send_gem(@path)
end

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/query_command'
class TestGemCommandsQueryCommand < RubyGemTestCase
class TestGemCommandsQueryCommand < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/server_command'
class TestGemCommandsServerCommand < RubyGemTestCase
class TestGemCommandsServerCommand < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/sources_command'
class TestGemCommandsSourcesCommand < RubyGemTestCase
class TestGemCommandsSourcesCommand < Gem::TestCase
def setup
super
@ -90,7 +90,7 @@ class TestGemCommandsSourcesCommand < RubyGemTestCase
util_setup_spec_fetcher
use_ui @ui do
assert_raises MockGemUi::TermError do
assert_raises Gem::MockGemUi::TermError do
@cmd.execute
end
end
@ -110,7 +110,7 @@ Error fetching http://beta-gems.example.com:
util_setup_spec_fetcher
use_ui @ui do
assert_raises MockGemUi::TermError do
assert_raises Gem::MockGemUi::TermError do
@cmd.execute
end
end

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/specification_command'
class TestGemCommandsSpecificationCommand < RubyGemTestCase
class TestGemCommandsSpecificationCommand < Gem::TestCase
def setup
super
@ -51,7 +51,7 @@ class TestGemCommandsSpecificationCommand < RubyGemTestCase
def test_execute_bad_name
@cmd.options[:args] = %w[foo]
assert_raises MockGemUi::TermError do
assert_raises Gem::MockGemUi::TermError do
use_ui @ui do
@cmd.execute
end

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/stale_command'
class TestGemCommandsStaleCommand < RubyGemTestCase
class TestGemCommandsStaleCommand < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,20 +4,16 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require "test/rubygems/gem_installer_test_case"
require 'rubygems/installer_test_case'
require 'rubygems/commands/uninstall_command'
class TestGemCommandsUninstallCommand < GemInstallerTestCase
class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
def setup
super
ui = MockGemUi.new
util_setup_gem ui
build_rake_in do
use_ui ui do
use_ui @ui do
@installer.install
end
end
@ -28,15 +24,25 @@ class TestGemCommandsUninstallCommand < GemInstallerTestCase
end
def test_execute_removes_executable
ui = Gem::MockGemUi.new
util_setup_gem ui
build_rake_in do
use_ui ui do
@installer.install
end
end
if win_platform?
assert_equal true, File.exist?(@executable)
assert File.exist?(@executable)
else
assert_equal true, File.symlink?(@executable)
assert File.symlink?(@executable)
end
# Evil hack to prevent false removal success
FileUtils.rm_f @executable
File.open(@executable, "wb+") {|f| f.puts "binary"}
open(@executable, "wb+") {|f| f.puts "binary"}
@cmd.options[:args] = Array(@spec.name)
use_ui @ui do

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/unpack_command'
class TestGemCommandsUnpackCommand < RubyGemTestCase
class TestGemCommandsUnpackCommand < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/update_command'
class TestGemCommandsUpdateCommand < RubyGemTestCase
class TestGemCommandsUpdateCommand < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/commands/which_command'
class TestGemCommandsWhichCommand < RubyGemTestCase
class TestGemCommandsWhichCommand < Gem::TestCase
def setup
super
@ -45,7 +45,7 @@ class TestGemCommandsWhichCommand < RubyGemTestCase
@cmd.handle_options %w[missing]
use_ui @ui do
assert_raises MockGemUi::TermError do
assert_raises Gem::MockGemUi::TermError do
@cmd.execute
end
end

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/config_file'
class TestGemConfigFile < RubyGemTestCase
class TestGemConfigFile < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/dependency'
class TestGemDependency < RubyGemTestCase
class TestGemDependency < Gem::TestCase
def test_initialize
d = dep "pkg", "> 1.0"
@ -64,7 +64,7 @@ class TestGemDependency < RubyGemTestCase
def test_equals_tilde
d = dep "a", "0"
assert_match d, d, "matche self"
assert_match d, d, "match self"
assert_match dep("a", ">= 0"), d, "match version exact"
assert_match dep("a", ">= 0"), dep("a", "1"), "match version"
assert_match dep(/a/, ">= 0"), d, "match simple regexp"

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/dependency_installer'
class TestGemDependencyInstaller < RubyGemTestCase
class TestGemDependencyInstaller < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/dependency_list'
class TestGemDependencyList < RubyGemTestCase
class TestGemDependencyList < Gem::TestCase
def setup
super
@ -110,7 +110,7 @@ class TestGemDependencyList < RubyGemTestCase
'deps of trimmed specs not included'
end
def test_dependency_order_no_dependendencies
def test_dependency_order_no_dependencies
@deplist.add @a1, @c2
order = @deplist.dependency_order

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/doc_manager'
class TestGemDocManager < RubyGemTestCase
class TestGemDocManager < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/ext'
class TestGemExtConfigureBuilder < RubyGemTestCase
class TestGemExtConfigureBuilder < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/ext'
class TestGemExtExtConfBuilder < RubyGemTestCase
class TestGemExtExtConfBuilder < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/ext'
class TestGemExtRakeBuilder < RubyGemTestCase
class TestGemExtRakeBuilder < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,11 +4,11 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require "test/rubygems/simple_gem"
require 'rubygems/format'
class TestGemFormat < RubyGemTestCase
class TestGemFormat < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,7 +4,7 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/gem_path_searcher'
class Gem::GemPathSearcher
@ -12,7 +12,7 @@ class Gem::GemPathSearcher
attr_accessor :lib_dirs
end
class TestGemGemPathSearcher < RubyGemTestCase
class TestGemGemPathSearcher < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/gem_runner'
class TestGemGemRunner < RubyGemTestCase
class TestGemGemRunner < Gem::TestCase
def test_do_configuration
Gem.clear_paths

Просмотреть файл

@ -4,11 +4,11 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems'
require 'rubygems/gemcutter_utilities'
class TestGemGemcutterUtilities < RubyGemTestCase
class TestGemGemcutterUtilities < Gem::TestCase
def setup
super
@ -74,7 +74,7 @@ class TestGemGemcutterUtilities < RubyGemTestCase
def test_sign_in_with_bad_credentials
skip 'Always uses $stdin on windows' if Gem.win_platform?
assert_raises MockGemUi::TermError do
assert_raises Gem::MockGemUi::TermError do
util_sign_in ['Access Denied.', 403, 'Forbidden']
end
@ -98,7 +98,7 @@ class TestGemGemcutterUtilities < RubyGemTestCase
@fetcher.data["#{host}/api/v1/api_key"] = response
Gem::RemoteFetcher.fetcher = @fetcher
@sign_in_ui = MockGemUi.new "#{email}\n#{password}\n"
@sign_in_ui = Gem::MockGemUi.new "#{email}\n#{password}\n"
use_ui @sign_in_ui do
@cmd.sign_in

Просмотреть файл

@ -4,14 +4,14 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/indexer'
unless ''.respond_to? :to_xs then
unless defined?(Builder::XChar) then
warn "Gem::Indexer tests are being skipped. Install builder gem." if $VERBOSE
end
class TestGemIndexer < RubyGemTestCase
class TestGemIndexer < Gem::TestCase
def setup
super
@ -558,5 +558,5 @@ eighty characters.&lt;/pre&gt;
refute File.exist?(file), "#{file} exists"
end
end if ''.respond_to? :to_xs
end if defined?(Builder::XChar)

Просмотреть файл

@ -4,11 +4,11 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gem_installer_test_case"
require 'rubygems/installer_test_case'
require 'rubygems/install_update_options'
require 'rubygems/command'
class TestGemInstallUpdateOptions < GemInstallerTestCase
class TestGemInstallUpdateOptions < Gem::InstallerTestCase
def setup
super

Просмотреть файл

@ -4,9 +4,9 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gem_installer_test_case"
require 'rubygems/installer_test_case'
class TestGemInstaller < GemInstallerTestCase
class TestGemInstaller < Gem::InstallerTestCase
def test_app_script_text
util_make_exec '2', ''
@ -72,6 +72,7 @@ load Gem.bin_path('a', 'my_exec', version)
end
def test_build_extensions_unsupported
gem_make_out = File.join @gemhome, 'gems', @spec.full_name, 'gem_make.out'
@spec.extensions << nil
e = assert_raises Gem::Installer::ExtensionBuildError do
@ -80,15 +81,15 @@ load Gem.bin_path('a', 'my_exec', version)
end
end
assert_match(/^No builder for extension ''$/, e.message)
assert_match(/^\s*No builder for extension ''$/, e.message)
assert_equal "Building native extensions. This could take a while...\n",
@ui.output
assert_equal '', @ui.error
assert_equal "No builder for extension ''\n", File.read('gem_make.out')
assert_equal "No builder for extension ''\n", File.read(gem_make_out)
ensure
FileUtils.rm_f 'gem_make.out'
FileUtils.rm_f gem_make_out
end
def test_ensure_dependency

Просмотреть файл

@ -4,11 +4,11 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/local_remote_options'
require 'rubygems/command'
class TestGemLocalRemoteOptions < RubyGemTestCase
class TestGemLocalRemoteOptions < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gem_package_tar_test_case"
require 'rubygems/package/tar_test_case'
require 'rubygems/package'
class TestGemPackageTarHeader < TarTestCase
class TestGemPackageTarHeader < Gem::Package::TarTestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gem_package_tar_test_case"
require 'rubygems/package/tar_test_case'
require 'rubygems/package/tar_input'
class TestGemPackageTarInput < TarTestCase
class TestGemPackageTarInput < Gem::Package::TarTestCase
# Sometimes the setgid bit doesn't take. Don't know if this is a problem on
# all systems, or just some. But for now, we will ignore it in the tests.

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gem_package_tar_test_case"
require 'rubygems/package/tar_test_case'
require 'rubygems/package/tar_output'
class TestGemPackageTarOutput < TarTestCase
class TestGemPackageTarOutput < Gem::Package::TarTestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gem_package_tar_test_case"
require 'rubygems/package/tar_test_case'
require 'rubygems/package'
class TestGemPackageTarReader < TarTestCase
class TestGemPackageTarReader < Gem::Package::TarTestCase
def test_each_entry
tar = tar_dir_header "foo", "bar", 0

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gem_package_tar_test_case"
require 'rubygems/package/tar_test_case'
require 'rubygems/package'
class TestGemPackageTarReaderEntry < TarTestCase
class TestGemPackageTarReaderEntry < Gem::Package::TarTestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gem_package_tar_test_case"
require 'rubygems/package/tar_test_case'
require 'rubygems/package/tar_writer'
class TestTarWriter < TarTestCase
class TestTarWriter < Gem::Package::TarTestCase
def setup
super

Просмотреть файл

@ -4,11 +4,11 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems'
require 'rubygems/package_task'
class TestGemPackageTask < RubyGemTestCase
class TestGemPackageTask < Gem::TestCase
def test_gem_package
gem = Gem::Specification.new do |g|

Просмотреть файл

@ -4,11 +4,11 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/platform'
require 'rbconfig'
class TestGemPlatform < RubyGemTestCase
class TestGemPlatform < Gem::TestCase
def test_self_local
util_set_arch 'i686-darwin8.10.1'

Просмотреть файл

@ -4,7 +4,7 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'ostruct'
require 'webrick'
require 'rubygems/remote_fetcher'
@ -24,7 +24,7 @@ require 'rubygems/format'
# software doesn't really care, as long as we hit the proxy URL when a
# proxy is configured.
class TestGemRemoteFetcher < RubyGemTestCase
class TestGemRemoteFetcher < Gem::TestCase
include Gem::DefaultUserInteraction
@ -617,7 +617,7 @@ gems:
assert_equal '', response.body
end
def test_request_unmodifed
def test_request_unmodified
uri = URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}"
conn = util_stub_connection_for :body => '', :code => 304

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require "rubygems/requirement"
class TestGemRequirement < RubyGemTestCase
class TestGemRequirement < Gem::TestCase
def test_equals2
r = req "= 1.2"

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/security'
class TestGemSecurity < RubyGemTestCase
class TestGemSecurity < Gem::TestCase
def test_class_build_cert
name = OpenSSL::X509::Name.parse "CN=nobody/DC=example"

Просмотреть файл

@ -4,7 +4,7 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/server'
require 'stringio'
@ -13,7 +13,7 @@ class Gem::Server
attr_reader :server
end
class TestGemServer < RubyGemTestCase
class TestGemServer < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,11 +4,11 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/source_index'
require 'rubygems/config_file'
class TestGemSourceIndex < RubyGemTestCase
class TestGemSourceIndex < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/spec_fetcher'
class TestGemSpecFetcher < RubyGemTestCase
class TestGemSpecFetcher < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,11 +4,11 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'stringio'
require 'rubygems/specification'
class TestGemSpecification < RubyGemTestCase
class TestGemSpecification < Gem::TestCase
LEGACY_YAML_SPEC = <<-EOF
--- !ruby/object:Gem::Specification
@ -997,7 +997,7 @@ end
assert_equal "WARNING: no description specified\n", @ui.error, 'error'
@ui = MockGemUi.new
@ui = Gem::MockGemUi.new
@a1.summary = 'this is my summary'
@a1.description = @a1.summary
@ -1133,7 +1133,7 @@ end
assert_equal "WARNING: no homepage specified\n", @ui.error, 'error'
@ui = MockGemUi.new
@ui = Gem::MockGemUi.new
@a1.homepage = ''

Просмотреть файл

@ -4,11 +4,11 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/user_interaction'
require 'timeout'
class TestGemStreamUI < RubyGemTestCase
class TestGemStreamUI < Gem::TestCase
module IsTty
attr_accessor :tty
@ -199,6 +199,24 @@ class TestGemStreamUI < RubyGemTestCase
assert_equal "Fetching: a.gem\rFetching: a.gem ( 50%)\rFetching: a.gem (100%)\n", @out.string
end
def test_verbose_download_reporter_progress_nil_length
@cfg.verbose = true
reporter = @sui.download_reporter
reporter.fetch 'a.gem', nil
reporter.update 1024
reporter.done
assert_equal "Fetching: a.gem\rFetching: a.gem (1024B)\rFetching: a.gem (1024B)\n", @out.string
end
def test_verbose_download_reporter_progress_zero_length
@cfg.verbose = true
reporter = @sui.download_reporter
reporter.fetch 'a.gem', 0
reporter.update 1024
reporter.done
assert_equal "Fetching: a.gem\rFetching: a.gem (1024B)\rFetching: a.gem (1024B)\n", @out.string
end
def test_verbose_download_reporter_no_tty
@out.tty = false

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require "rubygems/text"
class TestGemText < RubyGemTestCase
class TestGemText < Gem::TestCase
include Gem::Text
def test_format_text

Просмотреть файл

@ -4,31 +4,28 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gem_installer_test_case"
require 'rubygems/installer_test_case'
require 'rubygems/uninstaller'
class TestGemUninstaller < GemInstallerTestCase
class TestGemUninstaller < Gem::InstallerTestCase
def setup
super
ui = MockGemUi.new
util_setup_gem ui
@user_spec.executables = ["my_exec"]
# HACK util_make_exec
user_bin_dir = File.join Gem.user_dir, 'gems', @user_spec.full_name, 'bin'
FileUtils.mkdir_p user_bin_dir
exec_path = File.join user_bin_dir, "my_exec"
File.open exec_path, 'w' do |f|
open exec_path, 'w' do |f|
f.puts "#!/usr/bin/ruby"
end
user_bin_dir = File.join Gem.user_dir, 'bin'
FileUtils.mkdir_p user_bin_dir
exec_path = File.join user_bin_dir, "my_exec"
File.open exec_path, 'w' do |f|
open exec_path, 'w' do |f|
f.puts "#!/usr/bin/ruby"
end
@ -50,11 +47,14 @@ class TestGemUninstaller < GemInstallerTestCase
def test_remove_executables_force_keep
uninstaller = Gem::Uninstaller.new nil, :executables => false
executable = File.join Gem.user_dir, 'bin', 'my_exec'
assert File.exist? executable
use_ui @ui do
uninstaller.remove_executables @spec
uninstaller.remove_executables @user_spec
end
assert_equal true, File.exist?(File.join(@gemhome, 'bin', 'executable'))
assert File.exist? executable
assert_equal "Executables and scripts will remain installed.\n", @ui.output
end
@ -62,13 +62,16 @@ class TestGemUninstaller < GemInstallerTestCase
def test_remove_executables_force_remove
uninstaller = Gem::Uninstaller.new nil, :executables => true
executable = File.join Gem.user_dir, 'bin', 'my_exec'
assert File.exist? executable
use_ui @ui do
uninstaller.remove_executables @spec
uninstaller.remove_executables @user_spec
end
assert_equal "Removing executable\n", @ui.output
assert_equal "Removing my_exec\n", @ui.output
assert_equal false, File.exist?(File.join(@gemhome, 'bin', 'executable'))
refute File.exist? executable
end
def test_remove_executables_user

Просмотреть файл

@ -4,11 +4,11 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require "test/rubygems/simple_gem"
require 'rubygems/validator'
class TestGemValidator < RubyGemTestCase
class TestGemValidator < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require "rubygems/version"
class TestGemVersion < RubyGemTestCase
class TestGemVersion < Gem::TestCase
def test_bump
assert_bumped_version_equal "5.3", "5.2.4"

Просмотреть файл

@ -4,11 +4,11 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
require 'rubygems/command'
require 'rubygems/version_option'
class TestGemVersionOption < RubyGemTestCase
class TestGemVersionOption < Gem::TestCase
def setup
super

Просмотреть файл

@ -4,9 +4,9 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require "test/rubygems/gemutilities"
require 'rubygems/test_case'
class TestKernel < RubyGemTestCase
class TestKernel < Gem::TestCase
def setup
super
@ -27,7 +27,7 @@ class TestKernel < RubyGemTestCase
assert $:.any? { |p| %r{a-1/lib} =~ p }
end
def test_gem_redundent
def test_gem_redundant
assert gem('a', '= 1'), "Should load"
refute gem('a', '= 1'), "Should not load"
assert_equal 1, $:.select { |p| %r{a-1/lib} =~ p }.size