Upgrade to RubyGems 1.2.0 r1824. Incorporates [ruby-core:17353].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
dbf3fb3d8e
commit
8b424513fd
@ -1,3 +1,8 @@
|
|||||||
|
Thu Jun 26 11:04:30 2008 Eric Hodel <drbrain@segment7.net>
|
||||||
|
|
||||||
|
* lib/rubygems: Update to RubyGems 1.2.0 r1824. Incorporates patch by
|
||||||
|
Yusuke ENDOH [ruby-core:17353].
|
||||||
|
|
||||||
Thu Jun 26 00:48:31 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Thu Jun 26 00:48:31 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* parse.y (primary): not operand might be empty. [ruby-dev:35227]
|
* parse.y (primary): not operand might be empty. [ruby-dev:35227]
|
||||||
|
@ -212,8 +212,9 @@ module Gem
|
|||||||
def self.available?(gem, *requirements)
|
def self.available?(gem, *requirements)
|
||||||
requirements = Gem::Requirement.default if requirements.empty?
|
requirements = Gem::Requirement.default if requirements.empty?
|
||||||
|
|
||||||
unless gem.respond_to?(:name) && gem.respond_to?(:version_requirements)
|
unless gem.respond_to?(:name) and
|
||||||
gem = Gem::Dependency.new(gem, requirements)
|
gem.respond_to?(:version_requirements) then
|
||||||
|
gem = Gem::Dependency.new gem, requirements
|
||||||
end
|
end
|
||||||
|
|
||||||
!Gem.source_index.search(gem).empty?
|
!Gem.source_index.search(gem).empty?
|
||||||
@ -649,6 +650,7 @@ module Gem
|
|||||||
|
|
||||||
@gem_path << Gem.dir
|
@gem_path << Gem.dir
|
||||||
else
|
else
|
||||||
|
# TODO: should this be Gem.default_path instead?
|
||||||
@gem_path = [Gem.dir]
|
@gem_path = [Gem.dir]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -50,11 +50,7 @@ class Gem::Commands::InstallCommand < Gem::Command
|
|||||||
|
|
||||||
installed_gems = []
|
installed_gems = []
|
||||||
|
|
||||||
if options[:install_dir].nil? and RUBY_VERSION > '1.9' then
|
ENV.delete 'GEM_PATH' if options[:install_dir].nil? and RUBY_VERSION > '1.9'
|
||||||
ENV.delete 'GEM_PATH'
|
|
||||||
else
|
|
||||||
ENV['GEM_PATH'] = options[:install_dir] # HACK what does this do?
|
|
||||||
end
|
|
||||||
|
|
||||||
install_options = {
|
install_options = {
|
||||||
:env_shebang => options[:env_shebang],
|
:env_shebang => options[:env_shebang],
|
||||||
|
@ -18,6 +18,18 @@ class Gem::ConfigFile
|
|||||||
DEFAULT_VERBOSITY = true
|
DEFAULT_VERBOSITY = true
|
||||||
DEFAULT_UPDATE_SOURCES = true
|
DEFAULT_UPDATE_SOURCES = true
|
||||||
|
|
||||||
|
##
|
||||||
|
# For Ruby packagers to set configuration defaults. Set in
|
||||||
|
# rubygems/defaults/operating_system.rb
|
||||||
|
|
||||||
|
OPERATING_SYSTEM_DEFAULTS = {}
|
||||||
|
|
||||||
|
##
|
||||||
|
# For Ruby implementers to set configuration defaults. Set in
|
||||||
|
# rubygems/defaults/#{RUBY_ENGINE}.rb
|
||||||
|
|
||||||
|
PLATFORM_DEFAULTS = {}
|
||||||
|
|
||||||
system_config_path =
|
system_config_path =
|
||||||
begin
|
begin
|
||||||
require 'Win32API'
|
require 'Win32API'
|
||||||
@ -98,8 +110,14 @@ class Gem::ConfigFile
|
|||||||
@verbose = DEFAULT_VERBOSITY
|
@verbose = DEFAULT_VERBOSITY
|
||||||
@update_sources = DEFAULT_UPDATE_SOURCES
|
@update_sources = DEFAULT_UPDATE_SOURCES
|
||||||
|
|
||||||
@hash = load_file(SYSTEM_WIDE_CONFIG_FILE)
|
operating_system_config = Marshal.load Marshal.dump(OPERATING_SYSTEM_DEFAULTS)
|
||||||
@hash.merge!(load_file(config_file_name.dup.untaint))
|
platform_config = Marshal.load Marshal.dump(PLATFORM_DEFAULTS)
|
||||||
|
system_config = load_file SYSTEM_WIDE_CONFIG_FILE
|
||||||
|
user_config = load_file config_file_name.dup.untaint
|
||||||
|
|
||||||
|
@hash = operating_system_config.merge platform_config
|
||||||
|
@hash = @hash.merge system_config
|
||||||
|
@hash = @hash.merge user_config
|
||||||
|
|
||||||
# HACK these override command-line args, which is bad
|
# HACK these override command-line args, which is bad
|
||||||
@backtrace = @hash[:backtrace] if @hash.key? :backtrace
|
@backtrace = @hash[:backtrace] if @hash.key? :backtrace
|
||||||
|
@ -19,9 +19,9 @@ module Gem
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Default gem path.
|
# Default gem load path.
|
||||||
def self.default_path
|
def self.default_path
|
||||||
default_dir
|
[File.join(ENV['HOME'], '.gem'), default_dir]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deduce Ruby's --program-prefix and --program-suffix from its install name.
|
# Deduce Ruby's --program-prefix and --program-suffix from its install name.
|
||||||
|
@ -133,7 +133,9 @@ class Gem::DependencyInstaller
|
|||||||
deps.each do |dep|
|
deps.each do |dep|
|
||||||
results = find_gems_with_sources(dep).reverse
|
results = find_gems_with_sources(dep).reverse
|
||||||
|
|
||||||
results.reject! do
|
results.reject! do |dep_spec,|
|
||||||
|
to_do.push dep_spec
|
||||||
|
|
||||||
@source_index.any? do |_, installed_spec|
|
@source_index.any? do |_, installed_spec|
|
||||||
dep.name == installed_spec.name and
|
dep.name == installed_spec.name and
|
||||||
dep.version_requirements.satisfied_by? installed_spec.version
|
dep.version_requirements.satisfied_by? installed_spec.version
|
||||||
@ -144,7 +146,6 @@ class Gem::DependencyInstaller
|
|||||||
next if seen[dep_spec.name]
|
next if seen[dep_spec.name]
|
||||||
@specs_and_sources << [dep_spec, source_uri]
|
@specs_and_sources << [dep_spec, source_uri]
|
||||||
dependency_list.add dep_spec
|
dependency_list.add dep_spec
|
||||||
to_do.push dep_spec
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -16,7 +16,7 @@ class Gem::Ext::RakeBuilder < Gem::Ext::Builder
|
|||||||
end
|
end
|
||||||
|
|
||||||
cmd = ENV['rake'] || 'rake'
|
cmd = ENV['rake'] || 'rake'
|
||||||
cmd << " RUBYARCHDIR=#{dest_path} RUBYLIBDIR=#{dest_path}"
|
cmd += " RUBYARCHDIR=#{dest_path} RUBYLIBDIR=#{dest_path}" # ENV is frozen
|
||||||
|
|
||||||
run cmd, results
|
run cmd, results
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ class Gem::Indexer
|
|||||||
open @specs_index, 'wb' do |io|
|
open @specs_index, 'wb' do |io|
|
||||||
specs = index.sort.map do |_, spec|
|
specs = index.sort.map do |_, spec|
|
||||||
platform = spec.original_platform
|
platform = spec.original_platform
|
||||||
platform = Gem::Platform::RUBY if platform.nil?
|
platform = Gem::Platform::RUBY if platform.nil? or platform.empty?
|
||||||
[spec.name, spec.version, platform]
|
[spec.name, spec.version, platform]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -129,7 +129,9 @@ class Gem::Indexer
|
|||||||
|
|
||||||
open @latest_specs_index, 'wb' do |io|
|
open @latest_specs_index, 'wb' do |io|
|
||||||
specs = index.latest_specs.sort.map do |spec|
|
specs = index.latest_specs.sort.map do |spec|
|
||||||
[spec.name, spec.version, spec.original_platform]
|
platform = spec.original_platform
|
||||||
|
platform = Gem::Platform::RUBY if platform.nil? or platform.empty?
|
||||||
|
[spec.name, spec.version, platform]
|
||||||
end
|
end
|
||||||
|
|
||||||
specs = compact_specs specs
|
specs = compact_specs specs
|
||||||
@ -283,10 +285,7 @@ class Gem::Indexer
|
|||||||
# Builds and installs indexicies.
|
# Builds and installs indexicies.
|
||||||
|
|
||||||
def generate_index
|
def generate_index
|
||||||
FileUtils.rm_rf @directory
|
make_temp_directories
|
||||||
FileUtils.mkdir_p @directory, :mode => 0700
|
|
||||||
FileUtils.mkdir_p @quick_marshal_dir
|
|
||||||
|
|
||||||
index = collect_specs
|
index = collect_specs
|
||||||
build_indicies index
|
build_indicies index
|
||||||
install_indicies
|
install_indicies
|
||||||
@ -317,10 +316,20 @@ class Gem::Indexer
|
|||||||
dst_name = File.join @dest_directory, file
|
dst_name = File.join @dest_directory, file
|
||||||
|
|
||||||
FileUtils.rm_rf dst_name, :verbose => verbose
|
FileUtils.rm_rf dst_name, :verbose => verbose
|
||||||
FileUtils.mv src_name, @dest_directory, :verbose => verbose
|
FileUtils.mv src_name, @dest_directory, :verbose => verbose,
|
||||||
|
:force => true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Make directories for index generation
|
||||||
|
|
||||||
|
def make_temp_directories
|
||||||
|
FileUtils.rm_rf @directory
|
||||||
|
FileUtils.mkdir_p @directory, :mode => 0700
|
||||||
|
FileUtils.mkdir_p @quick_marshal_dir
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Ensure +path+ and path with +extension+ are identical.
|
# Ensure +path+ and path with +extension+ are identical.
|
||||||
|
|
||||||
@ -343,6 +352,7 @@ class Gem::Indexer
|
|||||||
spec.description = sanitize_string(spec.description)
|
spec.description = sanitize_string(spec.description)
|
||||||
spec.post_install_message = sanitize_string(spec.post_install_message)
|
spec.post_install_message = sanitize_string(spec.post_install_message)
|
||||||
spec.authors = spec.authors.collect { |a| sanitize_string(a) }
|
spec.authors = spec.authors.collect { |a| sanitize_string(a) }
|
||||||
|
|
||||||
spec
|
spec
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -90,6 +90,13 @@ module Gem::InstallUpdateOptions
|
|||||||
options[:format_executable] = value
|
options[:format_executable] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_option(:"Install/Update", '--[no-]user-install',
|
||||||
|
'Install in user\'s home directory instead',
|
||||||
|
'of GEM_HOME. Defaults to using home directory',
|
||||||
|
'only if GEM_HOME is not writable.') do |value, options|
|
||||||
|
options[:user_install] = value
|
||||||
|
end
|
||||||
|
|
||||||
add_option(:"Install/Update", "--development",
|
add_option(:"Install/Update", "--development",
|
||||||
"Install any additional development",
|
"Install any additional development",
|
||||||
"dependencies") do |value, options|
|
"dependencies") do |value, options|
|
||||||
|
@ -85,6 +85,32 @@ class Gem::Installer
|
|||||||
raise Gem::InstallError, "invalid gem format for #{@gem}"
|
raise Gem::InstallError, "invalid gem format for #{@gem}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not File.writable? @gem_home or
|
||||||
|
# TODO: Shouldn't have to test for existence of bindir; tests need it.
|
||||||
|
(@gem_home.to_s == Gem.dir and File.exist? Gem.bindir and
|
||||||
|
not File.writable? Gem.bindir)
|
||||||
|
if options[:user_install] == false # You explicitly don't want to use ~
|
||||||
|
raise Gem::FilePermissionError, @gem_home
|
||||||
|
elsif options[:user_install].nil?
|
||||||
|
say "Warning: falling back to user-level install since #{@gem_home} and #{@bin_dir} aren't both writable."
|
||||||
|
end
|
||||||
|
options[:user_install] = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if options[:user_install]
|
||||||
|
@gem_home = File.join(ENV['HOME'], '.gem')
|
||||||
|
|
||||||
|
user_bin_dir = File.join(@gem_home, 'gems', 'bin')
|
||||||
|
if !ENV['PATH'].split(':').include?(user_bin_dir)
|
||||||
|
say "You don't have #{user_bin_dir} in your PATH."
|
||||||
|
say "You won't be able to run gem-installed executables until you add it."
|
||||||
|
end
|
||||||
|
|
||||||
|
Dir.mkdir @gem_home if ! File.directory? @gem_home
|
||||||
|
# If it's still not writable, you've got issues.
|
||||||
|
raise Gem::FilePermissionError, @gem_home if ! File.writable? @gem_home
|
||||||
|
end
|
||||||
|
|
||||||
@spec = @format.spec
|
@spec = @format.spec
|
||||||
|
|
||||||
@gem_dir = File.join(@gem_home, "gems", @spec.full_name).untaint
|
@gem_dir = File.join(@gem_home, "gems", @spec.full_name).untaint
|
||||||
@ -132,7 +158,6 @@ class Gem::Installer
|
|||||||
end
|
end
|
||||||
|
|
||||||
FileUtils.mkdir_p @gem_home unless File.directory? @gem_home
|
FileUtils.mkdir_p @gem_home unless File.directory? @gem_home
|
||||||
raise Gem::FilePermissionError, @gem_home unless File.writable? @gem_home
|
|
||||||
|
|
||||||
Gem.ensure_gem_subdirectories @gem_home
|
Gem.ensure_gem_subdirectories @gem_home
|
||||||
|
|
||||||
@ -206,6 +231,7 @@ class Gem::Installer
|
|||||||
|
|
||||||
file_name = File.join @gem_home, 'specifications',
|
file_name = File.join @gem_home, 'specifications',
|
||||||
"#{@spec.full_name}.gemspec"
|
"#{@spec.full_name}.gemspec"
|
||||||
|
|
||||||
file_name.untaint
|
file_name.untaint
|
||||||
|
|
||||||
File.open(file_name, "w") do |file|
|
File.open(file_name, "w") do |file|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
require 'net/http'
|
require 'net/http'
|
||||||
require 'stringio'
|
require 'stringio'
|
||||||
|
require 'time'
|
||||||
require 'uri'
|
require 'uri'
|
||||||
|
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
@ -74,7 +75,12 @@ class Gem::RemoteFetcher
|
|||||||
# always replaced.
|
# always replaced.
|
||||||
|
|
||||||
def download(spec, source_uri, install_dir = Gem.dir)
|
def download(spec, source_uri, install_dir = Gem.dir)
|
||||||
|
if File.writable?(install_dir)
|
||||||
cache_dir = File.join install_dir, 'cache'
|
cache_dir = File.join install_dir, 'cache'
|
||||||
|
else
|
||||||
|
cache_dir = File.join(ENV['HOME'], '.gem', 'cache')
|
||||||
|
end
|
||||||
|
|
||||||
gem_file_name = "#{spec.full_name}.gem"
|
gem_file_name = "#{spec.full_name}.gem"
|
||||||
local_gem_path = File.join cache_dir, gem_file_name
|
local_gem_path = File.join cache_dir, gem_file_name
|
||||||
|
|
||||||
@ -132,49 +138,27 @@ class Gem::RemoteFetcher
|
|||||||
##
|
##
|
||||||
# Downloads +uri+ and returns it as a String.
|
# Downloads +uri+ and returns it as a String.
|
||||||
|
|
||||||
def fetch_path(uri)
|
def fetch_path(uri, mtime = nil, head = false)
|
||||||
open_uri_or_path(uri) do |input|
|
data = open_uri_or_path(uri, mtime, head)
|
||||||
input.read
|
data = Gem.gunzip data if uri.to_s =~ /gz$/ and not head
|
||||||
end
|
data
|
||||||
rescue FetchError
|
rescue FetchError
|
||||||
raise
|
raise
|
||||||
rescue Timeout::Error
|
rescue Timeout::Error
|
||||||
raise FetchError.new('timed out', uri)
|
raise FetchError.new('timed out', uri)
|
||||||
rescue IOError, SocketError, SystemCallError => e
|
rescue IOError, SocketError, SystemCallError => e
|
||||||
raise FetchError.new("#{e.class}: #{e}", uri)
|
raise FetchError.new("#{e.class}: #{e}", uri)
|
||||||
rescue => e
|
|
||||||
raise FetchError.new("#{e.class}: #{e}", uri)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Returns the size of +uri+ in bytes.
|
# Returns the size of +uri+ in bytes.
|
||||||
|
|
||||||
def fetch_size(uri)
|
def fetch_size(uri) # TODO: phase this out
|
||||||
return File.size(get_file_uri_path(uri)) if file_uri? uri
|
response = fetch_path(uri, nil, true)
|
||||||
|
|
||||||
uri = URI.parse uri unless URI::Generic === uri
|
response['content-length'].to_i
|
||||||
|
|
||||||
raise ArgumentError, 'uri is not an HTTP URI' unless URI::HTTP === uri
|
|
||||||
|
|
||||||
response = request uri, Net::HTTP::Head
|
|
||||||
|
|
||||||
if response.code !~ /^2/ then
|
|
||||||
raise FetchError.new("bad response #{response.message} #{response.code}", uri)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if response['content-length'] then
|
|
||||||
return response['content-length'].to_i
|
|
||||||
else
|
|
||||||
response = http.get uri.request_uri
|
|
||||||
return response.body.size
|
|
||||||
end
|
|
||||||
|
|
||||||
rescue SocketError, SystemCallError, Timeout::Error => e
|
|
||||||
raise FetchError.new("#{e.message} (#{e.class})\n\tfetching size", uri)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def escape(str)
|
def escape(str)
|
||||||
return unless str
|
return unless str
|
||||||
URI.escape(str)
|
URI.escape(str)
|
||||||
@ -245,33 +229,35 @@ class Gem::RemoteFetcher
|
|||||||
# Read the data from the (source based) URI, but if it is a file:// URI,
|
# Read the data from the (source based) URI, but if it is a file:// URI,
|
||||||
# read from the filesystem instead.
|
# read from the filesystem instead.
|
||||||
|
|
||||||
def open_uri_or_path(uri, depth = 0, &block)
|
def open_uri_or_path(uri, last_modified = nil, head = false, depth = 0)
|
||||||
if file_uri?(uri)
|
raise "block is dead" if block_given?
|
||||||
open(get_file_uri_path(uri), &block)
|
|
||||||
else
|
|
||||||
uri = URI.parse uri unless URI::Generic === uri
|
|
||||||
|
|
||||||
response = request uri
|
return open(get_file_uri_path(uri)) if file_uri? uri
|
||||||
|
|
||||||
|
uri = URI.parse uri unless URI::Generic === uri
|
||||||
|
raise ArgumentError, 'uri is not an HTTP URI' unless URI::HTTP === uri
|
||||||
|
|
||||||
|
fetch_type = head ? Net::HTTP::Head : Net::HTTP::Get
|
||||||
|
response = request uri, fetch_type, last_modified
|
||||||
|
|
||||||
case response
|
case response
|
||||||
when Net::HTTPOK then
|
when Net::HTTPOK then
|
||||||
block.call(StringIO.new(response.body)) if block
|
head ? response : response.body
|
||||||
when Net::HTTPRedirection then
|
when Net::HTTPRedirection then
|
||||||
raise FetchError.new('too many redirects', uri) if depth > 10
|
raise FetchError.new('too many redirects', uri) if depth > 10
|
||||||
|
|
||||||
open_uri_or_path(response['Location'], depth + 1, &block)
|
open_uri_or_path(response['Location'], last_modified, head, depth + 1)
|
||||||
else
|
else
|
||||||
raise FetchError.new("bad response #{response.message} #{response.code}", uri)
|
raise FetchError.new("bad response #{response.message} #{response.code}", uri)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Performs a Net::HTTP request of type +request_class+ on +uri+ returning
|
# Performs a Net::HTTP request of type +request_class+ on +uri+ returning
|
||||||
# a Net::HTTP response object. request maintains a table of persistent
|
# a Net::HTTP response object. request maintains a table of persistent
|
||||||
# connections to reduce connect overhead.
|
# connections to reduce connect overhead.
|
||||||
|
|
||||||
def request(uri, request_class = Net::HTTP::Get)
|
def request(uri, request_class, last_modified = nil)
|
||||||
request = request_class.new uri.request_uri
|
request = request_class.new uri.request_uri
|
||||||
|
|
||||||
unless uri.nil? || uri.user.nil? || uri.user.empty? then
|
unless uri.nil? || uri.user.nil? || uri.user.empty? then
|
||||||
@ -287,9 +273,14 @@ class Gem::RemoteFetcher
|
|||||||
request.add_field 'Connection', 'keep-alive'
|
request.add_field 'Connection', 'keep-alive'
|
||||||
request.add_field 'Keep-Alive', '30'
|
request.add_field 'Keep-Alive', '30'
|
||||||
|
|
||||||
|
if last_modified then
|
||||||
|
request.add_field 'If-Modified-Since', last_modified.rfc2822
|
||||||
|
end
|
||||||
|
|
||||||
connection = connection_for uri
|
connection = connection_for uri
|
||||||
|
|
||||||
retried = false
|
retried = false
|
||||||
|
bad_response = false
|
||||||
|
|
||||||
# HACK work around EOFError bug in Net::HTTP
|
# HACK work around EOFError bug in Net::HTTP
|
||||||
# NOTE Errno::ECONNABORTED raised a lot on Windows, and make impossible
|
# NOTE Errno::ECONNABORTED raised a lot on Windows, and make impossible
|
||||||
@ -299,6 +290,13 @@ class Gem::RemoteFetcher
|
|||||||
response = connection.request request
|
response = connection.request request
|
||||||
say "#{request.method} #{response.code} #{response.message}: #{uri}" if
|
say "#{request.method} #{response.code} #{response.message}: #{uri}" if
|
||||||
Gem.configuration.really_verbose
|
Gem.configuration.really_verbose
|
||||||
|
rescue Net::HTTPBadResponse
|
||||||
|
reset connection
|
||||||
|
|
||||||
|
raise FetchError.new('too many bad responses', uri) if bad_response
|
||||||
|
|
||||||
|
bad_response = true
|
||||||
|
retry
|
||||||
rescue EOFError, Errno::ECONNABORTED, Errno::ECONNRESET
|
rescue EOFError, Errno::ECONNABORTED, Errno::ECONNRESET
|
||||||
requests = @requests[connection.object_id]
|
requests = @requests[connection.object_id]
|
||||||
say "connection reset after #{requests} requests, retrying" if
|
say "connection reset after #{requests} requests, retrying" if
|
||||||
@ -306,10 +304,8 @@ class Gem::RemoteFetcher
|
|||||||
|
|
||||||
raise FetchError.new('too many connection resets', uri) if retried
|
raise FetchError.new('too many connection resets', uri) if retried
|
||||||
|
|
||||||
@requests.delete connection.object_id
|
reset connection
|
||||||
|
|
||||||
connection.finish
|
|
||||||
connection.start
|
|
||||||
retried = true
|
retried = true
|
||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
@ -317,6 +313,16 @@ class Gem::RemoteFetcher
|
|||||||
response
|
response
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Resets HTTP connection +connection+.
|
||||||
|
|
||||||
|
def reset(connection)
|
||||||
|
@requests.delete connection.object_id
|
||||||
|
|
||||||
|
connection.finish
|
||||||
|
connection.start
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Checks if the provided string is a file:// URI.
|
# Checks if the provided string is a file:// URI.
|
||||||
|
|
||||||
|
@ -2,5 +2,5 @@
|
|||||||
# This file is auto-generated by build scripts.
|
# This file is auto-generated by build scripts.
|
||||||
# See: rake update_version
|
# See: rake update_version
|
||||||
module Gem
|
module Gem
|
||||||
RubyGemsVersion = '1.1.1'
|
RubyGemsVersion = '1.2.0.1824'
|
||||||
end
|
end
|
||||||
|
@ -183,29 +183,23 @@ class Gem::SpecFetcher
|
|||||||
end
|
end
|
||||||
|
|
||||||
def load_specs(source_uri, file)
|
def load_specs(source_uri, file)
|
||||||
file_name = "#{file}.#{Gem.marshal_version}.gz"
|
file_name = "#{file}.#{Gem.marshal_version}"
|
||||||
|
spec_path = source_uri + "#{file_name}.gz"
|
||||||
spec_path = source_uri + file_name
|
|
||||||
|
|
||||||
cache_dir = cache_dir spec_path
|
cache_dir = cache_dir spec_path
|
||||||
|
local_file = File.join(cache_dir, file_name)
|
||||||
local_file = File.join(cache_dir, file_name).chomp '.gz'
|
loaded = false
|
||||||
|
|
||||||
if File.exist? local_file then
|
if File.exist? local_file then
|
||||||
local_size = File.stat(local_file).size
|
spec_dump = @fetcher.fetch_path spec_path, File.mtime(local_file)
|
||||||
|
|
||||||
remote_file = spec_path.dup
|
if spec_dump.empty? then
|
||||||
remote_file.path = remote_file.path.chomp '.gz'
|
spec_dump = Gem.read_binary local_file
|
||||||
remote_size = @fetcher.fetch_size remote_file
|
else
|
||||||
|
loaded = true
|
||||||
spec_dump = Gem.read_binary local_file if remote_size == local_size
|
end
|
||||||
end
|
else
|
||||||
|
spec_dump = @fetcher.fetch_path spec_path
|
||||||
unless spec_dump then
|
|
||||||
loaded = true
|
loaded = true
|
||||||
|
|
||||||
spec_dump_gz = @fetcher.fetch_path spec_path
|
|
||||||
spec_dump = Gem.gunzip spec_dump_gz
|
|
||||||
end
|
end
|
||||||
|
|
||||||
specs = Marshal.load spec_dump
|
specs = Marshal.load spec_dump
|
||||||
|
@ -60,8 +60,10 @@ module Gem
|
|||||||
# changes.
|
# changes.
|
||||||
#--
|
#--
|
||||||
# When updating this number, be sure to also update #to_ruby.
|
# When updating this number, be sure to also update #to_ruby.
|
||||||
|
#
|
||||||
|
# NOTE RubyGems < 1.2 cannot load specification versions > 2.
|
||||||
|
|
||||||
CURRENT_SPECIFICATION_VERSION = 3
|
CURRENT_SPECIFICATION_VERSION = 2
|
||||||
|
|
||||||
##
|
##
|
||||||
# An informal list of changes to the specification. The highest-valued
|
# An informal list of changes to the specification. The highest-valued
|
||||||
@ -77,13 +79,10 @@ module Gem
|
|||||||
'Added "required_rubygems_version"',
|
'Added "required_rubygems_version"',
|
||||||
'Now forward-compatible with future versions',
|
'Now forward-compatible with future versions',
|
||||||
],
|
],
|
||||||
3 => [
|
|
||||||
'Added dependency types',
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# :stopdoc:
|
# :stopdoc:
|
||||||
MARSHAL_FIELDS = { -1 => 16, 1 => 16, 2 => 16, 3 => 16 }
|
MARSHAL_FIELDS = { -1 => 16, 1 => 16, 2 => 16 }
|
||||||
|
|
||||||
now = Time.at(Time.now.to_i)
|
now = Time.at(Time.now.to_i)
|
||||||
TODAY = now - ((now.to_i + now.gmt_offset) % 86400)
|
TODAY = now - ((now.to_i + now.gmt_offset) % 86400)
|
||||||
@ -248,10 +247,12 @@ module Gem
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
# Dump only crucial instance variables.
|
# Dump only crucial instance variables.
|
||||||
#
|
#--
|
||||||
# MAINTAIN ORDER!
|
# MAINTAIN ORDER!
|
||||||
def _dump(limit) # :nodoc:
|
|
||||||
|
def _dump(limit)
|
||||||
Marshal.dump [
|
Marshal.dump [
|
||||||
@rubygems_version,
|
@rubygems_version,
|
||||||
@specification_version,
|
@specification_version,
|
||||||
@ -273,7 +274,9 @@ module Gem
|
|||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
# Load custom marshal format, re-initializing defaults as needed
|
# Load custom marshal format, re-initializing defaults as needed
|
||||||
|
|
||||||
def self._load(str)
|
def self._load(str)
|
||||||
array = Marshal.load str
|
array = Marshal.load str
|
||||||
|
|
||||||
@ -282,9 +285,15 @@ module Gem
|
|||||||
|
|
||||||
current_version = CURRENT_SPECIFICATION_VERSION
|
current_version = CURRENT_SPECIFICATION_VERSION
|
||||||
|
|
||||||
field_count = MARSHAL_FIELDS[spec.specification_version]
|
field_count = if spec.specification_version > current_version then
|
||||||
|
spec.instance_variable_set :@specification_version,
|
||||||
|
current_version
|
||||||
|
MARSHAL_FIELDS[current_version]
|
||||||
|
else
|
||||||
|
MARSHAL_FIELDS[spec.specification_version]
|
||||||
|
end
|
||||||
|
|
||||||
if field_count.nil? or array.size < field_count then
|
if array.size < field_count then
|
||||||
raise TypeError, "invalid Gem::Specification format #{array.inspect}"
|
raise TypeError, "invalid Gem::Specification format #{array.inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class Gem::FakeFetcher
|
|||||||
@paths = []
|
@paths = []
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_path(path)
|
def fetch_path path, mtime = nil
|
||||||
path = path.to_s
|
path = path.to_s
|
||||||
@paths << path
|
@paths << path
|
||||||
raise ArgumentError, 'need full URI' unless path =~ %r'^http://'
|
raise ArgumentError, 'need full URI' unless path =~ %r'^http://'
|
||||||
@ -40,7 +40,12 @@ class Gem::FakeFetcher
|
|||||||
raise Gem::RemoteFetcher::FetchError.new('no data', path)
|
raise Gem::RemoteFetcher::FetchError.new('no data', path)
|
||||||
end
|
end
|
||||||
|
|
||||||
data.respond_to?(:call) ? data.call : data
|
if data.respond_to?(:call) then
|
||||||
|
data.call
|
||||||
|
else
|
||||||
|
data = Gem.gunzip data if path.to_s =~ /gz$/ unless data.empty?
|
||||||
|
data
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_size(path)
|
def fetch_size(path)
|
||||||
|
@ -41,7 +41,7 @@ class Gem::Uninstaller
|
|||||||
list = Gem.source_index.search(/^#{@gem}$/, @version)
|
list = Gem.source_index.search(/^#{@gem}$/, @version)
|
||||||
|
|
||||||
if list.empty? then
|
if list.empty? then
|
||||||
raise Gem::InstallError, "Unknown gem #{@gem}-#{@version}"
|
raise Gem::InstallError, "Unknown gem #{@gem} #{@version}"
|
||||||
elsif list.size > 1 && @force_all
|
elsif list.size > 1 && @force_all
|
||||||
remove_all(list.dup)
|
remove_all(list.dup)
|
||||||
remove_executables(list.last)
|
remove_executables(list.last)
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
at_exit { $SAFE = 1 }
|
at_exit { $SAFE = 1 }
|
||||||
|
|
||||||
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||||||
|
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
@ -24,6 +26,10 @@ module Gem
|
|||||||
def self.win_platform=(val)
|
def self.win_platform=(val)
|
||||||
@@win_platform = val
|
@@win_platform = val
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module DefaultUserInteraction
|
||||||
|
@ui = MockGemUi.new
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class RubyGemTestCase < Test::Unit::TestCase
|
class RubyGemTestCase < Test::Unit::TestCase
|
||||||
|
@ -279,16 +279,16 @@ class TestGem < RubyGemTestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_self_path_ENV_PATH
|
def test_self_path_ENV_PATH
|
||||||
Gem.clear_paths
|
Gem.send :set_paths, nil
|
||||||
path_count = Gem.path.size
|
path_count = Gem.path.size
|
||||||
path_count -= 1 if defined? APPLE_GEM_HOME
|
|
||||||
Gem.clear_paths
|
Gem.clear_paths
|
||||||
util_ensure_gem_dirs
|
|
||||||
|
|
||||||
ENV['GEM_PATH'] = @additional.join(File::PATH_SEPARATOR)
|
ENV['GEM_PATH'] = @additional.join(File::PATH_SEPARATOR)
|
||||||
|
|
||||||
assert_equal @additional, Gem.path[0,2]
|
assert_equal @additional, Gem.path[0,2]
|
||||||
assert_equal path_count + @additional.size, Gem.path.size
|
|
||||||
|
assert_equal path_count + @additional.size, Gem.path.size,
|
||||||
|
"extra path components: #{Gem.path[2..-1].inspect}"
|
||||||
assert_match Gem.dir, Gem.path.last
|
assert_match Gem.dir, Gem.path.last
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -337,6 +337,7 @@ class TestGem < RubyGemTestCase
|
|||||||
|
|
||||||
file_name = File.expand_path __FILE__
|
file_name = File.expand_path __FILE__
|
||||||
prefix = File.dirname File.dirname(file_name)
|
prefix = File.dirname File.dirname(file_name)
|
||||||
|
prefix = File.dirname prefix if File.basename(prefix) == 'test'
|
||||||
|
|
||||||
Gem::ConfigMap[:libdir] = prefix
|
Gem::ConfigMap[:libdir] = prefix
|
||||||
|
|
||||||
@ -350,6 +351,7 @@ class TestGem < RubyGemTestCase
|
|||||||
|
|
||||||
file_name = File.expand_path __FILE__
|
file_name = File.expand_path __FILE__
|
||||||
prefix = File.dirname File.dirname(file_name)
|
prefix = File.dirname File.dirname(file_name)
|
||||||
|
prefix = File.dirname prefix if File.basename(prefix) == 'test'
|
||||||
|
|
||||||
Gem::ConfigMap[:sitelibdir] = prefix
|
Gem::ConfigMap[:sitelibdir] = prefix
|
||||||
|
|
||||||
|
@ -22,11 +22,15 @@ class TestGemConfigFile < RubyGemTestCase
|
|||||||
Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE
|
Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE
|
||||||
Gem::ConfigFile.send :const_set, :SYSTEM_WIDE_CONFIG_FILE,
|
Gem::ConfigFile.send :const_set, :SYSTEM_WIDE_CONFIG_FILE,
|
||||||
File.join(@tempdir, 'system-gemrc')
|
File.join(@tempdir, 'system-gemrc')
|
||||||
|
Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS.clear
|
||||||
|
Gem::ConfigFile::PLATFORM_DEFAULTS.clear
|
||||||
|
|
||||||
util_config_file
|
util_config_file
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
|
Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS.clear
|
||||||
|
Gem::ConfigFile::PLATFORM_DEFAULTS.clear
|
||||||
Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE
|
Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE
|
||||||
Gem::ConfigFile.send :const_set, :SYSTEM_WIDE_CONFIG_FILE,
|
Gem::ConfigFile.send :const_set, :SYSTEM_WIDE_CONFIG_FILE,
|
||||||
@orig_SYSTEM_WIDE_CONFIG_FILE
|
@orig_SYSTEM_WIDE_CONFIG_FILE
|
||||||
@ -84,6 +88,48 @@ class TestGemConfigFile < RubyGemTestCase
|
|||||||
assert_equal @temp_conf, @cfg.config_file_name
|
assert_equal @temp_conf, @cfg.config_file_name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_initialize_operating_system_override
|
||||||
|
Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS[:bulk_threshold] = 1
|
||||||
|
Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS['install'] = '--no-env-shebang'
|
||||||
|
|
||||||
|
Gem::ConfigFile::PLATFORM_DEFAULTS[:bulk_threshold] = 2
|
||||||
|
|
||||||
|
util_config_file
|
||||||
|
|
||||||
|
assert_equal 2, @cfg.bulk_threshold
|
||||||
|
assert_equal '--no-env-shebang', @cfg[:install]
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_initialize_platform_override
|
||||||
|
Gem::ConfigFile::PLATFORM_DEFAULTS[:bulk_threshold] = 2
|
||||||
|
Gem::ConfigFile::PLATFORM_DEFAULTS['install'] = '--no-env-shebang'
|
||||||
|
|
||||||
|
File.open Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE, 'w' do |fp|
|
||||||
|
fp.puts ":bulk_threshold: 3"
|
||||||
|
end
|
||||||
|
|
||||||
|
util_config_file
|
||||||
|
|
||||||
|
assert_equal 3, @cfg.bulk_threshold
|
||||||
|
assert_equal '--no-env-shebang', @cfg[:install]
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_initialize_system_wide_override
|
||||||
|
File.open Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE, 'w' do |fp|
|
||||||
|
fp.puts ":backtrace: false"
|
||||||
|
fp.puts ":bulk_threshold: 2048"
|
||||||
|
end
|
||||||
|
|
||||||
|
File.open @temp_conf, 'w' do |fp|
|
||||||
|
fp.puts ":backtrace: true"
|
||||||
|
end
|
||||||
|
|
||||||
|
util_config_file
|
||||||
|
|
||||||
|
assert_equal 2048, @cfg.bulk_threshold
|
||||||
|
assert_equal true, @cfg.backtrace
|
||||||
|
end
|
||||||
|
|
||||||
def test_handle_arguments
|
def test_handle_arguments
|
||||||
args = %w[--backtrace --bunch --of --args here]
|
args = %w[--backtrace --bunch --of --args here]
|
||||||
|
|
||||||
@ -222,23 +268,6 @@ class TestGemConfigFile < RubyGemTestCase
|
|||||||
assert_equal %w[http://even-more-gems.example.com], Gem.sources
|
assert_equal %w[http://even-more-gems.example.com], Gem.sources
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_global_config_file
|
|
||||||
File.open(@temp_conf, 'w') do |fp|
|
|
||||||
fp.puts ":backtrace: true"
|
|
||||||
end
|
|
||||||
|
|
||||||
File.open(File.join(Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE),
|
|
||||||
'w') do |fp|
|
|
||||||
fp.puts ":backtrace: false"
|
|
||||||
fp.puts ":bulk_threshold: 2048"
|
|
||||||
end
|
|
||||||
|
|
||||||
util_config_file
|
|
||||||
|
|
||||||
assert_equal 2048, @cfg.bulk_threshold
|
|
||||||
assert @cfg.backtrace
|
|
||||||
end
|
|
||||||
|
|
||||||
def util_config_file(args = @cfg_args)
|
def util_config_file(args = @cfg_args)
|
||||||
@cfg = Gem::ConfigFile.new args
|
@cfg = Gem::ConfigFile.new args
|
||||||
end
|
end
|
||||||
|
@ -66,6 +66,31 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|||||||
assert_equal [@a1], inst.installed_gems
|
assert_equal [@a1], inst.installed_gems
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_install_all_dependencies
|
||||||
|
e1, e1_gem = util_gem 'e', '1' do |s|
|
||||||
|
s.add_dependency 'b'
|
||||||
|
end
|
||||||
|
|
||||||
|
util_clear_gems
|
||||||
|
|
||||||
|
FileUtils.mv @a1_gem, @tempdir
|
||||||
|
FileUtils.mv @b1_gem, @tempdir
|
||||||
|
FileUtils.mv e1_gem, @tempdir
|
||||||
|
inst = nil
|
||||||
|
|
||||||
|
Dir.chdir @tempdir do
|
||||||
|
inst = Gem::DependencyInstaller.new :ignore_dependencies => true
|
||||||
|
inst.install 'b'
|
||||||
|
end
|
||||||
|
|
||||||
|
Dir.chdir @tempdir do
|
||||||
|
inst = Gem::DependencyInstaller.new
|
||||||
|
inst.install 'e'
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal %w[e-1 a-1], inst.installed_gems.map { |s| s.full_name }
|
||||||
|
end
|
||||||
|
|
||||||
def test_install_cache_dir
|
def test_install_cache_dir
|
||||||
FileUtils.mv @a1_gem, @tempdir
|
FileUtils.mv @a1_gem, @tempdir
|
||||||
FileUtils.mv @b1_gem, @tempdir
|
FileUtils.mv @b1_gem, @tempdir
|
||||||
|
@ -29,12 +29,12 @@ class TestGemExtConfigureBuilder < RubyGemTestCase
|
|||||||
Gem::Ext::ConfigureBuilder.build nil, nil, @dest_path, output
|
Gem::Ext::ConfigureBuilder.build nil, nil, @dest_path, output
|
||||||
end
|
end
|
||||||
|
|
||||||
expected = [
|
assert_equal "sh ./configure --prefix=#{@dest_path}", output.shift
|
||||||
"sh ./configure --prefix=#{@dest_path}",
|
assert_equal "", output.shift
|
||||||
"", "make", "ok\n", "make install", "ok\n"
|
assert_equal "make", output.shift
|
||||||
]
|
assert_match(/^ok$/m, output.shift)
|
||||||
|
assert_equal "make install", output.shift
|
||||||
assert_equal expected, output
|
assert_match(/^ok$/m, output.shift)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_build_fail
|
def test_self_build_fail
|
||||||
|
@ -34,7 +34,7 @@ class TestGemExtRakeBuilder < RubyGemTestCase
|
|||||||
expected = [
|
expected = [
|
||||||
"#{Gem.ruby} mkrf_conf.rb",
|
"#{Gem.ruby} mkrf_conf.rb",
|
||||||
"",
|
"",
|
||||||
"rake RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}",
|
"#{ENV['rake'] || 'rake'} RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}",
|
||||||
"(in #{realdir})\n"
|
"(in #{realdir})\n"
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ rake failed:
|
|||||||
|
|
||||||
#{Gem.ruby} mkrf_conf.rb
|
#{Gem.ruby} mkrf_conf.rb
|
||||||
|
|
||||||
rake RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}
|
#{ENV['rake'] || 'rake'} RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
assert_equal expected, error.message.split("\n")[0..4].join("\n")
|
assert_equal expected, error.message.split("\n")[0..4].join("\n")
|
||||||
|
@ -21,7 +21,6 @@ class TestGemIndexer < RubyGemTestCase
|
|||||||
util_make_gems
|
util_make_gems
|
||||||
|
|
||||||
@d2_0 = quick_gem 'd', '2.0'
|
@d2_0 = quick_gem 'd', '2.0'
|
||||||
write_file File.join(*%W[gems #{@d2_0.original_name} lib code.rb]) do end
|
|
||||||
util_build_gem @d2_0
|
util_build_gem @d2_0
|
||||||
|
|
||||||
gems = File.join(@tempdir, 'gems')
|
gems = File.join(@tempdir, 'gems')
|
||||||
@ -38,6 +37,41 @@ class TestGemIndexer < RubyGemTestCase
|
|||||||
@indexer.directory
|
@indexer.directory
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_build_indicies
|
||||||
|
spec = quick_gem 'd', '2.0'
|
||||||
|
spec.instance_variable_set :@original_platform, ''
|
||||||
|
|
||||||
|
@indexer.make_temp_directories
|
||||||
|
|
||||||
|
index = Gem::SourceIndex.new
|
||||||
|
index.add_spec spec
|
||||||
|
|
||||||
|
use_ui @ui do
|
||||||
|
@indexer.build_indicies index
|
||||||
|
end
|
||||||
|
|
||||||
|
specs_path = File.join @indexer.directory, "specs.#{@marshal_version}"
|
||||||
|
specs_dump = Gem.read_binary specs_path
|
||||||
|
specs = Marshal.load specs_dump
|
||||||
|
|
||||||
|
expected = [
|
||||||
|
['d', Gem::Version.new('2.0'), 'ruby'],
|
||||||
|
]
|
||||||
|
|
||||||
|
assert_equal expected, specs, 'specs'
|
||||||
|
|
||||||
|
latest_specs_path = File.join @indexer.directory,
|
||||||
|
"latest_specs.#{@marshal_version}"
|
||||||
|
latest_specs_dump = Gem.read_binary latest_specs_path
|
||||||
|
latest_specs = Marshal.load latest_specs_dump
|
||||||
|
|
||||||
|
expected = [
|
||||||
|
['d', Gem::Version.new('2.0'), 'ruby'],
|
||||||
|
]
|
||||||
|
|
||||||
|
assert_equal expected, latest_specs, 'latest_specs'
|
||||||
|
end
|
||||||
|
|
||||||
def test_generate_index
|
def test_generate_index
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@indexer.generate_index
|
@indexer.generate_index
|
||||||
|
@ -1,20 +1,21 @@
|
|||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
|
require File.join(File.expand_path(File.dirname(__FILE__)),
|
||||||
|
'gem_installer_test_case')
|
||||||
require 'rubygems/install_update_options'
|
require 'rubygems/install_update_options'
|
||||||
require 'rubygems/command'
|
require 'rubygems/command'
|
||||||
|
|
||||||
class TestGemInstallUpdateOptions < RubyGemTestCase
|
class TestGemInstallUpdateOptions < GemInstallerTestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
|
|
||||||
@cmd = Gem::Command.new 'dummy', 'dummy'
|
@cmd = Gem::Command.new 'dummy', 'dummy'
|
||||||
@cmd.extend Gem::InstallUpdateOptions
|
@cmd.extend Gem::InstallUpdateOptions
|
||||||
|
@cmd.add_install_update_options
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_add_install_update_options
|
def test_add_install_update_options
|
||||||
@cmd.add_install_update_options
|
|
||||||
|
|
||||||
args = %w[-i /install_to --rdoc --ri -E -f -t -w -P HighSecurity
|
args = %w[-i /install_to --rdoc --ri -E -f -t -w -P HighSecurity
|
||||||
--ignore-dependencies --format-exec --include-dependencies]
|
--ignore-dependencies --format-exec --include-dependencies]
|
||||||
|
|
||||||
@ -22,8 +23,6 @@ class TestGemInstallUpdateOptions < RubyGemTestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_security_policy
|
def test_security_policy
|
||||||
@cmd.add_install_update_options
|
|
||||||
|
|
||||||
@cmd.handle_options %w[-P HighSecurity]
|
@cmd.handle_options %w[-P HighSecurity]
|
||||||
|
|
||||||
assert_equal Gem::Security::HighSecurity, @cmd.options[:security_policy]
|
assert_equal Gem::Security::HighSecurity, @cmd.options[:security_policy]
|
||||||
@ -37,4 +36,26 @@ class TestGemInstallUpdateOptions < RubyGemTestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_user_install_enabled
|
||||||
|
@cmd.handle_options %w[--user-install]
|
||||||
|
|
||||||
|
@installer = Gem::Installer.new @gem, @cmd.options
|
||||||
|
@installer.install
|
||||||
|
assert File.exist?(File.join(@userhome, '.gem', 'gems'))
|
||||||
|
assert File.exist?(File.join(@userhome, '.gem', 'gems',
|
||||||
|
@spec.full_name))
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_user_install_disabled_read_only
|
||||||
|
@cmd.handle_options %w[--no-user-install]
|
||||||
|
|
||||||
|
File.chmod 0755, @userhome
|
||||||
|
FileUtils.chmod 0000, @gemhome
|
||||||
|
|
||||||
|
assert_raises(Gem::FilePermissionError) do
|
||||||
|
@installer = Gem::Installer.new @gem, @cmd.options
|
||||||
|
end
|
||||||
|
ensure
|
||||||
|
FileUtils.chmod 0755, @gemhome
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -515,6 +515,7 @@ load 'my_exec'
|
|||||||
spec = quick_gem 'a' do |s| s.platform = Gem::Platform.new 'mswin32' end
|
spec = quick_gem 'a' do |s| s.platform = Gem::Platform.new 'mswin32' end
|
||||||
gem = File.join @tempdir, "#{spec.full_name}.gem"
|
gem = File.join @tempdir, "#{spec.full_name}.gem"
|
||||||
|
|
||||||
|
Dir.mkdir util_inst_bindir
|
||||||
util_build_gem spec
|
util_build_gem spec
|
||||||
FileUtils.mv File.join(@gemhome, 'cache', "#{spec.full_name}.gem"),
|
FileUtils.mv File.join(@gemhome, 'cache', "#{spec.full_name}.gem"),
|
||||||
@tempdir
|
@tempdir
|
||||||
@ -525,6 +526,7 @@ load 'my_exec'
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_install
|
def test_install
|
||||||
|
Dir.mkdir util_inst_bindir
|
||||||
util_setup_gem
|
util_setup_gem
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@ -593,6 +595,7 @@ load 'my_exec'
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_install_ignore_dependencies
|
def test_install_ignore_dependencies
|
||||||
|
Dir.mkdir util_inst_bindir
|
||||||
@spec.add_dependency 'b', '> 5'
|
@spec.add_dependency 'b', '> 5'
|
||||||
util_setup_gem
|
util_setup_gem
|
||||||
@installer.ignore_dependencies = true
|
@installer.ignore_dependencies = true
|
||||||
@ -634,6 +637,43 @@ load 'my_exec'
|
|||||||
assert File.exist?(File.join(@gemhome, 'specifications',
|
assert File.exist?(File.join(@gemhome, 'specifications',
|
||||||
"#{@spec.full_name}.gemspec"))
|
"#{@spec.full_name}.gemspec"))
|
||||||
end
|
end
|
||||||
|
unless win_platform? # File.chmod doesn't work
|
||||||
|
def test_install_user_local_fallback
|
||||||
|
Dir.mkdir util_inst_bindir
|
||||||
|
File.chmod 0755, @userhome
|
||||||
|
File.chmod 0000, util_inst_bindir
|
||||||
|
File.chmod 0000, Gem.dir
|
||||||
|
install_dir = File.join @userhome, '.gem', 'gems', @spec.full_name
|
||||||
|
@spec.executables = ["executable"]
|
||||||
|
|
||||||
|
use_ui @ui do
|
||||||
|
util_setup_gem
|
||||||
|
@installer.install
|
||||||
|
end
|
||||||
|
|
||||||
|
assert File.exist?(File.join(install_dir, 'lib', 'code.rb'))
|
||||||
|
assert File.exist?(File.join(@userhome, '.gem', 'bin', 'executable'))
|
||||||
|
ensure
|
||||||
|
File.chmod 0755, Gem.dir
|
||||||
|
File.chmod 0755, util_inst_bindir
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_install_bindir_read_only
|
||||||
|
Dir.mkdir util_inst_bindir
|
||||||
|
File.chmod 0755, @userhome
|
||||||
|
File.chmod 0000, util_inst_bindir
|
||||||
|
|
||||||
|
use_ui @ui do
|
||||||
|
setup
|
||||||
|
util_setup_gem
|
||||||
|
@installer.install
|
||||||
|
end
|
||||||
|
|
||||||
|
assert File.exist?(File.join(@userhome, '.gem', 'bin', 'executable'))
|
||||||
|
ensure
|
||||||
|
File.chmod 0755, util_inst_bindir
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_install_with_message
|
def test_install_with_message
|
||||||
@spec.post_install_message = 'I am a shiny gem!'
|
@spec.post_install_message = 'I am a shiny gem!'
|
||||||
@ -647,22 +687,6 @@ load 'my_exec'
|
|||||||
assert_match %r|I am a shiny gem!|, @ui.output
|
assert_match %r|I am a shiny gem!|, @ui.output
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_install_writable
|
|
||||||
util_setup_gem
|
|
||||||
|
|
||||||
orig_mode = File.stat(Gem.dir).mode
|
|
||||||
File.chmod 0000, Gem.dir
|
|
||||||
|
|
||||||
e = assert_raise Gem::FilePermissionError do
|
|
||||||
@installer.install
|
|
||||||
end
|
|
||||||
|
|
||||||
assert_equal "You don't have write permissions into the #{@gemhome} directory.",
|
|
||||||
e.message
|
|
||||||
ensure
|
|
||||||
File.chmod orig_mode, Gem.dir
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_install_wrong_ruby_version
|
def test_install_wrong_ruby_version
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
installer = Gem::Installer.new old_ruby_required
|
installer = Gem::Installer.new old_ruby_required
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
|
||||||
require 'rubygems/commands/outdated_command'
|
|
||||||
|
|
||||||
class TestGemOutdatedCommand < RubyGemTestCase
|
|
||||||
|
|
||||||
def setup
|
|
||||||
super
|
|
||||||
|
|
||||||
@cmd = Gem::Commands::OutdatedCommand.new
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_initialize
|
|
||||||
assert @cmd.handles?(%W[--platform #{Gem::Platform.local}])
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_execute
|
|
||||||
local_01 = quick_gem 'foo', '0.1'
|
|
||||||
local_02 = quick_gem 'foo', '0.2'
|
|
||||||
remote_10 = quick_gem 'foo', '1.0'
|
|
||||||
remote_20 = quick_gem 'foo', '2.0'
|
|
||||||
|
|
||||||
remote_spec_file = File.join @gemhome, 'specifications',
|
|
||||||
remote_10.full_name + ".gemspec"
|
|
||||||
FileUtils.rm remote_spec_file
|
|
||||||
|
|
||||||
remote_spec_file = File.join @gemhome, 'specifications',
|
|
||||||
remote_20.full_name + ".gemspec"
|
|
||||||
FileUtils.rm remote_spec_file
|
|
||||||
|
|
||||||
util_setup_source_info_cache remote_10, remote_20
|
|
||||||
|
|
||||||
use_ui @ui do @cmd.execute end
|
|
||||||
|
|
||||||
assert_equal "foo (0.2 < 2.0)\n", @ui.output
|
|
||||||
assert_equal "", @ui.error
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
@ -10,6 +10,7 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
|||||||
require 'webrick'
|
require 'webrick'
|
||||||
require 'zlib'
|
require 'zlib'
|
||||||
require 'rubygems/remote_fetcher'
|
require 'rubygems/remote_fetcher'
|
||||||
|
require 'ostruct'
|
||||||
|
|
||||||
# = Testing Proxy Settings
|
# = Testing Proxy Settings
|
||||||
#
|
#
|
||||||
@ -106,6 +107,8 @@ gems:
|
|||||||
@a1, @a1_gem = util_gem 'a', '1' do |s| s.executables << 'a_bin' end
|
@a1, @a1_gem = util_gem 'a', '1' do |s| s.executables << 'a_bin' end
|
||||||
|
|
||||||
Gem::RemoteFetcher.fetcher = nil
|
Gem::RemoteFetcher.fetcher = nil
|
||||||
|
|
||||||
|
@fetcher = Gem::RemoteFetcher.fetcher
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_fetcher
|
def test_self_fetcher
|
||||||
@ -117,7 +120,10 @@ gems:
|
|||||||
def test_self_fetcher_with_proxy
|
def test_self_fetcher_with_proxy
|
||||||
proxy_uri = 'http://proxy.example.com'
|
proxy_uri = 'http://proxy.example.com'
|
||||||
Gem.configuration[:http_proxy] = proxy_uri
|
Gem.configuration[:http_proxy] = proxy_uri
|
||||||
|
Gem::RemoteFetcher.fetcher = nil
|
||||||
|
|
||||||
fetcher = Gem::RemoteFetcher.fetcher
|
fetcher = Gem::RemoteFetcher.fetcher
|
||||||
|
|
||||||
assert_not_nil fetcher
|
assert_not_nil fetcher
|
||||||
assert_kind_of Gem::RemoteFetcher, fetcher
|
assert_kind_of Gem::RemoteFetcher, fetcher
|
||||||
assert_equal proxy_uri, fetcher.instance_variable_get(:@proxy_uri).to_s
|
assert_equal proxy_uri, fetcher.instance_variable_get(:@proxy_uri).to_s
|
||||||
@ -145,7 +151,7 @@ gems:
|
|||||||
def test_fetch_size_socket_error
|
def test_fetch_size_socket_error
|
||||||
fetcher = Gem::RemoteFetcher.new nil
|
fetcher = Gem::RemoteFetcher.new nil
|
||||||
def fetcher.connection_for(uri)
|
def fetcher.connection_for(uri)
|
||||||
raise SocketError
|
raise SocketError, "tarded"
|
||||||
end
|
end
|
||||||
|
|
||||||
uri = 'http://gems.example.com/yaml'
|
uri = 'http://gems.example.com/yaml'
|
||||||
@ -153,15 +159,13 @@ gems:
|
|||||||
fetcher.fetch_size uri
|
fetcher.fetch_size uri
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal "SocketError (SocketError)\n\tfetching size (#{uri})",
|
assert_equal "SocketError: tarded (#{uri})", e.message
|
||||||
e.message
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_no_proxy
|
def test_no_proxy
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
fetcher = Gem::RemoteFetcher.new nil
|
assert_data_from_server @fetcher.fetch_path(@server_uri)
|
||||||
assert_data_from_server fetcher.fetch_path(@server_uri)
|
assert_equal SERVER_DATA.size, @fetcher.fetch_size(@server_uri)
|
||||||
assert_equal SERVER_DATA.size, fetcher.fetch_size(@server_uri)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -238,6 +242,7 @@ gems:
|
|||||||
install_dir = File.join @tempdir, 'more_gems'
|
install_dir = File.join @tempdir, 'more_gems'
|
||||||
|
|
||||||
a1_cache_gem = File.join install_dir, 'cache', "#{@a1.full_name}.gem"
|
a1_cache_gem = File.join install_dir, 'cache', "#{@a1.full_name}.gem"
|
||||||
|
FileUtils.mkdir_p(File.dirname(a1_cache_gem))
|
||||||
actual = fetcher.download(@a1, 'http://gems.example.com', install_dir)
|
actual = fetcher.download(@a1, 'http://gems.example.com', install_dir)
|
||||||
|
|
||||||
assert_equal a1_cache_gem, actual
|
assert_equal a1_cache_gem, actual
|
||||||
@ -247,7 +252,7 @@ gems:
|
|||||||
assert File.exist?(a1_cache_gem)
|
assert File.exist?(a1_cache_gem)
|
||||||
end
|
end
|
||||||
|
|
||||||
unless win_platform? then # File.chmod doesn't work
|
unless win_platform? # File.chmod doesn't work
|
||||||
def test_download_local_read_only
|
def test_download_local_read_only
|
||||||
FileUtils.mv @a1_gem, @tempdir
|
FileUtils.mv @a1_gem, @tempdir
|
||||||
local_path = File.join @tempdir, "#{@a1.full_name}.gem"
|
local_path = File.join @tempdir, "#{@a1.full_name}.gem"
|
||||||
@ -263,6 +268,19 @@ gems:
|
|||||||
ensure
|
ensure
|
||||||
File.chmod 0755, File.join(@gemhome, 'cache')
|
File.chmod 0755, File.join(@gemhome, 'cache')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_download_read_only
|
||||||
|
File.chmod 0555, File.join(@gemhome, 'cache')
|
||||||
|
File.chmod 0555, File.join(@gemhome)
|
||||||
|
|
||||||
|
fetcher = util_fuck_with_fetcher File.read(@a1_gem)
|
||||||
|
fetcher.download(@a1, 'http://gems.example.com')
|
||||||
|
assert File.exist?(File.join(@userhome, '.gem',
|
||||||
|
'cache', "#{@a1.full_name}.gem"))
|
||||||
|
ensure
|
||||||
|
File.chmod 0755, File.join(@gemhome)
|
||||||
|
File.chmod 0755, File.join(@gemhome, 'cache')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_download_platform_legacy
|
def test_download_platform_legacy
|
||||||
@ -363,10 +381,22 @@ gems:
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_fetch_path_gzip
|
||||||
|
fetcher = Gem::RemoteFetcher.new nil
|
||||||
|
|
||||||
|
def fetcher.open_uri_or_path(uri, mtime, head = nil)
|
||||||
|
Gem.gzip 'foo'
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal 'foo', fetcher.fetch_path(@uri + 'foo.gz')
|
||||||
|
end
|
||||||
|
|
||||||
def test_fetch_path_io_error
|
def test_fetch_path_io_error
|
||||||
fetcher = Gem::RemoteFetcher.new nil
|
fetcher = Gem::RemoteFetcher.new nil
|
||||||
|
|
||||||
def fetcher.open_uri_or_path(uri) raise EOFError; end
|
def fetcher.open_uri_or_path(uri, mtime, head = nil)
|
||||||
|
raise EOFError
|
||||||
|
end
|
||||||
|
|
||||||
e = assert_raise Gem::RemoteFetcher::FetchError do
|
e = assert_raise Gem::RemoteFetcher::FetchError do
|
||||||
fetcher.fetch_path 'uri'
|
fetcher.fetch_path 'uri'
|
||||||
@ -379,7 +409,9 @@ gems:
|
|||||||
def test_fetch_path_socket_error
|
def test_fetch_path_socket_error
|
||||||
fetcher = Gem::RemoteFetcher.new nil
|
fetcher = Gem::RemoteFetcher.new nil
|
||||||
|
|
||||||
def fetcher.open_uri_or_path(uri) raise SocketError; end
|
def fetcher.open_uri_or_path(uri, mtime, head = nil)
|
||||||
|
raise SocketError
|
||||||
|
end
|
||||||
|
|
||||||
e = assert_raise Gem::RemoteFetcher::FetchError do
|
e = assert_raise Gem::RemoteFetcher::FetchError do
|
||||||
fetcher.fetch_path 'uri'
|
fetcher.fetch_path 'uri'
|
||||||
@ -392,7 +424,7 @@ gems:
|
|||||||
def test_fetch_path_system_call_error
|
def test_fetch_path_system_call_error
|
||||||
fetcher = Gem::RemoteFetcher.new nil
|
fetcher = Gem::RemoteFetcher.new nil
|
||||||
|
|
||||||
def fetcher.open_uri_or_path(uri);
|
def fetcher.open_uri_or_path(uri, mtime = nil, head = nil)
|
||||||
raise Errno::ECONNREFUSED, 'connect(2)'
|
raise Errno::ECONNREFUSED, 'connect(2)'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -405,6 +437,16 @@ gems:
|
|||||||
assert_equal 'uri', e.uri
|
assert_equal 'uri', e.uri
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_fetch_path_unmodified
|
||||||
|
fetcher = Gem::RemoteFetcher.new nil
|
||||||
|
|
||||||
|
def fetcher.open_uri_or_path(uri, mtime, head = nil)
|
||||||
|
''
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal '', fetcher.fetch_path(URI.parse(@gem_repo), Time.at(0))
|
||||||
|
end
|
||||||
|
|
||||||
def test_get_proxy_from_env_empty
|
def test_get_proxy_from_env_empty
|
||||||
orig_env_HTTP_PROXY = ENV['HTTP_PROXY']
|
orig_env_HTTP_PROXY = ENV['HTTP_PROXY']
|
||||||
orig_env_http_proxy = ENV['http_proxy']
|
orig_env_http_proxy = ENV['http_proxy']
|
||||||
@ -475,9 +517,9 @@ gems:
|
|||||||
conn = { 'gems.example.com:80' => conn }
|
conn = { 'gems.example.com:80' => conn }
|
||||||
fetcher.instance_variable_set :@connections, conn
|
fetcher.instance_variable_set :@connections, conn
|
||||||
|
|
||||||
fetcher.send :open_uri_or_path, 'http://gems.example.com/redirect' do |io|
|
data = fetcher.open_uri_or_path 'http://gems.example.com/redirect'
|
||||||
assert_equal 'real_path', io.read
|
|
||||||
end
|
assert_equal 'real_path', data
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_open_uri_or_path_limited_redirects
|
def test_open_uri_or_path_limited_redirects
|
||||||
@ -495,29 +537,43 @@ gems:
|
|||||||
fetcher.instance_variable_set :@connections, conn
|
fetcher.instance_variable_set :@connections, conn
|
||||||
|
|
||||||
e = assert_raise Gem::RemoteFetcher::FetchError do
|
e = assert_raise Gem::RemoteFetcher::FetchError do
|
||||||
fetcher.send :open_uri_or_path, 'http://gems.example.com/redirect'
|
fetcher.open_uri_or_path 'http://gems.example.com/redirect'
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal 'too many redirects (http://gems.example.com/redirect)',
|
assert_equal 'too many redirects (http://gems.example.com/redirect)',
|
||||||
e.message
|
e.message
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_zip
|
def test_request
|
||||||
use_ui @ui do
|
uri = URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}"
|
||||||
self.class.enable_zip = true
|
util_stub_connection_for :body => :junk, :code => 200
|
||||||
fetcher = Gem::RemoteFetcher.new nil
|
|
||||||
assert_equal SERVER_DATA.size, fetcher.fetch_size(@server_uri), "probably not from proxy"
|
response = @fetcher.request uri, Net::HTTP::Get
|
||||||
zip_data = fetcher.fetch_path(@server_z_uri)
|
|
||||||
assert zip_data.size < SERVER_DATA.size, "Zipped data should be smaller"
|
assert_equal 200, response.code
|
||||||
end
|
assert_equal :junk, response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_no_zip
|
def test_request_head
|
||||||
use_ui @ui do
|
uri = URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}"
|
||||||
self.class.enable_zip = false
|
util_stub_connection_for :body => '', :code => 200
|
||||||
fetcher = Gem::RemoteFetcher.new nil
|
response = @fetcher.request uri, Net::HTTP::Head
|
||||||
assert_error { fetcher.fetch_path(@server_z_uri) }
|
|
||||||
|
assert_equal 200, response.code
|
||||||
|
assert_equal '', response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_request_unmodifed
|
||||||
|
uri = URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}"
|
||||||
|
conn = util_stub_connection_for :body => '', :code => 304
|
||||||
|
|
||||||
|
t = Time.now
|
||||||
|
response = @fetcher.request uri, Net::HTTP::Head, t
|
||||||
|
|
||||||
|
assert_equal 304, response.code
|
||||||
|
assert_equal '', response.body
|
||||||
|
|
||||||
|
assert_equal t.rfc2822, conn.payload['if-modified-since']
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_yaml_error_on_size
|
def test_yaml_error_on_size
|
||||||
@ -528,7 +584,17 @@ gems:
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
def util_stub_connection_for hash
|
||||||
|
def @fetcher.connection= conn
|
||||||
|
@conn = conn
|
||||||
|
end
|
||||||
|
|
||||||
|
def @fetcher.connection_for uri
|
||||||
|
@conn
|
||||||
|
end
|
||||||
|
|
||||||
|
@fetcher.connection = Conn.new OpenStruct.new(hash)
|
||||||
|
end
|
||||||
|
|
||||||
def assert_error(exception_class=Exception)
|
def assert_error(exception_class=Exception)
|
||||||
got_exception = false
|
got_exception = false
|
||||||
@ -548,6 +614,20 @@ gems:
|
|||||||
assert_block("Data is not from proxy") { data =~ /0\.4\.2/ }
|
assert_block("Data is not from proxy") { data =~ /0\.4\.2/ }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Conn
|
||||||
|
attr_accessor :payload
|
||||||
|
|
||||||
|
def initialize(response)
|
||||||
|
@response = response
|
||||||
|
self.payload = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def request(req)
|
||||||
|
self.payload = req
|
||||||
|
@response
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class NilLog < WEBrick::Log
|
class NilLog < WEBrick::Log
|
||||||
def log(level, data) #Do nothing
|
def log(level, data) #Do nothing
|
||||||
end
|
end
|
||||||
|
@ -280,7 +280,7 @@ RubyGems will revert to legacy indexes degrading performance.
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_load_specs_cached
|
def test_load_specs_cached
|
||||||
@fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] = nil
|
@fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] = ''
|
||||||
@fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}"] =
|
@fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}"] =
|
||||||
' ' * Marshal.dump(@latest_specs).length
|
' ' * Marshal.dump(@latest_specs).length
|
||||||
|
|
||||||
@ -294,9 +294,9 @@ RubyGems will revert to legacy indexes degrading performance.
|
|||||||
Marshal.dump @latest_specs, io
|
Marshal.dump @latest_specs, io
|
||||||
end
|
end
|
||||||
|
|
||||||
specs = @sf.load_specs @uri, 'specs'
|
latest_specs = @sf.load_specs @uri, 'latest_specs'
|
||||||
|
|
||||||
assert_equal @specs, specs
|
assert_equal @latest_specs, latest_specs
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -71,6 +71,8 @@ end
|
|||||||
File.open File.join(@tempdir, 'bin', 'exec'), 'w' do |fp|
|
File.open File.join(@tempdir, 'bin', 'exec'), 'w' do |fp|
|
||||||
fp.puts "#!#{Gem.ruby}"
|
fp.puts "#!#{Gem.ruby}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_attribute_names
|
def test_self_attribute_names
|
||||||
@ -112,6 +114,19 @@ end
|
|||||||
assert_equal expected_value, actual_value
|
assert_equal expected_value, actual_value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_self__load_future
|
||||||
|
spec = Gem::Specification.new
|
||||||
|
spec.name = 'a'
|
||||||
|
spec.version = '1'
|
||||||
|
spec.specification_version = @current_version + 1
|
||||||
|
|
||||||
|
new_spec = Marshal.load Marshal.dump(spec)
|
||||||
|
|
||||||
|
assert_equal 'a', new_spec.name
|
||||||
|
assert_equal Gem::Version.new(1), new_spec.version
|
||||||
|
assert_equal @current_version, new_spec.specification_version
|
||||||
|
end
|
||||||
|
|
||||||
def test_self_load
|
def test_self_load
|
||||||
spec = File.join @gemhome, 'specifications', "#{@a2.full_name}.gemspec"
|
spec = File.join @gemhome, 'specifications', "#{@a2.full_name}.gemspec"
|
||||||
gs = Gem::Specification.load spec
|
gs = Gem::Specification.load spec
|
||||||
@ -689,7 +704,7 @@ end
|
|||||||
|
|
||||||
if s.respond_to? :specification_version then
|
if s.respond_to? :specification_version then
|
||||||
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
||||||
s.specification_version = 3
|
s.specification_version = 2
|
||||||
|
|
||||||
if current_version >= 3 then
|
if current_version >= 3 then
|
||||||
s.add_runtime_dependency(%q<rake>, [\"> 0.4\"])
|
s.add_runtime_dependency(%q<rake>, [\"> 0.4\"])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user