summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--lib/rubygems.rb80
-rw-r--r--lib/rubygems/builder.rb4
-rw-r--r--lib/rubygems/commands/build_command.rb8
-rw-r--r--lib/rubygems/commands/fetch_command.rb13
-rw-r--r--lib/rubygems/commands/pristine_command.rb6
-rw-r--r--lib/rubygems/commands/setup_command.rb19
-rw-r--r--lib/rubygems/commands/specification_command.rb26
-rw-r--r--lib/rubygems/config_file.rb4
-rw-r--r--lib/rubygems/custom_require.rb5
-rw-r--r--lib/rubygems/defaults.rb7
-rw-r--r--lib/rubygems/format.rb2
-rw-r--r--lib/rubygems/installer.rb12
-rw-r--r--lib/rubygems/installer_test_case.rb4
-rw-r--r--lib/rubygems/package/tar_input.rb32
-rw-r--r--lib/rubygems/platform.rb1
-rw-r--r--lib/rubygems/psych_additions.rb9
-rw-r--r--lib/rubygems/psych_tree.rb27
-rw-r--r--lib/rubygems/requirement.rb51
-rw-r--r--lib/rubygems/spec_fetcher.rb8
-rw-r--r--lib/rubygems/specification.rb65
-rw-r--r--lib/rubygems/syck_hack.rb65
-rw-r--r--lib/rubygems/test_case.rb33
-rw-r--r--lib/rubygems/version.rb6
-rw-r--r--test/rubygems/data/null-type.gemspec.rzbin0 -> 553 bytes
-rw-r--r--test/rubygems/test_gem.rb107
-rw-r--r--test/rubygems/test_gem_commands_build_command.rb16
-rw-r--r--test/rubygems/test_gem_commands_fetch_command.rb25
-rw-r--r--test/rubygems/test_gem_commands_help_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_install_command.rb33
-rw-r--r--test/rubygems/test_gem_commands_specification_command.rb98
-rw-r--r--test/rubygems/test_gem_format.rb2
-rw-r--r--test/rubygems/test_gem_installer.rb212
-rw-r--r--test/rubygems/test_gem_platform.rb7
-rw-r--r--test/rubygems/test_gem_security.rb1
-rw-r--r--test/rubygems/test_gem_specification.rb217
36 files changed, 1062 insertions, 153 deletions
diff --git a/ChangeLog b/ChangeLog
index 6e1bfc8369..9c8e892a91 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Wed Apr 18 05:49:32 2012 Eric Hodel <drbrain@segment7.net>
+
+ * lib/rubygems: Update to RubyGems 1.8.22 plus r33517 and r35337 which
+ were ported to the rubygems git repository.
+
+ See https://github.com/rubygems/rubygems/blob/1.8/History.txt for
+ changes since 1.8.11.
+ * test/rubygems: ditto.
+
Tue Apr 17 22:18:48 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* strftime.c (rb_strftime_with_timespec): fix padding of time zone
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index c8f969224c..6c974fbc3d 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -7,7 +7,9 @@
module Gem
QUICKLOADER_SUCKAGE = RUBY_VERSION =~ /^1\.9\.1/
- GEM_PRELUDE_SUCKAGE = RUBY_VERSION =~ /^1\.9\.2/
+
+ # Only MRI 1.9.2 has the custom prelude.
+ GEM_PRELUDE_SUCKAGE = RUBY_VERSION =~ /^1\.9\.2/ && RUBY_ENGINE == "ruby"
end
if Gem::GEM_PRELUDE_SUCKAGE and defined?(Gem::QuickLoader) then
@@ -118,7 +120,7 @@ require "rubygems/deprecate"
# -The RubyGems Team
module Gem
- VERSION = '1.8.11'
+ VERSION = '1.8.21'
##
# Raised when RubyGems is unable to load or activate a gem. Contains the
@@ -256,7 +258,7 @@ module Gem
Gem.path.each do |gemdir|
each_load_path all_partials(gemdir) do |load_path|
- result << gemdir.add(load_path).expand_path
+ result << load_path
end
end
@@ -442,10 +444,10 @@ module Gem
# problem, then we will silently continue.
def self.ensure_gem_subdirectories dir = Gem.dir
- require 'fileutils'
-
old_umask = File.umask
- File.umask old_umask | 022
+ File.umask old_umask | 002
+
+ require 'fileutils'
%w[cache doc gems specifications].each do |name|
subdir = File.join dir, name
@@ -639,35 +641,54 @@ module Gem
index
end
+ @yaml_loaded = false
+
##
# Loads YAML, preferring Psych
def self.load_yaml
- begin
- gem 'psych', '~> 1.2', '>= 1.2.1' unless ENV['TEST_SYCK']
- rescue Gem::LoadError
- # It's OK if the user does not have the psych gem installed. We will
- # attempt to require the stdlib version
- end
+ return if @yaml_loaded
- begin
- # Try requiring the gem version *or* stdlib version of psych.
- require 'psych' unless ENV['TEST_SYCK']
- rescue ::LoadError
- ensure
- require 'yaml'
- end
+ test_syck = ENV['TEST_SYCK']
- # Hack to handle syck's DefaultKey bug with psych.
- # See the note at the top of lib/rubygems/requirement.rb for
- # why we end up defining DefaultKey more than once.
- if !defined? YAML::Syck
- YAML.module_eval do
- const_set 'Syck', Module.new {
- const_set 'DefaultKey', Class.new
- }
+ unless test_syck
+ begin
+ gem 'psych', '~> 1.2', '>= 1.2.1'
+ rescue Gem::LoadError
+ # It's OK if the user does not have the psych gem installed. We will
+ # attempt to require the stdlib version
+ end
+
+ begin
+ # Try requiring the gem version *or* stdlib version of psych.
+ require 'psych'
+ rescue ::LoadError
+ # If we can't load psych, thats fine, go on.
+ else
+ # If 'yaml' has already been required, then we have to
+ # be sure to switch it over to the newly loaded psych.
+ if defined?(YAML::ENGINE) && YAML::ENGINE.yamler != "psych"
+ YAML::ENGINE.yamler = "psych"
end
+
+ require 'rubygems/psych_additions'
+ require 'rubygems/psych_tree'
+ end
end
+
+ require 'yaml'
+
+ # If we're supposed to be using syck, then we may have to force
+ # activate it via the YAML::ENGINE API.
+ if test_syck and defined?(YAML::ENGINE)
+ YAML::ENGINE.yamler = "syck" unless YAML::ENGINE.syck?
+ end
+
+ # Now that we're sure some kind of yaml library is loaded, pull
+ # in our hack to deal with Syck's DefaultKey ugliness.
+ require 'rubygems/syck_hack'
+
+ @yaml_loaded = true
end
##
@@ -987,9 +1008,8 @@ module Gem
def self.loaded_path? path
# TODO: ruby needs a feature to let us query what's loaded in 1.8 and 1.9
- $LOADED_FEATURES.find { |s|
- s =~ /(^|\/)#{Regexp.escape path}#{Regexp.union(*Gem.suffixes)}$/
- }
+ re = /(^|\/)#{Regexp.escape path}#{Regexp.union(*Gem.suffixes)}$/
+ $LOADED_FEATURES.any? { |s| s =~ re }
end
##
diff --git a/lib/rubygems/builder.rb b/lib/rubygems/builder.rb
index a8e96dd90c..25e8fc8321 100644
--- a/lib/rubygems/builder.rb
+++ b/lib/rubygems/builder.rb
@@ -32,9 +32,9 @@ class Gem::Builder
# Builds the gem from the specification. Returns the name of the file
# written.
- def build
+ def build(skip_validation=false)
@spec.mark_version
- @spec.validate
+ @spec.validate unless skip_validation
@signer = sign
write_package
say success if Gem.configuration.verbose
diff --git a/lib/rubygems/commands/build_command.rb b/lib/rubygems/commands/build_command.rb
index 572a5c36ec..36a6fe48f2 100644
--- a/lib/rubygems/commands/build_command.rb
+++ b/lib/rubygems/commands/build_command.rb
@@ -4,7 +4,11 @@ require 'rubygems/builder'
class Gem::Commands::BuildCommand < Gem::Command
def initialize
- super('build', 'Build a gem from a gemspec')
+ super 'build', 'Build a gem from a gemspec'
+
+ add_option '--force', 'skip validation of the spec' do |value, options|
+ options[:force] = true
+ end
end
def arguments # :nodoc:
@@ -22,7 +26,7 @@ class Gem::Commands::BuildCommand < Gem::Command
spec = load_gemspec gemspec
if spec then
- Gem::Builder.new(spec).build
+ Gem::Builder.new(spec).build options[:force]
else
alert_error "Error loading gemspec. Aborting."
terminate_interaction 1
diff --git a/lib/rubygems/commands/fetch_command.rb b/lib/rubygems/commands/fetch_command.rb
index 666d83e730..e7c9cc9525 100644
--- a/lib/rubygems/commands/fetch_command.rb
+++ b/lib/rubygems/commands/fetch_command.rb
@@ -13,6 +13,7 @@ class Gem::Commands::FetchCommand < Gem::Command
add_bulk_threshold_option
add_proxy_option
add_source_option
+ add_clear_sources_option
add_version_option
add_platform_option
@@ -58,8 +59,16 @@ class Gem::Commands::FetchCommand < Gem::Command
next
end
- path = Gem::RemoteFetcher.fetcher.download spec, source_uri
- FileUtils.mv path, File.basename(spec.cache_file)
+ file = "#{spec.full_name}.gem"
+ remote_path = URI.parse(source_uri) + "gems/#{file}"
+
+ fetch = Gem::RemoteFetcher.fetcher
+
+ gem = fetch.fetch_path remote_path.to_s
+
+ File.open file, "wb" do |f|
+ f.write gem
+ end
say "Downloaded #{spec.full_name}"
end
diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb
index 272a4dd18e..83e6cc7a67 100644
--- a/lib/rubygems/commands/pristine_command.rb
+++ b/lib/rubygems/commands/pristine_command.rb
@@ -94,10 +94,14 @@ extensions.
end
# TODO use installer options
+ install_defaults = Gem::ConfigFile::PLATFORM_DEFAULTS['install']
+ installer_env_shebang = install_defaults.to_s['--env-shebang']
+
installer = Gem::Installer.new(gem,
:wrappers => true,
:force => true,
- :install_dir => spec.base_dir)
+ :install_dir => spec.base_dir,
+ :env_shebang => installer_env_shebang)
installer.install
say "Restored #{spec.full_name}"
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index 52a3b88fe3..0c957393d9 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -252,9 +252,19 @@ TEXT
end
def make_destination_dirs(install_destdir)
- lib_dir = nil
- bin_dir = nil
+ lib_dir, bin_dir = Gem.default_rubygems_dirs
+ unless lib_dir
+ lib_dir, bin_dir = generate_default_dirs(install_destdir)
+ end
+
+ mkdir_p lib_dir
+ mkdir_p bin_dir
+
+ return lib_dir, bin_dir
+ end
+
+ def generate_default_dirs(install_destdir)
prefix = options[:prefix]
site_or_vendor = options[:site_or_vendor]
@@ -283,10 +293,7 @@ TEXT
bin_dir = File.join install_destdir, bin_dir.gsub(/^[a-zA-Z]:/, '')
end
- mkdir_p lib_dir
- mkdir_p bin_dir
-
- return lib_dir, bin_dir
+ [lib_dir, bin_dir]
end
def remove_old_bin_files(bin_dir)
diff --git a/lib/rubygems/commands/specification_command.rb b/lib/rubygems/commands/specification_command.rb
index 921fd519e9..566a9cc66e 100644
--- a/lib/rubygems/commands/specification_command.rb
+++ b/lib/rubygems/commands/specification_command.rb
@@ -62,7 +62,25 @@ FIELD name of gemspec field to show
"Please specify a gem name or file on the command line"
end
- dep = Gem::Dependency.new gem, options[:version]
+ case options[:version]
+ when String
+ req = Gem::Requirement.parse options[:version]
+ when Gem::Requirement
+ req = options[:version]
+ else
+ raise Gem::CommandLineError, "Unsupported version type: #{options[:version]}"
+ end
+
+ if !req.none? and options[:all]
+ alert_error "Specify --all or -v, not both"
+ terminate_interaction 1
+ end
+
+ if options[:all]
+ dep = Gem::Dependency.new gem
+ else
+ dep = Gem::Dependency.new gem, options[:version]
+ end
field = get_one_optional_argument
@@ -80,7 +98,11 @@ FIELD name of gemspec field to show
end
if remote? then
- found = Gem::SpecFetcher.fetcher.fetch dep
+ found = Gem::SpecFetcher.fetcher.fetch dep, true
+
+ if dep.prerelease? or options[:prerelease]
+ found += Gem::SpecFetcher.fetcher.fetch dep, false, true, true
+ end
specs.push(*found.map { |spec,| spec })
end
diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb
index a4237e143f..d77dbd9235 100644
--- a/lib/rubygems/config_file.rb
+++ b/lib/rubygems/config_file.rb
@@ -25,6 +25,8 @@
# +:sources+:: Sets Gem::sources
# +:verbose+:: See #verbose
+require 'rbconfig'
+
class Gem::ConfigFile
DEFAULT_BACKTRACE = false
@@ -68,7 +70,7 @@ class Gem::ConfigFile
path.strip
rescue LoadError
- "/etc"
+ RbConfig::CONFIG["sysconfdir"] || "/etc"
end
end
diff --git a/lib/rubygems/custom_require.rb b/lib/rubygems/custom_require.rb
index 641db842ac..c813e3aaa2 100644
--- a/lib/rubygems/custom_require.rb
+++ b/lib/rubygems/custom_require.rb
@@ -32,7 +32,7 @@ module Kernel
# that file has already been loaded is preserved.
def require path
- if Gem.unresolved_deps.empty? or Gem.loaded_path? path then
+ if Gem.unresolved_deps.empty? then
gem_original_require path
else
spec = Gem::Specification.find { |s|
@@ -55,7 +55,8 @@ module Kernel
return gem_original_require path
end
rescue LoadError => load_error
- if load_error.message.end_with?(path) and Gem.try_activate(path) then
+ if load_error.message.start_with?("Could not find") or
+ (load_error.message.end_with?(path) and Gem.try_activate(path)) then
return gem_original_require(path)
end
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
index 20b4198bfa..d6732adbfa 100644
--- a/lib/rubygems/defaults.rb
+++ b/lib/rubygems/defaults.rb
@@ -44,6 +44,13 @@ module Gem
end
##
+ # Paths where RubyGems' .rb files and bin files are installed
+
+ def self.default_rubygems_dirs
+ nil # default to standard layout
+ end
+
+ ##
# Path for gems in the user's home directory
def self.user_dir
diff --git a/lib/rubygems/format.rb b/lib/rubygems/format.rb
index 246c599316..9644f6ab8e 100644
--- a/lib/rubygems/format.rb
+++ b/lib/rubygems/format.rb
@@ -28,7 +28,7 @@ class Gem::Format
# representing the data in the gem
def self.from_file_by_path(file_path, security_policy = nil)
- unless File.exist?(file_path)
+ unless File.file?(file_path)
raise Gem::Exception, "Cannot load gem at [#{file_path}] in #{Dir.pwd}"
end
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 74d803d7fa..31fb1209c9 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -366,7 +366,7 @@ class Gem::Installer
if /\A#!/ =~ first_line then
# Preserve extra words on shebang line, like "-w". Thanks RPA.
- shebang = first_line.sub(/\A\#!.*?ruby\S*(?=(\s+\S+))/, "#!#{Gem.ruby}")
+ shebang = first_line.sub(/\A\#!.*?ruby\S*((\s+\S+)+)/, "#!#{Gem.ruby}")
opts = $1
shebang.strip! # Avoid nasty ^M issues.
end
@@ -466,9 +466,13 @@ require 'rubygems'
version = "#{Gem::Requirement.default}"
-if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
- version = $1
- ARGV.shift
+if ARGV.first
+ str = ARGV.first
+ str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
+ if str =~ /\\A_(.*)_\\z/
+ version = $1
+ ARGV.shift
+ end
end
gem '#{spec.name}', version
diff --git a/lib/rubygems/installer_test_case.rb b/lib/rubygems/installer_test_case.rb
index 7c7b3b98af..96a5156995 100644
--- a/lib/rubygems/installer_test_case.rb
+++ b/lib/rubygems/installer_test_case.rb
@@ -118,7 +118,9 @@ class Gem::InstallerTestCase < Gem::TestCase
FileUtils.mkdir_p 'bin'
FileUtils.mkdir_p 'lib'
FileUtils.mkdir_p File.join('ext', 'a')
- File.open File.join('bin', 'executable'), 'w' do |f| f.puts '1' end
+ File.open File.join('bin', 'executable'), 'w' do |f|
+ f.puts "raise 'ran executable'"
+ end
File.open File.join('lib', 'code.rb'), 'w' do |f| f.puts '1' end
File.open File.join('ext', 'a', 'mkrf_conf.rb'), 'w' do |f|
f << <<-EOF
diff --git a/lib/rubygems/package/tar_input.rb b/lib/rubygems/package/tar_input.rb
index 5ac93ff336..77b4d698da 100644
--- a/lib/rubygems/package/tar_input.rb
+++ b/lib/rubygems/package/tar_input.rb
@@ -210,21 +210,25 @@ class Gem::Package::TarInput
# the unpacking speed) we threw our hands in the air and declared that
# this method would use the String IO approach on all platforms at all
# times. And that's the way it is.
-
+ #
+ # Revisited. Here's the beginning of the long story.
+ # http://osdir.com/ml/lang.ruby.gems.devel/2007-06/msg00045.html
+ #
+ # StringIO wraping has never worked as a workaround by definition. Skipping
+ # initial 10 bytes and passing -MAX_WBITS to Zlib::Inflate luckily works as
+ # gzip reader, but it only works if the GZip header is 10 bytes long (see
+ # below) and it does not check inflated stream consistency (CRC value in the
+ # Gzip trailer.)
+ #
+ # RubyGems generated Gzip Header: 10 bytes
+ # magic(2) + method(1) + flag(1) + mtime(4) + exflag(1) + os(1) +
+ # orig_name(0) + comment(0)
+ #
+ # Ideally, it must return a GZipReader without meaningless buffering. We
+ # have lots of CRuby committers around so let's fix windows build when we
+ # received an error.
def zipped_stream(entry)
- if defined? Rubinius or defined? Maglev then
- # these implementations have working Zlib
- zis = Zlib::GzipReader.new entry
- dis = zis.read
- is = StringIO.new(dis)
- else
- # This is Jamis Buck's Zlib workaround for some unknown issue
- entry.read(10) # skip the gzip header
- zis = Zlib::Inflate.new(-Zlib::MAX_WBITS)
- is = StringIO.new(zis.inflate(entry.read))
- end
- ensure
- zis.finish if zis
+ Zlib::GzipReader.new entry
end
end
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
index 4a4e3c1b35..682714a5de 100644
--- a/lib/rubygems/platform.rb
+++ b/lib/rubygems/platform.rb
@@ -68,6 +68,7 @@ class Gem::Platform
when /aix(\d+)/ then [ 'aix', $1 ]
when /cygwin/ then [ 'cygwin', nil ]
when /darwin(\d+)?/ then [ 'darwin', $1 ]
+ when /^macruby$/ then [ 'macruby', nil ]
when /freebsd(\d+)/ then [ 'freebsd', $1 ]
when /hpux(\d+)/ then [ 'hpux', $1 ]
when /^java$/, /^jruby$/ then [ 'java', nil ]
diff --git a/lib/rubygems/psych_additions.rb b/lib/rubygems/psych_additions.rb
new file mode 100644
index 0000000000..08a5cb37ea
--- /dev/null
+++ b/lib/rubygems/psych_additions.rb
@@ -0,0 +1,9 @@
+# This exists just to satify bugs in marshal'd gemspecs that
+# contain a reference to YAML::PrivateType. We prune these out
+# in Specification._load, but if we don't have the constant, Marshal
+# blows up.
+
+module Psych
+ class PrivateType
+ end
+end
diff --git a/lib/rubygems/psych_tree.rb b/lib/rubygems/psych_tree.rb
new file mode 100644
index 0000000000..eca8249383
--- /dev/null
+++ b/lib/rubygems/psych_tree.rb
@@ -0,0 +1,27 @@
+module Gem
+ if defined? ::Psych::Visitors
+ class NoAliasYAMLTree < Psych::Visitors::YAMLTree
+ def visit_String(str)
+ return super unless str == '=' # or whatever you want
+
+ quote = Psych::Nodes::Scalar::SINGLE_QUOTED
+ @emitter.scalar str, nil, nil, false, true, quote
+ end
+
+ # Noop this out so there are no anchors
+ def register(target, obj)
+ end
+
+ # This is ported over from the yaml_tree in 1.9.3
+ def format_time time
+ if time.utc?
+ time.strftime("%Y-%m-%d %H:%M:%S.%9N Z")
+ else
+ time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z")
+ end
+ end
+
+ private :format_time
+ end
+ end
+end
diff --git a/lib/rubygems/requirement.rb b/lib/rubygems/requirement.rb
index ed5cacc237..7abff01c39 100644
--- a/lib/rubygems/requirement.rb
+++ b/lib/rubygems/requirement.rb
@@ -1,35 +1,18 @@
require "rubygems/version"
-# :stopdoc:
-
-# Hack to handle syck's DefaultKey bug with psych
-#
-# Quick note! If/when psych loads in 1.9, it will redefine
-# YAML to point to Psych by removing the YAML constant.
-# Thusly, over in Gem.load_yaml, we define DefaultKey again
-# after proper yaml library has been loaded.
-#
-# All this is so that there is always a YAML::Syck::DefaultKey
-# class no matter if the full yaml library has loaded or not.
-#
-module YAML
- if !defined? Syck
- module Syck
- class DefaultKey
- def to_s
- '='
- end
- end
- end
- end
-end
-
-# :startdoc:
-
##
# A Requirement is a set of one or more version restrictions. It supports a
# few (<tt>=, !=, >, <, >=, <=, ~></tt>) different restriction operators.
+# REFACTOR: The fact that a requirement is singular or plural is kind of
+# awkward. Is Requirement the right name for this? Or should it be one
+# [op, number] pair, and we call the list of requirements something else?
+# Since a Requirement is held by a Dependency, maybe this should be made
+# singular and the list aspect should be pulled up into Dependency?
+
+require "rubygems/version"
+require "rubygems/deprecate"
+
class Gem::Requirement
include Comparable
@@ -147,6 +130,18 @@ class Gem::Requirement
fix_syck_default_key_in_requirements
end
+ def yaml_initialize(tag, vals) # :nodoc:
+ vals.each do |ivar, val|
+ instance_variable_set "@#{ivar}", val
+ end
+
+ fix_syck_default_key_in_requirements
+ end
+
+ def init_with coder # :nodoc:
+ yaml_initialize coder.tag, coder.map
+ end
+
def prerelease?
requirements.any? { |r| r.last.prerelease? }
end
@@ -188,9 +183,11 @@ class Gem::Requirement
private
def fix_syck_default_key_in_requirements
+ Gem.load_yaml
+
# Fixup the Syck DefaultKey bug
@requirements.each do |r|
- if r[0].kind_of? YAML::Syck::DefaultKey
+ if r[0].kind_of? Gem::SyckDefaultKey
r[0] = "="
end
end
diff --git a/lib/rubygems/spec_fetcher.rb b/lib/rubygems/spec_fetcher.rb
index ad61267cae..7302ad9ffa 100644
--- a/lib/rubygems/spec_fetcher.rb
+++ b/lib/rubygems/spec_fetcher.rb
@@ -255,8 +255,12 @@ class Gem::SpecFetcher
loaded = false
if File.exist? local_file then
- spec_dump =
- @fetcher.fetch_path(spec_path, File.mtime(local_file)) rescue nil
+ begin
+ spec_dump =
+ @fetcher.fetch_path(spec_path, File.mtime(local_file))
+ rescue Gem::RemoteFetcher::FetchError => e
+ alert_warning "Error fetching data: #{e.message}"
+ end
loaded = true if spec_dump
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 97db19e69a..70a3fd09b4 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -262,18 +262,19 @@ class Gem::Specification
def self._all # :nodoc:
unless defined?(@@all) && @@all then
- specs = []
+ specs = {}
- self.dirs.reverse_each { |dir|
+ self.dirs.each { |dir|
Dir[File.join(dir, "*.gemspec")].each { |path|
spec = Gem::Specification.load path.untaint
# #load returns nil if the spec is bad, so we just ignore
# it at this stage
- specs << spec if spec
+ specs[spec.full_name] ||= spec if spec
}
}
- @@all = specs
+ @@all = specs.values
+
_resort!
end
@@all
@@ -484,6 +485,8 @@ class Gem::Specification
# +input+ can be anything that YAML.load() accepts: String or IO.
def self.from_yaml(input)
+ Gem.load_yaml
+
input = normalize_yaml_input input
spec = YAML.load input
@@ -535,7 +538,7 @@ class Gem::Specification
file = file.dup.untaint
code = if defined? Encoding
- File.read file, :encoding => "UTF-8"
+ File.read file, :mode => 'r:UTF-8:-'
else
File.read file
end
@@ -663,11 +666,16 @@ class Gem::Specification
raise TypeError, "invalid Gem::Specification format #{array.inspect}"
end
+ # Cleanup any YAML::PrivateType. They only show up for an old bug
+ # where nil => null, so just convert them to nil based on the type.
+
+ array.map! { |e| e.kind_of?(YAML::PrivateType) ? nil : e }
+
spec.instance_variable_set :@rubygems_version, array[0]
# spec version
spec.instance_variable_set :@name, array[2]
spec.instance_variable_set :@version, array[3]
- spec.instance_variable_set :@date, array[4]
+ spec.date = array[4]
spec.instance_variable_set :@summary, array[5]
spec.instance_variable_set :@required_ruby_version, array[6]
spec.instance_variable_set :@required_rubygems_version, array[7]
@@ -756,8 +764,16 @@ class Gem::Specification
def activate_dependencies
self.runtime_dependencies.each do |spec_dep|
- # TODO: check for conflicts! not just name!
- next if Gem.loaded_specs.include? spec_dep.name
+ if loaded = Gem.loaded_specs[spec_dep.name]
+ next if spec_dep.matches_spec? loaded
+
+ msg = "can't satisfy '#{spec_dep}', already activated '#{loaded.full_name}'"
+ e = Gem::LoadError.new msg
+ e.name = spec_dep.name
+
+ raise e
+ end
+
specs = spec_dep.to_specs
if specs.size == 1 then
@@ -986,6 +1002,12 @@ class Gem::Specification
when String then
if /\A(\d{4})-(\d{2})-(\d{2})\Z/ =~ date then
Time.utc($1.to_i, $2.to_i, $3.to_i)
+
+ # Workaround for where the date format output from psych isn't
+ # parsed as a Time object by syck and thus comes through as a
+ # string.
+ elsif /\A(\d{4})-(\d{2})-(\d{2}) \d{2}:\d{2}:\d{2}\.\d+?Z\z/ =~ date then
+ Time.utc($1.to_i, $2.to_i, $3.to_i)
else
raise(Gem::InvalidSpecificationException,
"invalid date format in specification: #{date.inspect}")
@@ -1362,7 +1384,7 @@ class Gem::Specification
val = other_spec.instance_variable_get(name)
if val then
instance_variable_set name, val.dup
- else
+ elsif Gem.configuration.really_verbose
warn "WARNING: #{full_name} has an invalid nil value for #{name}"
end
rescue TypeError
@@ -1912,7 +1934,22 @@ class Gem::Specification
def to_yaml(opts = {}) # :nodoc:
if YAML.const_defined?(:ENGINE) && !YAML::ENGINE.syck? then
- super.gsub(/ !!null \n/, " \n")
+ # Because the user can switch the YAML engine behind our
+ # back, we have to check again here to make sure that our
+ # psych code was properly loaded, and load it if not.
+ unless Gem.const_defined?(:NoAliasYAMLTree)
+ require 'rubygems/psych_tree'
+ end
+
+ builder = Gem::NoAliasYAMLTree.new({})
+ builder << self
+ ast = builder.tree
+
+ io = StringIO.new
+
+ Psych::Visitors::Emitter.new(io).accept(ast)
+
+ io.string.gsub(/ !!null \n/, " \n")
else
YAML.quick_emit object_id, opts do |out|
out.map taguri, to_yaml_style do |map|
@@ -2097,7 +2134,13 @@ class Gem::Specification
# FIX: have this handle the platform/new_platform/original_platform bullshit
def yaml_initialize(tag, vals) # :nodoc:
vals.each do |ivar, val|
- instance_variable_set "@#{ivar}", val
+ case ivar
+ when "date"
+ # Force Date to go through the extra coerce logic in date=
+ self.date = val.untaint
+ else
+ instance_variable_set "@#{ivar}", val.untaint
+ end
end
@original_platform = @platform # for backwards compatibility
diff --git a/lib/rubygems/syck_hack.rb b/lib/rubygems/syck_hack.rb
new file mode 100644
index 0000000000..154d1d16f1
--- /dev/null
+++ b/lib/rubygems/syck_hack.rb
@@ -0,0 +1,65 @@
+# :stopdoc:
+
+# Hack to handle syck's DefaultKey bug
+#
+# This file is always loaded AFTER either syck or psych are already
+# loaded. It then looks at what constants are available and creates
+# a consistent view on all rubys.
+#
+# All this is so that there is always a YAML::Syck::DefaultKey
+# class no matter if the full yaml library has loaded or not.
+#
+
+module YAML
+ # In newer 1.9.2, there is a Syck toplevel constant instead of it
+ # being underneith YAML. If so, reference it back under YAML as
+ # well.
+ if defined? ::Syck
+ Syck = ::Syck
+
+ # JRuby's "Syck" is called "Yecht"
+ elsif defined? YAML::Yecht
+ Syck = YAML::Yecht
+
+ # Otherwise, if there is no YAML::Syck, then we've got just psych
+ # loaded, so lets define a stub for DefaultKey.
+ elsif !defined? YAML::Syck
+ module Syck
+ class DefaultKey
+ end
+ end
+ end
+
+ # Now that we've got something that is always here, define #to_s
+ # so when code tries to use this, it at least just shows up like it
+ # should.
+ module Syck
+ class DefaultKey
+ def to_s
+ '='
+ end
+ end
+ end
+end
+
+# Sometime in the 1.9 dev cycle, the Syck constant was moved from under YAML
+# to be a toplevel constant. So gemspecs created under these versions of Syck
+# will have references to Syck::DefaultKey.
+#
+# So we need to be sure that we reference Syck at the toplevel too so that
+# we can always load these kind of gemspecs.
+#
+if !defined?(Syck)
+ Syck = YAML::Syck
+end
+
+# Now that we've got Syck setup in all the right places, store
+# a reference to the DefaultKey class inside Gem. We do this so that
+# if later on YAML, etc are redefined, we've still got a consistent
+# place to find the DefaultKey class for comparison.
+
+module Gem
+ SyckDefaultKey = YAML::Syck::DefaultKey
+end
+
+# :startdoc:
diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
index 6aed3487c6..9fbdfca52e 100644
--- a/lib/rubygems/test_case.rb
+++ b/lib/rubygems/test_case.rb
@@ -243,7 +243,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
##
# Builds and installs the Gem::Specification +spec+
- def install_gem spec
+ def install_gem spec, options = {}
require 'rubygems/installer'
use_ui Gem::MockGemUi.new do
@@ -254,26 +254,14 @@ class Gem::TestCase < MiniTest::Unit::TestCase
gem = File.join(@tempdir, File.basename(spec.cache_file)).untaint
- Gem::Installer.new(gem, :wrappers => true).install
+ Gem::Installer.new(gem, options.merge({:wrappers => true})).install
end
##
# Builds and installs the Gem::Specification +spec+ into the user dir
def install_gem_user spec
- require 'rubygems/installer'
-
- use_ui Gem::MockGemUi.new do
- Dir.chdir @tempdir do
- Gem::Builder.new(spec).build
- end
- end
-
- gem = File.join(@tempdir, File.basename(spec.cache_file)).untaint
-
- i = Gem::Installer.new(gem, :wrappers => true, :user_install => true)
- i.install
- i.spec
+ install_gem spec, :user_install => true
end
##
@@ -499,8 +487,11 @@ class Gem::TestCase < MiniTest::Unit::TestCase
if deps then
block = proc do |s|
- deps.each do |n, req|
- s.add_dependency n, (req || '>= 0')
+ # Since Hash#each is unordered in 1.8, sort
+ # the keys and iterate that way so the tests are
+ # deteriminstic on all implementations.
+ deps.keys.sort.each do |n|
+ s.add_dependency n, (deps[n] || '>= 0')
end
end
end
@@ -520,8 +511,11 @@ class Gem::TestCase < MiniTest::Unit::TestCase
if deps then
block = proc do |s|
- deps.each do |n, req|
- s.add_dependency n, (req || '>= 0')
+ # Since Hash#each is unordered in 1.8, sort
+ # the keys and iterate that way so the tests are
+ # deteriminstic on all implementations.
+ deps.keys.sort.each do |n|
+ s.add_dependency n, (deps[n] || '>= 0')
end
end
end
@@ -874,4 +868,3 @@ Also, a list:
end
end
-
diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb
index 62af34462d..ecf9f2b4ce 100644
--- a/lib/rubygems/version.rb
+++ b/lib/rubygems/version.rb
@@ -238,6 +238,12 @@ class Gem::Version
initialize array[0]
end
+ def yaml_initialize(tag, map)
+ @version = map['version']
+ @segments = nil
+ @hash = nil
+ end
+
##
# A version is considered a prerelease if it contains a letter.
diff --git a/test/rubygems/data/null-type.gemspec.rz b/test/rubygems/data/null-type.gemspec.rz
new file mode 100644
index 0000000000..b1d0a6d7cd
--- /dev/null
+++ b/test/rubygems/data/null-type.gemspec.rz
Binary files differ
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index 436d14c927..b7c7f41eb6 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -353,6 +353,29 @@ class TestGem < Gem::TestCase
##
# [A] depends on
+ # [C] = 1.0 depends on
+ # [B] = 2.0
+ # [B] ~> 1.0 (satisfied by 1.0)
+
+ def test_self_activate_checks_dependencies
+ a, _ = util_spec 'a', '1.0'
+ a.add_dependency 'c', '= 1.0'
+ a.add_dependency 'b', '~> 1.0'
+
+ util_spec 'b', '1.0'
+ util_spec 'b', '2.0'
+ c, _ = util_spec 'c', '1.0', 'b' => '= 2.0'
+
+ e = assert_raises Gem::LoadError do
+ assert_activate nil, a, c, "b"
+ end
+
+ expected = "can't satisfy 'b (~> 1.0)', already activated 'b-2.0'"
+ assert_equal expected, e.message
+ end
+
+ ##
+ # [A] depends on
# [B] ~> 1.0 (satisfied by 1.0)
# [C] = 1.0 depends on
# [B] = 2.0
@@ -606,8 +629,8 @@ class TestGem < Gem::TestCase
File.umask 0
Gem.ensure_gem_subdirectories @gemhome
- assert_equal 0, File::Stat.new(@gemhome).mode & 022
- assert_equal 0, File::Stat.new(File.join(@gemhome, "cache")).mode & 022
+ assert_equal 0, File::Stat.new(@gemhome).mode & 002
+ assert_equal 0, File::Stat.new(File.join(@gemhome, "cache")).mode & 002
ensure
File.umask old_umask
end unless win_platform?
@@ -1099,6 +1122,86 @@ class TestGem < Gem::TestCase
end
end
+ def test_gem_path_ordering
+ refute_equal Gem.dir, Gem.user_dir
+
+ write_file File.join(@tempdir, 'lib', "g.rb") { |fp| fp.puts "" }
+ write_file File.join(@tempdir, 'lib', 'm.rb') { |fp| fp.puts "" }
+
+ g = new_spec 'g', '1', nil, "lib/g.rb"
+ m = new_spec 'm', '1', nil, "lib/m.rb"
+
+ install_gem g, :install_dir => Gem.dir
+ m0 = install_gem m, :install_dir => Gem.dir
+ m1 = install_gem m, :install_dir => Gem.user_dir
+
+ assert_equal m0.gem_dir, File.join(Gem.dir, "gems", "m-1")
+ assert_equal m1.gem_dir, File.join(Gem.user_dir, "gems", "m-1")
+
+ tests = [
+ [:dir0, [ Gem.dir, Gem.user_dir], m0],
+ [:dir1, [ Gem.user_dir, Gem.dir], m1]
+ ]
+
+ tests.each do |_name, _paths, expected|
+ Gem.paths = { 'GEM_HOME' => _paths.first, 'GEM_PATH' => _paths }
+ Gem::Specification.reset
+ Gem.searcher = nil
+
+ assert_equal Gem::Dependency.new('m','1').to_specs,
+ Gem::Dependency.new('m','1').to_specs.sort
+
+ assert_equal \
+ [expected.gem_dir],
+ Gem::Dependency.new('m','1').to_specs.map(&:gem_dir).sort,
+ "Wrong specs for #{_name}"
+
+ spec = Gem::Dependency.new('m','1').to_spec
+
+ assert_equal \
+ File.join(_paths.first, "gems", "m-1"),
+ spec.gem_dir,
+ "Wrong spec before require for #{_name}"
+ refute spec.activated?, "dependency already activated for #{_name}"
+
+ gem "m"
+
+ spec = Gem::Dependency.new('m','1').to_spec
+ assert spec.activated?, "dependency not activated for #{_name}"
+
+ assert_equal \
+ File.join(_paths.first, "gems", "m-1"),
+ spec.gem_dir,
+ "Wrong spec after require for #{_name}"
+
+ spec.instance_variable_set :@activated, false
+ Gem.loaded_specs.delete(spec.name)
+ $:.delete(File.join(spec.gem_dir, "lib"))
+ end
+ end
+
+ def test_gem_path_ordering_short
+ write_file File.join(@tempdir, 'lib', "g.rb") { |fp| fp.puts "" }
+ write_file File.join(@tempdir, 'lib', 'm.rb') { |fp| fp.puts "" }
+
+ g = new_spec 'g', '1', nil, "lib/g.rb"
+ m = new_spec 'm', '1', nil, "lib/m.rb"
+
+ install_gem g, :install_dir => Gem.dir
+ install_gem m, :install_dir => Gem.dir
+ install_gem m, :install_dir => Gem.user_dir
+
+ Gem.paths = {
+ 'GEM_HOME' => Gem.dir,
+ 'GEM_PATH' => [ Gem.dir, Gem.user_dir]
+ }
+
+ assert_equal \
+ File.join(Gem.dir, "gems", "m-1"),
+ Gem::Dependency.new('m','1').to_spec.gem_dir,
+ "Wrong spec selected"
+ end
+
def with_plugin(path)
test_plugin_path = File.expand_path("test/rubygems/plugin/#{path}",
@@project_dir)
diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb
index 55f5df6f8b..5d374542ba 100644
--- a/test/rubygems/test_gem_commands_build_command.rb
+++ b/test/rubygems/test_gem_commands_build_command.rb
@@ -98,5 +98,21 @@ class TestGemCommandsBuildCommand < Gem::TestCase
assert_equal "this is a summary", spec.summary
end
+ def test_execute_force
+ @gem.instance_variable_set :@required_rubygems_version, nil
+
+ gemspec_file = File.join(@tempdir, @gem.spec_name)
+
+ File.open gemspec_file, 'w' do |gs|
+ gs.write @gem.to_yaml
+ end
+
+ @cmd.options[:args] = [gemspec_file]
+ @cmd.options[:force] = true
+
+ util_test_build_gem @gem, gemspec_file
+ end
+
+
end
diff --git a/test/rubygems/test_gem_commands_fetch_command.rb b/test/rubygems/test_gem_commands_fetch_command.rb
index f4fee79ea3..9017a43b80 100644
--- a/test/rubygems/test_gem_commands_fetch_command.rb
+++ b/test/rubygems/test_gem_commands_fetch_command.rb
@@ -73,5 +73,30 @@ class TestGemCommandsFetchCommand < Gem::TestCase
"#{@a1.full_name} not fetched"
end
+ def test_execute_handles_sources_properly
+ repo = "http://gems.example.com"
+ @uri = URI.parse repo
+
+ Gem.sources.replace [repo]
+
+ util_setup_fake_fetcher
+ util_setup_spec_fetcher @a1, @a2
+
+ @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
+ File.read(@a1.cache_file)
+
+ @cmd.options[:args] = [@a2.name]
+ @cmd.options[:version] = Gem::Requirement.new '1'
+
+ use_ui @ui do
+ Dir.chdir @tempdir do
+ @cmd.execute
+ end
+ end
+
+ assert File.exist?(File.join(@tempdir, @a1.file_name)),
+ "#{@a1.full_name} not fetched"
+ end
+
end
diff --git a/test/rubygems/test_gem_commands_help_command.rb b/test/rubygems/test_gem_commands_help_command.rb
index 822811101c..d626b1436a 100644
--- a/test/rubygems/test_gem_commands_help_command.rb
+++ b/test/rubygems/test_gem_commands_help_command.rb
@@ -3,7 +3,6 @@ require "rubygems/test_case"
require "rubygems/commands/help_command"
require "rubygems/format"
require "rubygems/command_manager"
-require_relative "rubygems_plugin"
class TestGemCommandsHelpCommand < Gem::TestCase
def setup
diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb
index bd61db5e45..2215d4d4ab 100644
--- a/test/rubygems/test_gem_commands_install_command.rb
+++ b/test/rubygems/test_gem_commands_install_command.rb
@@ -3,6 +3,7 @@ require 'rubygems/commands/install_command'
begin
gem "rdoc"
+ gem "json"
rescue Gem::LoadError
# ignore
end
@@ -177,6 +178,38 @@ class TestGemCommandsInstallCommand < Gem::TestCase
assert_match(/ould not find a valid gem 'nonexistent'/, @ui.error)
end
+ def test_execute_bad_source
+ util_setup_fake_fetcher
+ util_setup_spec_fetcher
+
+ # This is needed because we need to exercise the cache path
+ # within SpecFetcher
+ path = File.join Gem.user_home, '.gem', 'specs', "not-there.nothing%80",
+ "latest_specs.4.8"
+
+ FileUtils.mkdir_p File.dirname(path)
+
+ File.open path, "w" do |f|
+ f.write Marshal.dump([])
+ end
+
+ Gem.sources.replace ["http://not-there.nothing"]
+
+ @cmd.options[:args] = %w[nonexistent]
+
+ use_ui @ui do
+ e = assert_raises Gem::SystemExitException do
+ @cmd.execute
+ end
+ assert_equal 2, e.exit_code
+ end
+
+ errs = @ui.error.split("\n")
+
+ assert_match(/WARNING: Error fetching data/, errs.shift)
+ assert_match(/ould not find a valid gem 'nonexistent'/, errs.shift)
+ end
+
def test_execute_nonexistent_with_hint
misspelled = "nonexistent_with_hint"
correctly_spelled = "non_existent_with_hint"
diff --git a/test/rubygems/test_gem_commands_specification_command.rb b/test/rubygems/test_gem_commands_specification_command.rb
index 03c4af6823..978c6fe194 100644
--- a/test/rubygems/test_gem_commands_specification_command.rb
+++ b/test/rubygems/test_gem_commands_specification_command.rb
@@ -43,6 +43,24 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
assert_equal '', @ui.error
end
+ def test_execute_all_conflicts_with_version
+ quick_spec 'foo', '0.0.1'
+ quick_spec 'foo', '0.0.2'
+
+ @cmd.options[:args] = %w[foo]
+ @cmd.options[:all] = true
+ @cmd.options[:version] = "1"
+
+ assert_raises Gem::MockGemUi::TermError do
+ use_ui @ui do
+ @cmd.execute
+ end
+ end
+
+ assert_equal '', @ui.output
+ assert_equal "ERROR: Specify --all or -v, not both\n", @ui.error
+ end
+
def test_execute_bad_name
@cmd.options[:args] = %w[foo]
@@ -122,6 +140,86 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
assert_match %r|name: foo|, @ui.output
end
+ def test_execute_remote_with_version
+ foo1 = quick_gem 'foo', "1"
+ foo2 = quick_gem 'foo', "2"
+
+ @fetcher = Gem::FakeFetcher.new
+ Gem::RemoteFetcher.fetcher = @fetcher
+
+ util_setup_spec_fetcher foo1, foo2
+
+ FileUtils.rm File.join(@gemhome, 'specifications', foo1.spec_name)
+ FileUtils.rm File.join(@gemhome, 'specifications', foo2.spec_name)
+
+ @cmd.options[:args] = %w[foo]
+ @cmd.options[:version] = "1"
+ @cmd.options[:domain] = :remote
+
+ use_ui @ui do
+ @cmd.execute
+ end
+
+ spec = Gem::Specification.from_yaml @ui.output
+
+ assert_equal Gem::Version.new("1"), spec.version
+ end
+
+ def test_execute_remote_without_prerelease
+ foo = new_spec 'foo', '2.0.0'
+ foo_pre = new_spec 'foo', '2.0.1.pre'
+
+ install_specs foo, foo_pre
+
+ @fetcher = Gem::FakeFetcher.new
+ Gem::RemoteFetcher.fetcher = @fetcher
+
+ util_setup_spec_fetcher foo
+ util_setup_spec_fetcher foo_pre
+
+ @cmd.options[:args] = %w[foo]
+ @cmd.options[:domain] = :remote
+
+ use_ui @ui do
+ @cmd.execute
+ end
+
+ assert_match %r|\A--- !ruby/object:Gem::Specification|, @ui.output
+ assert_match %r|name: foo|, @ui.output
+
+ spec = YAML.load @ui.output
+
+ assert_equal Gem::Version.new("2.0.0"), spec.version
+ end
+
+ def test_execute_remote_with_prerelease
+ foo = new_spec 'foo', '2.0.0'
+ foo_pre = new_spec 'foo', '2.0.1.pre'
+
+ install_specs foo, foo_pre
+
+ @fetcher = Gem::FakeFetcher.new
+ Gem::RemoteFetcher.fetcher = @fetcher
+
+ util_setup_spec_fetcher foo
+ util_setup_spec_fetcher foo_pre
+
+ @cmd.options[:args] = %w[foo]
+ @cmd.options[:domain] = :remote
+ @cmd.options[:prerelease] = true
+
+ use_ui @ui do
+ @cmd.execute
+ end
+
+ assert_match %r|\A--- !ruby/object:Gem::Specification|, @ui.output
+ assert_match %r|name: foo|, @ui.output
+
+ spec = YAML.load @ui.output
+
+ assert_equal Gem::Version.new("2.0.1.pre"), spec.version
+ end
+
def test_execute_ruby
foo = quick_spec 'foo'
diff --git a/test/rubygems/test_gem_format.rb b/test/rubygems/test_gem_format.rb
index 805455f763..711527bf79 100644
--- a/test/rubygems/test_gem_format.rb
+++ b/test/rubygems/test_gem_format.rb
@@ -57,7 +57,7 @@ class TestGemFormat < Gem::Package::TarTestCase
def test_class_from_file_by_path_nonexistent
assert_raises Gem::Exception do
- Gem::Format.from_file_by_path '/nonexistent'
+ Gem::Format.from_file_by_path '/a/path/that/is/nonexistent'
end
end
diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb
index 3c6fb45589..d40fbc93bf 100644
--- a/test/rubygems/test_gem_installer.rb
+++ b/test/rubygems/test_gem_installer.rb
@@ -2,26 +2,23 @@ require 'rubygems/installer_test_case'
class TestGemInstaller < Gem::InstallerTestCase
- def setup
- super
+ def util_setup_install
+ @gemhome = @installer_tmp
+ Gem.use_paths @installer_tmp
- if __name__ !~ /^test_install(_|$)/ then
- @gemhome = @installer_tmp
- Gem.use_paths @installer_tmp
+ @spec = Gem::Specification.find_by_name 'a'
+ @user_spec = Gem::Specification.find_by_name 'b'
- @spec = Gem::Specification.find_by_name 'a'
- @user_spec = Gem::Specification.find_by_name 'b'
-
- @installer.spec = @spec
- @installer.gem_home = @installer_tmp
- @installer.gem_dir = @spec.gem_dir
- @user_installer.spec = @user_spec
- @user_installer.gem_home = @installer_tmp
- end
+ @installer.spec = @spec
+ @installer.gem_home = @installer_tmp
+ @installer.gem_dir = @spec.gem_dir
+ @user_installer.spec = @user_spec
+ @user_installer.gem_home = @installer_tmp
end
-
def test_app_script_text
+ util_setup_install
+
@spec.version = 2
util_make_exec @spec, ''
@@ -38,9 +35,13 @@ require 'rubygems'
version = \">= 0\"
-if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
- version = $1
- ARGV.shift
+if ARGV.first
+ str = ARGV.first
+ str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
+ if str =~ /\\A_(.*)_\\z/
+ version = $1
+ ARGV.shift
+ end
end
gem 'a', version
@@ -52,6 +53,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_build_extensions_none
+ util_setup_install
+
use_ui @ui do
@installer.build_extensions
end
@@ -63,6 +66,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_build_extensions_extconf_bad
+ util_setup_install
+
@spec.extensions << 'extconf.rb'
e = assert_raises Gem::Installer::ExtensionBuildError do
@@ -86,6 +91,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_build_extensions_unsupported
+ util_setup_install
+
gem_make_out = File.join @gemhome, 'gems', @spec.full_name, 'gem_make.out'
@spec.extensions << nil
@@ -107,6 +114,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_ensure_dependency
+ util_setup_install
+
dep = Gem::Dependency.new 'a', '>= 2'
assert @installer.ensure_dependency(@spec, dep)
@@ -119,6 +128,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_extract_files
+ util_setup_install
+
format = Object.new
def format.file_entries
[[{'size' => 7, 'mode' => 0400, 'path' => 'thefile'}, 'content']]
@@ -137,6 +148,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_extract_files_bad_dest
+ util_setup_install
+
@installer.gem_dir = 'somedir'
@installer.format = nil
e = assert_raises ArgumentError do
@@ -147,6 +160,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_extract_files_relative
+ util_setup_install
+
format = Object.new
def format.file_entries
[[{'size' => 10, 'mode' => 0644, 'path' => '../thefile'}, '../thefile']]
@@ -166,6 +181,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_extract_files_absolute
+ util_setup_install
+
format = Object.new
def format.file_entries
[[{'size' => 8, 'mode' => 0644, 'path' => '/thefile'}, '/thefile']]
@@ -183,6 +200,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_generate_bin_bindir
+ util_setup_install
+
@installer.wrappers = true
@spec.executables = %w[executable]
@@ -208,6 +227,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_generate_bin_bindir_with_user_install_warning
+ util_setup_install
+
bin_dir = Gem.win_platform? ? File.expand_path(ENV["WINDIR"]) : "/usr/bin"
options = {
@@ -227,6 +248,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_generate_bin_script
+ util_setup_install
+
@installer.wrappers = true
util_make_exec
@installer.gem_dir = util_gem_dir
@@ -242,6 +265,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_generate_bin_script_format
+ util_setup_install
+
@installer.format_executable = true
@installer.wrappers = true
util_make_exec
@@ -257,6 +282,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_generate_bin_script_format_disabled
+ util_setup_install
+
@installer.wrappers = true
util_make_exec
@installer.gem_dir = util_gem_dir
@@ -271,6 +298,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_generate_bin_script_install_dir
+ util_setup_install
+
@installer.wrappers = true
@spec.executables = %w[executable]
@@ -295,6 +324,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_generate_bin_script_no_execs
+ util_setup_install
+
util_execless
@installer.wrappers = true
@@ -304,6 +335,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_generate_bin_script_no_perms
+ util_setup_install
+
@installer.wrappers = true
util_make_exec
@@ -323,6 +356,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_generate_bin_script_no_shebang
+ util_setup_install
+
@installer.wrappers = true
@spec.executables = %w[executable]
@@ -346,6 +381,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_generate_bin_script_wrappers
+ util_setup_install
+
@installer.wrappers = true
util_make_exec
@installer.gem_dir = util_gem_dir
@@ -371,6 +408,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_generate_bin_symlink
+ util_setup_install
+
return if win_platform? #Windows FS do not support symlinks
@installer.wrappers = false
@@ -386,6 +425,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_generate_bin_symlink_no_execs
+ util_setup_install
+
util_execless
@installer.wrappers = false
@@ -395,6 +436,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_generate_bin_symlink_no_perms
+ util_setup_install
+
@installer.wrappers = false
util_make_exec
@installer.gem_dir = util_gem_dir
@@ -415,6 +458,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_generate_bin_symlink_update_newer
+ util_setup_install
+
return if win_platform? #Windows FS do not support symlinks
@installer.wrappers = false
@@ -446,6 +491,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_generate_bin_symlink_update_older
+ util_setup_install
+
return if win_platform? #Windows FS do not support symlinks
@installer.wrappers = false
@@ -482,6 +529,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_generate_bin_symlink_update_remove_wrapper
+ util_setup_install
+
return if win_platform? #Windows FS do not support symlinks
@installer.wrappers = true
@@ -513,6 +562,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_generate_bin_symlink_win32
+ util_setup_install
+
old_win_platform = Gem.win_platform?
Gem.win_platform = true
@installer.wrappers = false
@@ -537,6 +588,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_generate_bin_uses_default_shebang
+ util_setup_install
+
return if win_platform? #Windows FS do not support symlinks
@installer.wrappers = true
@@ -620,6 +673,95 @@ load Gem.bin_path('a', 'executable', version)
assert_same @installer, @pre_install_hook_arg
end
+ def test_install_creates_working_binstub
+ Dir.mkdir util_inst_bindir
+ util_setup_gem
+ util_clear_gems
+
+ @installer.wrappers = true
+
+ gemdir = File.join @gemhome, 'gems', @spec.full_name
+
+ @newspec = nil
+ build_rake_in do
+ use_ui @ui do
+ @newspec = @installer.install
+ end
+ end
+
+ exe = File.join gemdir, 'bin', 'executable'
+
+ e = assert_raises RuntimeError do
+ instance_eval File.read(exe)
+ end
+
+ assert_match(/ran executable/, e.message)
+ end
+
+ def test_install_creates_binstub_that_understand_version
+ Dir.mkdir util_inst_bindir
+ util_setup_gem
+ util_clear_gems
+
+ @installer.wrappers = true
+
+ @newspec = nil
+ build_rake_in do
+ use_ui @ui do
+ @newspec = @installer.install
+ end
+ end
+
+ exe = File.join @gemhome, 'bin', 'executable'
+
+ ARGV.unshift "_3.0_"
+
+ begin
+ Gem::Specification.reset
+
+ e = assert_raises Gem::LoadError do
+ instance_eval File.read(exe)
+ end
+ ensure
+ ARGV.shift if ARGV.first == "_3.0_"
+ end
+
+ assert_match(/\(= 3\.0\)/, e.message)
+ end
+
+ def test_install_creates_binstub_that_dont_trust_encoding
+ skip unless "".respond_to?(:force_encoding)
+
+ Dir.mkdir util_inst_bindir
+ util_setup_gem
+ util_clear_gems
+
+ @installer.wrappers = true
+
+ @newspec = nil
+ build_rake_in do
+ use_ui @ui do
+ @newspec = @installer.install
+ end
+ end
+
+ exe = File.join @gemhome, 'bin', 'executable'
+
+ ARGV.unshift "\xE4pfel".force_encoding("UTF-8")
+
+ begin
+ Gem::Specification.reset
+
+ e = assert_raises RuntimeError do
+ instance_eval File.read(exe)
+ end
+ ensure
+ ARGV.shift if ARGV.first == "\xE4pfel"
+ end
+
+ assert_match(/ran executable/, e.message)
+ end
+
def test_install_with_no_prior_files
Dir.mkdir util_inst_bindir
util_clear_gems
@@ -889,6 +1031,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_installation_satisfies_dependency_eh
+ util_setup_install
+
dep = Gem::Dependency.new 'a', '>= 2'
assert @installer.installation_satisfies_dependency?(dep)
@@ -897,6 +1041,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_shebang
+ util_setup_install
+
util_make_exec @spec, "#!/usr/bin/ruby"
shebang = @installer.shebang 'executable'
@@ -905,6 +1051,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_shebang_arguments
+ util_setup_install
+
util_make_exec @spec, "#!/usr/bin/ruby -ws"
shebang = @installer.shebang 'executable'
@@ -913,6 +1061,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_shebang_empty
+ util_setup_install
+
util_make_exec @spec, ''
shebang = @installer.shebang 'executable'
@@ -920,6 +1070,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_shebang_env
+ util_setup_install
+
util_make_exec @spec, "#!/usr/bin/env ruby"
shebang = @installer.shebang 'executable'
@@ -928,6 +1080,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_shebang_env_arguments
+ util_setup_install
+
util_make_exec @spec, "#!/usr/bin/env ruby -ws"
shebang = @installer.shebang 'executable'
@@ -936,6 +1090,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_shebang_env_shebang
+ util_setup_install
+
util_make_exec @spec, ''
@installer.env_shebang = true
@@ -948,6 +1104,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_shebang_nested
+ util_setup_install
+
util_make_exec @spec, "#!/opt/local/ruby/bin/ruby"
shebang = @installer.shebang 'executable'
@@ -956,6 +1114,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_shebang_nested_arguments
+ util_setup_install
+
util_make_exec @spec, "#!/opt/local/ruby/bin/ruby -ws"
shebang = @installer.shebang 'executable'
@@ -964,6 +1124,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_shebang_version
+ util_setup_install
+
util_make_exec @spec, "#!/usr/bin/ruby18"
shebang = @installer.shebang 'executable'
@@ -972,6 +1134,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_shebang_version_arguments
+ util_setup_install
+
util_make_exec @spec, "#!/usr/bin/ruby18 -ws"
shebang = @installer.shebang 'executable'
@@ -980,6 +1144,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_shebang_version_env
+ util_setup_install
+
util_make_exec @spec, "#!/usr/bin/env ruby18"
shebang = @installer.shebang 'executable'
@@ -988,6 +1154,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_shebang_version_env_arguments
+ util_setup_install
+
util_make_exec @spec, "#!/usr/bin/env ruby18 -ws"
shebang = @installer.shebang 'executable'
@@ -996,6 +1164,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_unpack
+ util_setup_install
+
util_setup_gem
dest = File.join @gemhome, 'gems', @spec.full_name
@@ -1007,6 +1177,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_write_spec
+ util_setup_install
+
spec_dir = File.join @gemhome, 'specifications'
spec_file = File.join spec_dir, @spec.spec_name
FileUtils.rm spec_file
@@ -1022,6 +1194,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_write_spec_writes_cached_spec
+ util_setup_install
+
spec_dir = File.join @gemhome, 'specifications'
spec_file = File.join spec_dir, @spec.spec_name
FileUtils.rm spec_file
@@ -1041,6 +1215,8 @@ load Gem.bin_path('a', 'executable', version)
end
def test_dir
+ util_setup_install
+
assert_match @installer.dir, %r!/installer/gems/a-2$!
end
diff --git a/test/rubygems/test_gem_platform.rb b/test/rubygems/test_gem_platform.rb
index bd09b89f0a..f3b94ea83d 100644
--- a/test/rubygems/test_gem_platform.rb
+++ b/test/rubygems/test_gem_platform.rb
@@ -43,6 +43,7 @@ class TestGemPlatform < Gem::TestCase
'sparc-solaris2.9' => ['sparc', 'solaris', '2.9'],
'universal-darwin8' => ['universal', 'darwin', '8'],
'universal-darwin9' => ['universal', 'darwin', '9'],
+ 'universal-macruby' => ['universal', 'macruby', nil],
'i386-cygwin' => ['x86', 'cygwin', nil],
'i686-darwin' => ['x86', 'darwin', nil],
'i686-darwin8.4.1' => ['x86', 'darwin', '8'],
@@ -246,6 +247,12 @@ class TestGemPlatform < Gem::TestCase
refute_match 'dotnet-2.0', Gem::Platform.local
assert_match 'dotnet-4.0', Gem::Platform.local
+ util_set_arch 'universal-macruby-1.0'
+ assert_match 'universal-macruby', Gem::Platform.local
+ assert_match 'macruby', Gem::Platform.local
+ refute_match 'universal-macruby-0.10', Gem::Platform.local
+ assert_match 'universal-macruby-1.0', Gem::Platform.local
+
util_set_arch 'powerpc-darwin'
assert_match 'powerpc-darwin', Gem::Platform.local
diff --git a/test/rubygems/test_gem_security.rb b/test/rubygems/test_gem_security.rb
index 7f1b2e6ee3..df3168dce4 100644
--- a/test/rubygems/test_gem_security.rb
+++ b/test/rubygems/test_gem_security.rb
@@ -43,7 +43,6 @@ class TestGemSecurity < Gem::TestCase
:key_size => 512,
:save_cert => false,
:save_key => false,
- :trust_dir => File.join(Gem.user_home, '.gem', 'trust'),
}
result = Gem::Security.build_self_signed_cert email, opt
diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
index d63b9bd30e..c64be793fd 100644
--- a/test/rubygems/test_gem_specification.rb
+++ b/test/rubygems/test_gem_specification.rb
@@ -136,7 +136,7 @@ end
name: posix-spawn
version: !ruby/object:Gem::Version
version: 0.3.6
- prerelease:
+ prerelease:
dependencies:
- !ruby/object:Gem::Dependency
name: rake-compiler
@@ -159,8 +159,131 @@ bindir:
Gem::Specification.from_yaml yaml
end
+ op = new_spec.dependencies.first.requirement.requirements.first.first
+ refute_kind_of YAML::Syck::DefaultKey, op
+
+ refute_match %r%DefaultKey%, new_spec.to_ruby
+ end
+
+ def test_self_from_yaml_cleans_up_defaultkey
+ yaml = <<-YAML
+--- !ruby/object:Gem::Specification
+name: posix-spawn
+version: !ruby/object:Gem::Version
+ version: 0.3.6
+ prerelease:
+dependencies:
+- !ruby/object:Gem::Dependency
+ name: rake-compiler
+ requirement: &70243867725240 !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - !ruby/object:YAML::Syck::DefaultKey {}
+
+ - !ruby/object:Gem::Version
+ version: 0.7.6
+ type: :development
+ prerelease: false
+ version_requirements: *70243867725240
+platform: ruby
+files: []
+test_files: []
+bindir:
+ YAML
+
+ new_spec = Gem::Specification.from_yaml yaml
+
+ op = new_spec.dependencies.first.requirement.requirements.first.first
+ refute_kind_of YAML::Syck::DefaultKey, op
+
+ refute_match %r%DefaultKey%, new_spec.to_ruby
+ end
+
+ def test_self_from_yaml_cleans_up_defaultkey_from_newer_192
+ yaml = <<-YAML
+--- !ruby/object:Gem::Specification
+name: posix-spawn
+version: !ruby/object:Gem::Version
+ version: 0.3.6
+ prerelease:
+dependencies:
+- !ruby/object:Gem::Dependency
+ name: rake-compiler
+ requirement: &70243867725240 !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - !ruby/object:Syck::DefaultKey {}
+
+ - !ruby/object:Gem::Version
+ version: 0.7.6
+ type: :development
+ prerelease: false
+ version_requirements: *70243867725240
+platform: ruby
+files: []
+test_files: []
+bindir:
+ YAML
+
+ new_spec = Gem::Specification.from_yaml yaml
+
+ op = new_spec.dependencies.first.requirement.requirements.first.first
+ refute_kind_of YAML::Syck::DefaultKey, op
+
refute_match %r%DefaultKey%, new_spec.to_ruby
- end if RUBY_VERSION < '1.9'
+ end
+
+ def test_self_from_yaml_cleans_up_Date_objects
+ yaml = <<-YAML
+--- !ruby/object:Gem::Specification
+rubygems_version: 0.8.1
+specification_version: 1
+name: diff-lcs
+version: !ruby/object:Gem::Version
+ version: 1.1.2
+date: 2004-10-20
+summary: Provides a list of changes that represent the difference between two sequenced collections.
+require_paths:
+ - lib
+author: Austin Ziegler
+email: diff-lcs@halostatue.ca
+homepage: http://rubyforge.org/projects/ruwiki/
+rubyforge_project: ruwiki
+description: "Test"
+bindir: bin
+has_rdoc: true
+required_ruby_version: !ruby/object:Gem::Version::Requirement
+ requirements:
+ -
+ - ">="
+ - !ruby/object:Gem::Version
+ version: 1.8.1
+ version:
+platform: ruby
+files:
+ - tests/00test.rb
+rdoc_options:
+ - "--title"
+ - "Diff::LCS -- A Diff Algorithm"
+ - "--main"
+ - README
+ - "--line-numbers"
+extra_rdoc_files:
+ - README
+ - ChangeLog
+ - Install
+executables:
+ - ldiff
+ - htmldiff
+extensions: []
+requirements: []
+dependencies: []
+ YAML
+
+ new_spec = Gem::Specification.from_yaml yaml
+
+ assert_kind_of Time, new_spec.date
+ end
def test_self_load
full_path = @a2.spec_file
@@ -220,6 +343,29 @@ bindir:
assert_equal @a2, spec
end
+ if defined?(Encoding)
+ def test_self_load_utf8_with_ascii_encoding
+ int_enc = Encoding.default_internal
+ silence_warnings { Encoding.default_internal = 'US-ASCII' }
+
+ spec2 = @a2.dup
+ bin = "\u5678"
+ spec2.authors = [bin]
+ full_path = spec2.spec_file
+ write_file full_path do |io|
+ io.write spec2.to_ruby_for_cache.force_encoding('BINARY').sub("\\u{5678}", bin.force_encoding('BINARY'))
+ end
+
+ spec = Gem::Specification.load full_path
+
+ spec2.files.clear
+
+ assert_equal spec2, spec
+ ensure
+ silence_warnings { Encoding.default_internal = int_enc }
+ end
+ end
+
def test_self_load_legacy_ruby
spec = Gem::Deprecate.skip_during do
eval LEGACY_RUBY_SPEC
@@ -260,6 +406,27 @@ bindir:
assert_equal expected, Gem::Specification.normalize_yaml_input(input)
end
+ DATA_PATH = File.expand_path "../data", __FILE__
+
+ def test_handles_private_null_type
+ path = File.join DATA_PATH, "null-type.gemspec.rz"
+
+ data = Marshal.load Gem.inflate(Gem.read_binary(path))
+
+ assert_equal nil, data.rubyforge_project
+ end
+
+ def test_emits_zulu_timestamps_properly
+ skip "bug only on 1.9.2" unless RUBY_VERSION =~ /1\.9\.2/
+
+ t = Time.utc(2012, 3, 12)
+ @a2.date = t
+
+ yaml = with_psych { @a2.to_yaml }
+
+ assert_match %r!date: 2012-03-12 00:00:00\.000000000 Z!, yaml
+ end
+
def test_initialize
spec = Gem::Specification.new do |s|
s.name = "blah"
@@ -1041,6 +1208,18 @@ end
assert_match %r|^platform: ruby$|, @a1.to_yaml
end
+ def test_to_yaml_emits_syck_compat_yaml
+ if YAML.const_defined?(:ENGINE) && !YAML::ENGINE.syck?
+ @a1.add_dependency "gx", "1.0.0"
+
+ y = @a1.to_yaml
+
+ refute_match %r!^\s*- - =!, y
+ else
+ skip "Only validates psych yaml"
+ end
+ end
+
def test_validate
util_setup_validate
@@ -1384,6 +1563,15 @@ end
assert_equal Gem::Version.new('1'), @a1.version
end
+ def test__load_fixes_Date_objects
+ spec = new_spec "a", 1
+ spec.instance_variable_set :@date, Date.today
+
+ spec = Marshal.load Marshal.dump(spec)
+
+ assert_kind_of Time, spec.date
+ end
+
def test_load_errors_contain_filename
specfile = Tempfile.new(self.class.name.downcase)
specfile.write "raise 'boom'"
@@ -1505,4 +1693,29 @@ end
# ignore
end
end
+
+ def with_psych
+ begin
+ require "yaml"
+ old_engine = YAML::ENGINE.yamler
+ YAML::ENGINE.yamler = 'psych'
+ rescue NameError
+ # probably on 1.8, ignore
+ end
+
+ yield
+ ensure
+ begin
+ YAML::ENGINE.yamler = old_engine
+ rescue NameError
+ # ignore
+ end
+ end
+
+ def silence_warnings
+ old_verbose, $VERBOSE = $VERBOSE, false
+ yield
+ ensure
+ $VERBOSE = old_verbose
+ end
end