1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
parent b511e1bfbe
commit 934f537b45
87 changed files with 570 additions and 331 deletions

View file

@ -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> 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 * variable.c (rb_mod_const_of, sv_i): Module#constant should exclude

View file

@ -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 -*- # -*- ruby -*-
#-- #--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
@ -5,15 +11,20 @@
# See LICENSE.txt for permissions. # See LICENSE.txt for permissions.
#++ #++
# TODO: remove when 1.9.1 no longer supported module Gem
QUICKLOADER_SUCKAGE = RUBY_VERSION >= "1.9.1" and RUBY_VERSION < "1.9.2" QUICKLOADER_SUCKAGE = RUBY_VERSION =~ /^1\.9\.1/
# TODO: remove when 1.9.2 no longer supported GEM_PRELUDE_SUCKAGE = RUBY_VERSION =~ /^1\.9\.2/
GEM_PRELUDE_SUCKAGE = RUBY_VERSION >= "1.9.2" and RUBY_VERSION < "1.9.3" 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 $LOADED_FEATURES.delete Gem::QuickLoader.path_to_full_rubygems_library
Gem::QuickLoader.load_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 class << Gem
remove_method :try_activate if Gem.respond_to?(:try_activate, true) remove_method :try_activate if Gem.respond_to?(:try_activate, true)
@ -1165,7 +1176,7 @@ end
module Kernel 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+. # Use Kernel#gem to activate a specific version of +gem_name+.
@ -1217,6 +1228,7 @@ end
require 'rubygems/exceptions' require 'rubygems/exceptions'
gem_preluded = Gem::GEM_PRELUDE_SUCKAGE and defined? Gem
unless gem_preluded then # TODO: remove guard after 1.9.2 dropped unless gem_preluded then # TODO: remove guard after 1.9.2 dropped
begin begin
## ##
@ -1240,7 +1252,7 @@ end
## ##
# Enables the require hook for RubyGems. # Enables the require hook for RubyGems.
require 'rubygems/custom_require' require 'rubygems/custom_require' unless Gem::GEM_PRELUDE_SUCKAGE
Gem.clear_paths Gem.clear_paths

View file

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

View file

@ -56,7 +56,7 @@ class Gem::Dependency
@type = type @type = type
@prerelease = false @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. # +requirement+ for the dirty details.
@version_requirements = @requirement @version_requirements = @requirement

View file

@ -84,7 +84,7 @@ class Gem::DependencyInstaller
## ##
# Returns a list of pairs of gemspecs and source_uris that match # Returns a list of pairs of gemspecs and source_uris that match
# Gem::Dependency +dep+ from both local (Dir.pwd) and remote (Gem.sources) # 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. # local gems preferred over remote gems.
def find_gems_with_sources(dep) def find_gems_with_sources(dep)

View file

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

View file

@ -28,7 +28,7 @@ class Gem::Ext::Builder
File.open('Makefile', 'wb') {|f| f.print mf} 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+)/ RbConfig::CONFIG['configure_args'] =~ /with-make-prog\=(\w+)/
make_program = $1 || ENV['make'] make_program = $1 || ENV['make']
unless make_program then unless make_program then

View file

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

View file

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

View file

@ -63,7 +63,7 @@ class Gem::Indexer
require 'tmpdir' require 'tmpdir'
require 'zlib' require 'zlib'
unless ''.respond_to? :to_xs then unless defined?(Builder::XChar) then
raise "Gem::Indexer requires that the XML Builder library be installed:" \ raise "Gem::Indexer requires that the XML Builder library be installed:" \
"\n\tgem install builder" "\n\tgem install builder"
end end
@ -555,10 +555,18 @@ class Gem::Indexer
# Sanitize a single string. # Sanitize a single string.
def sanitize_string(string) def sanitize_string(string)
return string unless string
# HACK the #to_s is in here because RSpec has an Array of Arrays of # 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.) # 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 end
## ##

View file

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

View file

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

View file

@ -7,7 +7,11 @@
require 'stringio' require 'stringio'
require 'rubygems/user_interaction' 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 class TermError < RuntimeError; end
module TTY module TTY

View file

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

View file

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

View file

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

View file

@ -6,15 +6,19 @@
at_exit { $SAFE = 1 } at_exit { $SAFE = 1 }
# $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
if defined? Gem::QuickLoader if defined? Gem::QuickLoader
Gem::QuickLoader.load_full_rubygems_library Gem::QuickLoader.load_full_rubygems_library
else else
require 'rubygems' require 'rubygems'
end end
require 'fileutils'
begin
gem 'minitest'
rescue Gem::LoadError
end
require 'minitest/autorun' require 'minitest/autorun'
require 'fileutils'
require 'tmpdir' require 'tmpdir'
require 'uri' require 'uri'
require 'rubygems/package' require 'rubygems/package'
@ -35,44 +39,84 @@ end
require 'rdoc/rdoc' require 'rdoc/rdoc'
require "test/rubygems/mockgemui" require 'rubygems/mock_gem_ui'
module Gem module Gem
##
# Allows setting the gem path searcher. This method is available when
# requiring 'rubygems/test_case'
def self.searcher=(searcher) def self.searcher=(searcher)
@searcher = searcher @searcher = searcher
end end
##
# Allows setting the default SourceIndex. This method is available when
# requiring 'rubygems/test_case'
def self.source_index=(si) def self.source_index=(si)
@@source_index = si @@source_index = si
end end
##
# Allows toggling Windows behavior. This method is available when requiring
# 'rubygems/test_case'
def self.win_platform=(val) def self.win_platform=(val)
@@win_platform = val @@win_platform = val
end end
##
# Allows setting path to ruby. This method is available when requiring
# 'rubygems/test_case'
def self.ruby= ruby def self.ruby= ruby
@ruby = ruby @ruby = ruby
end end
##
# When rubygems/test_case is required the default user interaction is a
# MockGemUi.
module DefaultUserInteraction module DefaultUserInteraction
@ui = MockGemUi.new @ui = Gem::MockGemUi.new
end end
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 include Gem::DefaultUserInteraction
undef_method :default_test if instance_methods.include? 'default_test' or undef_method :default_test if instance_methods.include? 'default_test' or
instance_methods.include? :default_test 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 def setup
super super
@orig_gem_home = ENV['GEM_HOME'] @orig_gem_home = ENV['GEM_HOME']
@orig_gem_path = ENV['GEM_PATH'] @orig_gem_path = ENV['GEM_PATH']
@ui = MockGemUi.new @ui = Gem::MockGemUi.new
tmpdir = nil tmpdir = nil
Dir.chdir Dir.tmpdir do tmpdir = Dir.pwd end # HACK OSX /private/tmp Dir.chdir Dir.tmpdir do tmpdir = Dir.pwd end # HACK OSX /private/tmp
if ENV['KEEP_FILES'] then if ENV['KEEP_FILES'] then
@ -125,10 +169,10 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
@marshal_version = "#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}" @marshal_version = "#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}"
@private_key = File.expand_path File.join(File.dirname(__FILE__), @private_key = File.expand_path('../../../test/rubygems/private_key.pem',
'private_key.pem') __FILE__)
@public_cert = File.expand_path File.join(File.dirname(__FILE__), @public_cert = File.expand_path('../../../test/rubygems/public_cert.pem',
'public_cert.pem') __FILE__)
Gem.post_build_hooks.clear Gem.post_build_hooks.clear
Gem.post_install_hooks.clear Gem.post_install_hooks.clear
@ -161,6 +205,10 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
@orig_LOAD_PATH = $LOAD_PATH.dup @orig_LOAD_PATH = $LOAD_PATH.dup
end end
##
# #teardown restores the process to its original state and removes the
# tempdir unless the +KEEP_FILES+ environment variable was set.
def teardown def teardown
$LOAD_PATH.replace @orig_LOAD_PATH $LOAD_PATH.replace @orig_LOAD_PATH
@ -188,27 +236,36 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
end end
end end
def install_gem gem ##
# Builds and installs the Gem::Specification +spec+
def install_gem spec
require 'rubygems/installer' require 'rubygems/installer'
use_ui MockGemUi.new do use_ui Gem::MockGemUi.new do
Dir.chdir @tempdir do Dir.chdir @tempdir do
Gem::Builder.new(gem).build Gem::Builder.new(spec).build
end end
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 Gem::Installer.new(gem, :wrappers => true).install
end end
def uninstall_gem gem ##
# Uninstalls the Gem::Specification +spec+
def uninstall_gem spec
require 'rubygems/uninstaller' require 'rubygems/uninstaller'
uninstaller = Gem::Uninstaller.new gem.name, :executables => true, uninstaller = Gem::Uninstaller.new spec.name, :executables => true,
:user_install => true :user_install => true
uninstaller.uninstall uninstaller.uninstall
end end
##
# Enables pretty-print for all tests
def mu_pp(obj) def mu_pp(obj)
s = '' s = ''
s = PP.pp obj, s s = PP.pp obj, s
@ -216,33 +273,8 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
s.chomp s.chomp
end end
def prep_cache_files(lc) ##
@usr_si ||= Gem::SourceIndex.new # Reads a Marshal file at +path+
@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
def read_cache(path) def read_cache(path)
open path.dup.untaint, 'rb' do |io| open path.dup.untaint, 'rb' do |io|
@ -250,28 +282,45 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
end end
end end
##
# Reads a binary file at +path+
def read_binary(path) def read_binary(path)
Gem.read_binary path Gem.read_binary path
end end
##
# Writes a binary file to +path+ which is relative to +@gemhome+
def write_file(path) def write_file(path)
path = File.join(@gemhome, path) path = File.join @gemhome, path
dir = File.dirname path dir = File.dirname path
FileUtils.mkdir_p dir FileUtils.mkdir_p dir
open path, 'wb' do |io| open path, 'wb' do |io|
yield io yield io if block_given?
end end
path path
end 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' require 'rubygems/specification'
spec = Gem::Specification.new do |s| spec = Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY s.platform = Gem::Platform::RUBY
s.name = gemname s.name = name
s.version = version s.version = version
s.author = 'A User' s.author = 'A User'
s.email = 'example@example.com' s.email = 'example@example.com'
@ -295,6 +344,10 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
return spec return spec
end 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) def util_build_gem(spec)
dir = File.join(@gemhome, 'gems', spec.full_name) dir = File.join(@gemhome, 'gems', spec.full_name)
FileUtils.mkdir_p dir FileUtils.mkdir_p dir
@ -306,7 +359,7 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
File.open file, 'w' do |fp| fp.puts "# #{file}" end File.open file, 'w' do |fp| fp.puts "# #{file}" end
end end
use_ui MockGemUi.new do use_ui Gem::MockGemUi.new do
Gem::Builder.new(spec).build Gem::Builder.new(spec).build
end end
@ -315,14 +368,23 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
end end
end end
##
# Removes all installed gems from +@gemhome+.
def util_clear_gems def util_clear_gems
FileUtils.rm_r File.join(@gemhome, 'gems') FileUtils.rm_r File.join(@gemhome, 'gems')
FileUtils.rm_r File.join(@gemhome, 'specifications') FileUtils.rm_r File.join(@gemhome, 'specifications')
Gem.source_index.refresh! Gem.source_index.refresh!
end 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) def util_gem(name, version, deps = nil, &block)
if deps then # fuck you eric if deps then
block = proc do |s| block = proc do |s|
deps.each do |n, req| deps.each do |n, req|
s.add_dependency n, (req || '>= 0') s.add_dependency n, (req || '>= 0')
@ -345,6 +407,9 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
[spec, cache_file] [spec, cache_file]
end end
##
# Gzips +data+.
def util_gzip(data) def util_gzip(data)
out = StringIO.new out = StringIO.new
@ -355,6 +420,23 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
out.string out.string
end 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) def util_make_gems(prerelease = false)
@a1 = quick_gem 'a', '1' do |s| @a1 = quick_gem 'a', '1' do |s|
s.files = %w[lib/code.rb] s.files = %w[lib/code.rb]
@ -391,17 +473,16 @@ Also, a list:
if prerelease if prerelease
@a2_pre = quick_gem('a', '2.a', &init) @a2_pre = quick_gem('a', '2.a', &init)
write_file File.join(*%W[gems #{@a2_pre.original_name} lib code.rb]) do write_file File.join(*%W[gems #{@a2_pre.original_name} lib code.rb])
end
util_build_gem @a2_pre util_build_gem @a2_pre
end end
write_file File.join(*%W[gems #{@a1.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]) do end write_file File.join(*%W[gems #{@a2.original_name} lib code.rb])
write_file File.join(*%W[gems #{@a3a.original_name} lib code.rb]) do end write_file File.join(*%W[gems #{@a3a.original_name} lib code.rb])
write_file File.join(*%W[gems #{@b2.original_name} lib code.rb]) do end 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]) do end 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]) do end write_file File.join(*%W[gems #{@pl1.original_name} lib code.rb])
[@a1, @a2, @a3a, @a_evil9, @b2, @c1_2, @pl1].each do |spec| [@a1, @a2, @a3a, @a_evil9, @b2, @c1_2, @pl1].each do |spec|
util_build_gem spec util_build_gem spec
@ -425,6 +506,12 @@ Also, a list:
platform platform
end 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) def util_setup_fake_fetcher(prerelease = false)
require 'zlib' require 'zlib'
require 'socket' require 'socket'
@ -451,6 +538,10 @@ Also, a list:
Gem::RemoteFetcher.fetcher = @fetcher Gem::RemoteFetcher.fetcher = @fetcher
end 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) def util_setup_spec_fetcher(*specs)
specs = Hash[*specs.map { |spec| [spec.full_name, spec] }.flatten] specs = Hash[*specs.map { |spec| [spec.full_name, spec] }.flatten]
si = Gem::SourceIndex.new specs si = Gem::SourceIndex.new specs
@ -485,65 +576,87 @@ Also, a list:
si si
end end
##
# Deflates +data+
def util_zip(data) def util_zip(data)
Zlib::Deflate.deflate data Zlib::Deflate.deflate data
end end
##
# Is this test being run on a Windows platform?
def self.win_platform? def self.win_platform?
Gem.win_platform? Gem.win_platform?
end end
##
# Is this test being run on a Windows platform?
def win_platform? def win_platform?
Gem.win_platform? Gem.win_platform?
end end
##
# Returns whether or not we're on a version of Ruby built with VC++ (or # Returns whether or not we're on a version of Ruby built with VC++ (or
# Borland) versus Cygwin, Mingw, etc. # Borland) versus Cygwin, Mingw, etc.
#
def self.vc_windows? def self.vc_windows?
RUBY_PLATFORM.match('mswin') RUBY_PLATFORM.match('mswin')
end end
##
# Returns whether or not we're on a version of Ruby built with VC++ (or # Returns whether or not we're on a version of Ruby built with VC++ (or
# Borland) versus Cygwin, Mingw, etc. # Borland) versus Cygwin, Mingw, etc.
#
def vc_windows? def vc_windows?
RUBY_PLATFORM.match('mswin') RUBY_PLATFORM.match('mswin')
end end
##
# Returns the make command for the current platform. For versions of Ruby # 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 # built on MS Windows with VC++ or Borland it will return 'nmake'. On all
# other platforms, including Cygwin, it will return 'make'. # other platforms, including Cygwin, it will return 'make'.
#
def self.make_command def self.make_command
ENV["make"] || (vc_windows? ? 'nmake' : 'make') ENV["make"] || (vc_windows? ? 'nmake' : 'make')
end end
##
# Returns the make command for the current platform. For versions of Ruby # 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 # built on MS Windows with VC++ or Borland it will return 'nmake'. On all
# other platforms, including Cygwin, it will return 'make'. # other platforms, including Cygwin, it will return 'make'.
#
def make_command def make_command
ENV["make"] || (vc_windows? ? 'nmake' : 'make') ENV["make"] || (vc_windows? ? 'nmake' : 'make')
end end
##
# Returns whether or not the nmake command could be found. # Returns whether or not the nmake command could be found.
#
def nmake_found? def nmake_found?
system('nmake /? 1>NUL 2>&1') system('nmake /? 1>NUL 2>&1')
end 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 # a hardcoded one. This helps CI tools when running parallels builds on
# the same builder slave. # the same builder slave.
def self.process_based_port def self.process_based_port
@@process_based_port ||= 8000 + $$ % 1000 @@process_based_port ||= 8000 + $$ % 1000
end end
##
# See ::process_based_port
def process_based_port def process_based_port
self.class.process_based_port self.class.process_based_port
end end
##
# Allows the proper version of +rake+ to be used for the test.
def build_rake_in def build_rake_in
gem_ruby = Gem.ruby gem_ruby = Gem.ruby
Gem.ruby = @@ruby Gem.ruby = @@ruby
@ -559,6 +672,9 @@ Also, a list:
end end
end end
##
# Finds the path to the ruby executable
def self.rubybin def self.rubybin
ruby = ENV["RUBY"] ruby = ENV["RUBY"]
return ruby if ruby return ruby if ruby
@ -604,7 +720,7 @@ Also, a list:
end end
## ##
# Construct a new Gem::Requirement. # Constructs a new Gem::Requirement.
def req *requirements def req *requirements
return requirements.first if Gem::Requirement === requirements.first return requirements.first if Gem::Requirement === requirements.first
@ -612,7 +728,7 @@ Also, a list:
end end
## ##
# Construct a new Gem::Specification. # Constructs a new Gem::Specification.
def spec name, version, &block def spec name, version, &block
Gem::Specification.new name, v(version), &block Gem::Specification.new name, v(version), &block

View file

@ -127,9 +127,8 @@ class Gem::Uninstaller
# +gemspec+. # +gemspec+.
def remove_executables(spec) 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| list = @source_index.find_name(spec.name).delete_if { |s|
@ -146,15 +145,16 @@ class Gem::Uninstaller
return if executables.empty? return if executables.empty?
answer = if @force_executables.nil? then remove = if @force_executables.nil? then
ask_yes_no("Remove executables:\n" \ ask_yes_no("Remove executables:\n" \
"\t#{spec.executables.join(", ")}\n\nin addition to the gem?", "\t#{spec.executables.join ', '}\n\n" \
true) # " # appease ruby-mode - don't ask "in addition to the gem?",
true)
else else
@force_executables @force_executables
end end
unless answer then unless remove then
say "Executables and scripts will remain installed." say "Executables and scripts will remain installed."
else else
raise Gem::FilePermissionError, bindir unless File.writable? bindir raise Gem::FilePermissionError, bindir unless File.writable? bindir
@ -166,7 +166,6 @@ class Gem::Uninstaller
end end
end end
end end
end
## ##
# Removes all gems in +list+. # Removes all gems in +list+.

View file

@ -72,7 +72,7 @@ module Gem::DefaultUserInteraction
end 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 # including this module may use the interaction methods on the default UI
# directly. Classes may also reference the ui and ui= methods. # directly. Classes may also reference the ui and ui= methods.
# #
@ -224,7 +224,7 @@ class Gem::StreamUI
result result
end end
if RUBY_VERSION >= "1.9" then if RUBY_VERSION > '1.9.2' then
## ##
# Ask for a password. Does not echo response to terminal. # Ask for a password. Does not echo response to terminal.
@ -477,12 +477,20 @@ class Gem::StreamUI
end end
def fetch(file_name, total_bytes) 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) update_display(false)
end end
def update(bytes) 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 return if new_progress == @progress
@progress = new_progress @progress = new_progress
@ -490,7 +498,7 @@ class Gem::StreamUI
end end
def done def done
@progress = 100 @progress = 100 if @units == '%'
update_display(true, true) update_display(true, true)
end end
@ -498,8 +506,9 @@ class Gem::StreamUI
def update_display(show_progress = true, new_line = false) def update_display(show_progress = true, new_line = false)
return unless @out.tty? 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 else
@out.print "Fetching: %s" % @file_name @out.print "Fetching: %s" % @file_name
end end

View file

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

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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'
class TestConfig < RubyGemTestCase class TestConfig < Gem::TestCase
def test_datadir def test_datadir
_, err = capture_io do _, err = capture_io do

View file

@ -4,14 +4,14 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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'
require 'rubygems/gem_openssl' require 'rubygems/gem_openssl'
require 'rubygems/installer' require 'rubygems/installer'
require 'pathname' require 'pathname'
require 'tmpdir' require 'tmpdir'
class TestGem < RubyGemTestCase class TestGem < Gem::TestCase
def setup def setup
super super

View file

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

View file

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

View file

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

View file

@ -4,11 +4,11 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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/commands/build_command'
require 'rubygems/format' require 'rubygems/format'
class TestGemCommandsBuildCommand < RubyGemTestCase class TestGemCommandsBuildCommand < Gem::TestCase
def setup def setup
super super

View file

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

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/commands/check_command'
class TestGemCommandsCheckCommand < RubyGemTestCase class TestGemCommandsCheckCommand < Gem::TestCase
def setup def setup
super super

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/commands/contents_command'
class TestGemCommandsContentsCommand < RubyGemTestCase class TestGemCommandsContentsCommand < Gem::TestCase
def setup def setup
super super
@ -54,7 +54,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_raises MockGemUi::TermError do assert_raises Gem::MockGemUi::TermError do
use_ui @ui do use_ui @ui do
@cmd.execute @cmd.execute
end end

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/commands/dependency_command'
class TestGemCommandsDependencyCommand < RubyGemTestCase class TestGemCommandsDependencyCommand < Gem::TestCase
def setup def setup
super super
@ -72,7 +72,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_raises MockGemUi::TermError do assert_raises Gem::MockGemUi::TermError do
use_ui @ui do use_ui @ui do
@cmd.execute @cmd.execute
end end
@ -161,7 +161,7 @@ Gem foo-2
@cmd.options[:reverse_dependencies] = true @cmd.options[:reverse_dependencies] = true
@cmd.options[:domain] = :remote @cmd.options[:domain] = :remote
assert_raises MockGemUi::TermError do assert_raises Gem::MockGemUi::TermError do
use_ui @ui do use_ui @ui do
@cmd.execute @cmd.execute
end end

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/commands/environment_command'
class TestGemCommandsEnvironmentCommand < RubyGemTestCase class TestGemCommandsEnvironmentCommand < Gem::TestCase
def setup def setup
super super

View file

@ -4,12 +4,12 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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/package'
require 'rubygems/security' require 'rubygems/security'
require 'rubygems/commands/fetch_command' require 'rubygems/commands/fetch_command'
class TestGemCommandsFetchCommand < RubyGemTestCase class TestGemCommandsFetchCommand < Gem::TestCase
def setup def setup
super super

View file

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

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/commands/install_command'
class TestGemCommandsInstallCommand < RubyGemTestCase class TestGemCommandsInstallCommand < Gem::TestCase
def setup def setup
super super

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/commands/list_command'
class TestGemCommandsListCommand < RubyGemTestCase class TestGemCommandsListCommand < Gem::TestCase
def setup def setup
super super

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/commands/lock_command'
class TestGemCommandsLockCommand < RubyGemTestCase class TestGemCommandsLockCommand < Gem::TestCase
def setup def setup
super super

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/commands/outdated_command'
class TestGemCommandsOutdatedCommand < RubyGemTestCase class TestGemCommandsOutdatedCommand < Gem::TestCase
def setup def setup
super super

View file

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

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/commands/pristine_command'
class TestGemCommandsPristineCommand < RubyGemTestCase class TestGemCommandsPristineCommand < Gem::TestCase
def setup def setup
super super

View file

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

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/commands/query_command'
class TestGemCommandsQueryCommand < RubyGemTestCase class TestGemCommandsQueryCommand < Gem::TestCase
def setup def setup
super super

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/commands/server_command'
class TestGemCommandsServerCommand < RubyGemTestCase class TestGemCommandsServerCommand < Gem::TestCase
def setup def setup
super super

View file

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

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/commands/specification_command'
class TestGemCommandsSpecificationCommand < RubyGemTestCase class TestGemCommandsSpecificationCommand < Gem::TestCase
def setup def setup
super super
@ -51,7 +51,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_raises MockGemUi::TermError do assert_raises Gem::MockGemUi::TermError do
use_ui @ui do use_ui @ui do
@cmd.execute @cmd.execute
end end

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/commands/stale_command'
class TestGemCommandsStaleCommand < RubyGemTestCase class TestGemCommandsStaleCommand < Gem::TestCase
def setup def setup
super super

View file

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

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/commands/unpack_command'
class TestGemCommandsUnpackCommand < RubyGemTestCase class TestGemCommandsUnpackCommand < Gem::TestCase
def setup def setup
super super

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/commands/update_command'
class TestGemCommandsUpdateCommand < RubyGemTestCase class TestGemCommandsUpdateCommand < Gem::TestCase
def setup def setup
super super

View file

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

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/config_file'
class TestGemConfigFile < RubyGemTestCase class TestGemConfigFile < Gem::TestCase
def setup def setup
super super

View file

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

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/dependency_installer'
class TestGemDependencyInstaller < RubyGemTestCase class TestGemDependencyInstaller < Gem::TestCase
def setup def setup
super super

View file

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

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/doc_manager'
class TestGemDocManager < RubyGemTestCase class TestGemDocManager < Gem::TestCase
def setup def setup
super super

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/gem_runner'
class TestGemGemRunner < RubyGemTestCase class TestGemGemRunner < Gem::TestCase
def test_do_configuration def test_do_configuration
Gem.clear_paths Gem.clear_paths

View file

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

View file

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

View file

@ -4,11 +4,11 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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/install_update_options'
require 'rubygems/command' require 'rubygems/command'
class TestGemInstallUpdateOptions < GemInstallerTestCase class TestGemInstallUpdateOptions < Gem::InstallerTestCase
def setup def setup
super super

View file

@ -4,9 +4,9 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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 def test_app_script_text
util_make_exec '2', '' util_make_exec '2', ''
@ -72,6 +72,7 @@ load Gem.bin_path('a', 'my_exec', version)
end end
def test_build_extensions_unsupported def test_build_extensions_unsupported
gem_make_out = File.join @gemhome, 'gems', @spec.full_name, 'gem_make.out'
@spec.extensions << nil @spec.extensions << nil
e = assert_raises Gem::Installer::ExtensionBuildError do e = assert_raises Gem::Installer::ExtensionBuildError do
@ -80,15 +81,15 @@ load Gem.bin_path('a', 'my_exec', version)
end end
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", assert_equal "Building native extensions. This could take a while...\n",
@ui.output @ui.output
assert_equal '', @ui.error 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 ensure
FileUtils.rm_f 'gem_make.out' FileUtils.rm_f gem_make_out
end end
def test_ensure_dependency def test_ensure_dependency

View file

@ -4,11 +4,11 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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/local_remote_options'
require 'rubygems/command' require 'rubygems/command'
class TestGemLocalRemoteOptions < RubyGemTestCase class TestGemLocalRemoteOptions < Gem::TestCase
def setup def setup
super super

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/package'
class TestGemPackageTarHeader < TarTestCase class TestGemPackageTarHeader < Gem::Package::TarTestCase
def setup def setup
super super

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' 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 # 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. # all systems, or just some. But for now, we will ignore it in the tests.

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/package/tar_output'
class TestGemPackageTarOutput < TarTestCase class TestGemPackageTarOutput < Gem::Package::TarTestCase
def setup def setup
super super

View file

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

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/package'
class TestGemPackageTarReaderEntry < TarTestCase class TestGemPackageTarReaderEntry < Gem::Package::TarTestCase
def setup def setup
super super

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/package/tar_writer'
class TestTarWriter < TarTestCase class TestTarWriter < Gem::Package::TarTestCase
def setup def setup
super super

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,11 +4,11 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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/source_index'
require 'rubygems/config_file' require 'rubygems/config_file'
class TestGemSourceIndex < RubyGemTestCase class TestGemSourceIndex < Gem::TestCase
def setup def setup
super super

View file

@ -4,10 +4,10 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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' require 'rubygems/spec_fetcher'
class TestGemSpecFetcher < RubyGemTestCase class TestGemSpecFetcher < Gem::TestCase
def setup def setup
super super

View file

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

View file

@ -4,11 +4,11 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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 'rubygems/user_interaction'
require 'timeout' require 'timeout'
class TestGemStreamUI < RubyGemTestCase class TestGemStreamUI < Gem::TestCase
module IsTty module IsTty
attr_accessor :tty 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 assert_equal "Fetching: a.gem\rFetching: a.gem ( 50%)\rFetching: a.gem (100%)\n", @out.string
end 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 def test_verbose_download_reporter_no_tty
@out.tty = false @out.tty = false

View file

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

View file

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

View file

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

View file

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

View file

@ -4,11 +4,11 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel. # 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/command'
require 'rubygems/version_option' require 'rubygems/version_option'
class TestGemVersionOption < RubyGemTestCase class TestGemVersionOption < Gem::TestCase
def setup def setup
super super

View file

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