mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rubygems: Update to RubyGems 2.2.2 prerelease to check fixes to
CI. * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bd950a75b5
commit
ea2a00d785
40 changed files with 663 additions and 109 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Tue Feb 4 09:47:57 2014 Eric Hodel <drbrain@segment7.net>
|
||||||
|
|
||||||
|
* lib/rubygems: Update to RubyGems 2.2.2 prerelease to check fixes to
|
||||||
|
CI.
|
||||||
|
* test/rubygems: ditto.
|
||||||
|
|
||||||
Mon Feb 3 12:04:47 2014 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
|
Mon Feb 3 12:04:47 2014 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
|
||||||
|
|
||||||
* error.c: [DOC] Exception#cause may return nil. [ci skip]
|
* error.c: [DOC] Exception#cause may return nil. [ci skip]
|
||||||
|
|
|
@ -4,9 +4,12 @@ class Gem::AvailableSet
|
||||||
|
|
||||||
Tuple = Struct.new(:spec, :source)
|
Tuple = Struct.new(:spec, :source)
|
||||||
|
|
||||||
|
attr_accessor :remote # :nodoc:
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@set = []
|
@set = []
|
||||||
@sorted = nil
|
@sorted = nil
|
||||||
|
@remote = true
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :set
|
attr_reader :set
|
||||||
|
|
|
@ -137,9 +137,10 @@ class Gem::ConfigFile
|
||||||
attr_reader :ssl_verify_mode
|
attr_reader :ssl_verify_mode
|
||||||
|
|
||||||
##
|
##
|
||||||
# Path name of directory or file of openssl CA certificate, used for remote https connection
|
# Path name of directory or file of openssl CA certificate, used for remote
|
||||||
|
# https connection
|
||||||
|
|
||||||
attr_reader :ssl_ca_cert
|
attr_accessor :ssl_ca_cert
|
||||||
|
|
||||||
##
|
##
|
||||||
# Path name of directory or file of openssl client certificate, used for remote https connection with client authentication
|
# Path name of directory or file of openssl client certificate, used for remote https connection with client authentication
|
||||||
|
|
|
@ -419,6 +419,7 @@ class Gem::DependencyInstaller
|
||||||
|
|
||||||
request_set = as.to_request_set install_development_deps
|
request_set = as.to_request_set install_development_deps
|
||||||
request_set.soft_missing = @force
|
request_set.soft_missing = @force
|
||||||
|
request_set.remote = false unless consider_remote?
|
||||||
|
|
||||||
installer_set = Gem::Resolver::InstallerSet.new @domain
|
installer_set = Gem::Resolver::InstallerSet.new @domain
|
||||||
installer_set.always_install.concat request_set.always_install
|
installer_set.always_install.concat request_set.always_install
|
||||||
|
|
|
@ -34,7 +34,11 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
|
||||||
ENV["RUBYOPT"] = ["-r#{siteconf_path}", rubyopt].compact.join(' ')
|
ENV["RUBYOPT"] = ["-r#{siteconf_path}", rubyopt].compact.join(' ')
|
||||||
cmd = [Gem.ruby, File.basename(extension), *args].join ' '
|
cmd = [Gem.ruby, File.basename(extension), *args].join ' '
|
||||||
|
|
||||||
|
begin
|
||||||
run cmd, results
|
run cmd, results
|
||||||
|
ensure
|
||||||
|
FileUtils.mv 'mkmf.log', dest_path if File.exist? 'mkmf.log'
|
||||||
|
end
|
||||||
|
|
||||||
ENV["DESTDIR"] = nil
|
ENV["DESTDIR"] = nil
|
||||||
ENV["RUBYOPT"] = rubyopt
|
ENV["RUBYOPT"] = rubyopt
|
||||||
|
|
|
@ -641,7 +641,7 @@ version = "#{Gem::Requirement.default}"
|
||||||
if ARGV.first
|
if ARGV.first
|
||||||
str = ARGV.first
|
str = ARGV.first
|
||||||
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
|
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
|
||||||
if str =~ /\\A_(.*)_\\z/
|
if str =~ /\\A_(.*)_\\z/ and Gem::Version.correct?($1) then
|
||||||
version = $1
|
version = $1
|
||||||
ARGV.shift
|
ARGV.shift
|
||||||
end
|
end
|
||||||
|
|
|
@ -134,7 +134,7 @@ class Gem::Package::TarHeader
|
||||||
vals[:gid] ||= 0
|
vals[:gid] ||= 0
|
||||||
vals[:mtime] ||= 0
|
vals[:mtime] ||= 0
|
||||||
vals[:checksum] ||= ""
|
vals[:checksum] ||= ""
|
||||||
vals[:typeflag] ||= "0"
|
vals[:typeflag] = "0" if vals[:typeflag].nil? || vals[:typeflag].empty?
|
||||||
vals[:magic] ||= "ustar"
|
vals[:magic] ||= "ustar"
|
||||||
vals[:version] ||= "00"
|
vals[:version] ||= "00"
|
||||||
vals[:uname] ||= "wheel"
|
vals[:uname] ||= "wheel"
|
||||||
|
|
|
@ -132,11 +132,19 @@ class Gem::RemoteFetcher
|
||||||
FileUtils.mkdir_p cache_dir rescue nil unless File.exist? cache_dir
|
FileUtils.mkdir_p cache_dir rescue nil unless File.exist? cache_dir
|
||||||
|
|
||||||
# Always escape URI's to deal with potential spaces and such
|
# Always escape URI's to deal with potential spaces and such
|
||||||
unless URI::Generic === source_uri
|
# It should also be considered that source_uri may already be
|
||||||
|
# a valid URI with escaped characters. e.g. "{DESede}" is encoded
|
||||||
|
# as "%7BDESede%7D". If this is escaped again the percentage
|
||||||
|
# symbols will be escaped.
|
||||||
|
unless source_uri.is_a?(URI::Generic)
|
||||||
|
begin
|
||||||
|
source_uri = URI.parse(source_uri)
|
||||||
|
rescue
|
||||||
source_uri = URI.parse(URI.const_defined?(:DEFAULT_PARSER) ?
|
source_uri = URI.parse(URI.const_defined?(:DEFAULT_PARSER) ?
|
||||||
URI::DEFAULT_PARSER.escape(source_uri.to_s) :
|
URI::DEFAULT_PARSER.escape(source_uri.to_s) :
|
||||||
URI.escape(source_uri.to_s))
|
URI.escape(source_uri.to_s))
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scheme = source_uri.scheme
|
scheme = source_uri.scheme
|
||||||
|
|
||||||
|
@ -285,12 +293,13 @@ class Gem::RemoteFetcher
|
||||||
def cache_update_path uri, path = nil, update = true
|
def cache_update_path uri, path = nil, update = true
|
||||||
mtime = path && File.stat(path).mtime rescue nil
|
mtime = path && File.stat(path).mtime rescue nil
|
||||||
|
|
||||||
if mtime && Net::HTTPNotModified === fetch_path(uri, mtime, true)
|
data = fetch_path(uri, mtime)
|
||||||
Gem.read_binary(path)
|
|
||||||
else
|
|
||||||
data = fetch_path(uri)
|
|
||||||
|
|
||||||
if update and path then
|
if data == nil # indicates the server returned 304 Not Modified
|
||||||
|
return Gem.read_binary(path)
|
||||||
|
end
|
||||||
|
|
||||||
|
if update and path
|
||||||
open(path, 'wb') do |io|
|
open(path, 'wb') do |io|
|
||||||
io.flock(File::LOCK_EX)
|
io.flock(File::LOCK_EX)
|
||||||
io.write data
|
io.write data
|
||||||
|
@ -299,7 +308,6 @@ class Gem::RemoteFetcher
|
||||||
|
|
||||||
data
|
data
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Returns the size of +uri+ in bytes.
|
# Returns the size of +uri+ in bytes.
|
||||||
|
|
|
@ -48,15 +48,14 @@ class Gem::Request
|
||||||
connection.key = OpenSSL::PKey::RSA.new pem
|
connection.key = OpenSSL::PKey::RSA.new pem
|
||||||
end
|
end
|
||||||
|
|
||||||
|
store.set_default_paths
|
||||||
|
add_rubygems_trusted_certs(store)
|
||||||
if Gem.configuration.ssl_ca_cert
|
if Gem.configuration.ssl_ca_cert
|
||||||
if File.directory? Gem.configuration.ssl_ca_cert
|
if File.directory? Gem.configuration.ssl_ca_cert
|
||||||
store.add_path Gem.configuration.ssl_ca_cert
|
store.add_path Gem.configuration.ssl_ca_cert
|
||||||
else
|
else
|
||||||
store.add_file Gem.configuration.ssl_ca_cert
|
store.add_file Gem.configuration.ssl_ca_cert
|
||||||
end
|
end
|
||||||
else
|
|
||||||
store.set_default_paths
|
|
||||||
add_rubygems_trusted_certs(store)
|
|
||||||
end
|
end
|
||||||
connection.cert_store = store
|
connection.cert_store = store
|
||||||
rescue LoadError => e
|
rescue LoadError => e
|
||||||
|
@ -106,7 +105,8 @@ class Gem::Request
|
||||||
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
|
||||||
request.basic_auth @uri.user, @uri.password
|
request.basic_auth Gem::UriFormatter.new(@uri.user).unescape,
|
||||||
|
Gem::UriFormatter.new(@uri.password).unescape
|
||||||
end
|
end
|
||||||
|
|
||||||
request.add_field 'User-Agent', @user_agent
|
request.add_field 'User-Agent', @user_agent
|
||||||
|
|
|
@ -38,6 +38,11 @@ class Gem::RequestSet
|
||||||
|
|
||||||
attr_accessor :ignore_dependencies
|
attr_accessor :ignore_dependencies
|
||||||
|
|
||||||
|
##
|
||||||
|
# When false no remote sets are used for resolving gems.
|
||||||
|
|
||||||
|
attr_accessor :remote
|
||||||
|
|
||||||
##
|
##
|
||||||
# Sets used for resolution
|
# Sets used for resolution
|
||||||
|
|
||||||
|
@ -71,6 +76,7 @@ class Gem::RequestSet
|
||||||
@git_set = nil
|
@git_set = nil
|
||||||
@ignore_dependencies = false
|
@ignore_dependencies = false
|
||||||
@install_dir = Gem.dir
|
@install_dir = Gem.dir
|
||||||
|
@remote = true
|
||||||
@requests = []
|
@requests = []
|
||||||
@sets = []
|
@sets = []
|
||||||
@soft_missing = false
|
@soft_missing = false
|
||||||
|
@ -150,6 +156,7 @@ class Gem::RequestSet
|
||||||
gemdeps = options[:gemdeps]
|
gemdeps = options[:gemdeps]
|
||||||
|
|
||||||
@install_dir = options[:install_dir] || Gem.dir
|
@install_dir = options[:install_dir] || Gem.dir
|
||||||
|
@remote = options[:domain] != :local
|
||||||
|
|
||||||
load_gemdeps gemdeps, options[:without_groups]
|
load_gemdeps gemdeps, options[:without_groups]
|
||||||
|
|
||||||
|
@ -235,6 +242,7 @@ class Gem::RequestSet
|
||||||
@sets << @vendor_set
|
@sets << @vendor_set
|
||||||
|
|
||||||
set = Gem::Resolver.compose_sets(*@sets)
|
set = Gem::Resolver.compose_sets(*@sets)
|
||||||
|
set.remote = @remote
|
||||||
|
|
||||||
resolver = Gem::Resolver.new @dependencies, set
|
resolver = Gem::Resolver.new @dependencies, set
|
||||||
resolver.development = @development
|
resolver.development = @development
|
||||||
|
|
|
@ -59,6 +59,8 @@ class Gem::Resolver
|
||||||
|
|
||||||
sets = sets.map do |set|
|
sets = sets.map do |set|
|
||||||
case set
|
case set
|
||||||
|
when Gem::Resolver::BestSet then
|
||||||
|
set
|
||||||
when Gem::Resolver::ComposedSet then
|
when Gem::Resolver::ComposedSet then
|
||||||
set.sets
|
set.sets
|
||||||
else
|
else
|
||||||
|
|
|
@ -25,10 +25,12 @@ class Gem::Resolver::APISet < Gem::Resolver::Set
|
||||||
# http://guides.rubygems.org/rubygems-org-api
|
# http://guides.rubygems.org/rubygems-org-api
|
||||||
|
|
||||||
def initialize dep_uri = 'https://rubygems.org/api/v1/dependencies'
|
def initialize dep_uri = 'https://rubygems.org/api/v1/dependencies'
|
||||||
|
super()
|
||||||
|
|
||||||
dep_uri = URI dep_uri unless URI === dep_uri # for ruby 1.8
|
dep_uri = URI dep_uri unless URI === dep_uri # for ruby 1.8
|
||||||
|
|
||||||
@dep_uri = dep_uri
|
@dep_uri = dep_uri
|
||||||
@uri = dep_uri + '../../..'
|
@uri = dep_uri + '../..'
|
||||||
|
|
||||||
@data = Hash.new { |h,k| h[k] = [] }
|
@data = Hash.new { |h,k| h[k] = [] }
|
||||||
@source = Gem::Source.new @uri
|
@source = Gem::Source.new @uri
|
||||||
|
@ -41,6 +43,8 @@ class Gem::Resolver::APISet < Gem::Resolver::Set
|
||||||
def find_all req
|
def find_all req
|
||||||
res = []
|
res = []
|
||||||
|
|
||||||
|
return res unless @remote
|
||||||
|
|
||||||
versions(req.name).each do |ver|
|
versions(req.name).each do |ver|
|
||||||
if req.dependency.match? req.name, ver[:number]
|
if req.dependency.match? req.name, ver[:number]
|
||||||
res << Gem::Resolver::APISpecification.new(self, ver)
|
res << Gem::Resolver::APISpecification.new(self, ver)
|
||||||
|
@ -55,6 +59,7 @@ class Gem::Resolver::APISet < Gem::Resolver::Set
|
||||||
# data for DependencyRequests +reqs+.
|
# data for DependencyRequests +reqs+.
|
||||||
|
|
||||||
def prefetch reqs
|
def prefetch reqs
|
||||||
|
return unless @remote
|
||||||
names = reqs.map { |r| r.dependency.name }
|
names = reqs.map { |r| r.dependency.name }
|
||||||
needed = names - @data.keys
|
needed = names - @data.keys
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,30 @@ class Gem::Resolver::BestSet < Gem::Resolver::ComposedSet
|
||||||
def initialize sources = Gem.sources
|
def initialize sources = Gem.sources
|
||||||
super()
|
super()
|
||||||
|
|
||||||
sources.each_source do |source|
|
@sources = sources
|
||||||
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Picks which sets to use for the configured sources.
|
||||||
|
|
||||||
|
def pick_sets # :nodoc:
|
||||||
|
@sources.each_source do |source|
|
||||||
@sets << source.dependency_resolver_set
|
@sets << source.dependency_resolver_set
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def find_all req # :nodoc:
|
||||||
|
pick_sets if @remote and @sets.empty?
|
||||||
|
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
def prefetch reqs # :nodoc:
|
||||||
|
pick_sets if @remote and @sets.empty?
|
||||||
|
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
def pretty_print q # :nodoc:
|
def pretty_print q # :nodoc:
|
||||||
q.group 2, '[BestSet', ']' do
|
q.group 2, '[BestSet', ']' do
|
||||||
q.breakable
|
q.breakable
|
||||||
|
|
|
@ -16,9 +16,20 @@ class Gem::Resolver::ComposedSet < Gem::Resolver::Set
|
||||||
# Gem::Resolver::compose_sets instead.
|
# Gem::Resolver::compose_sets instead.
|
||||||
|
|
||||||
def initialize *sets
|
def initialize *sets
|
||||||
|
super()
|
||||||
|
|
||||||
@sets = sets
|
@sets = sets
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Sets the remote network access for all composed sets.
|
||||||
|
|
||||||
|
def remote= remote
|
||||||
|
super
|
||||||
|
|
||||||
|
@sets.each { |set| set.remote = remote }
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Finds all specs matching +req+ in all sets.
|
# Finds all specs matching +req+ in all sets.
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,8 @@ class Gem::Resolver::GitSet < Gem::Resolver::Set
|
||||||
attr_reader :specs # :nodoc:
|
attr_reader :specs # :nodoc:
|
||||||
|
|
||||||
def initialize # :nodoc:
|
def initialize # :nodoc:
|
||||||
|
super()
|
||||||
|
|
||||||
@git = ENV['git'] || 'git'
|
@git = ENV['git'] || 'git'
|
||||||
@need_submodules = {}
|
@need_submodules = {}
|
||||||
@repositories = {}
|
@repositories = {}
|
||||||
|
@ -91,6 +93,7 @@ class Gem::Resolver::GitSet < Gem::Resolver::Set
|
||||||
@repositories.each do |name, (repository, reference)|
|
@repositories.each do |name, (repository, reference)|
|
||||||
source = Gem::Source::Git.new name, repository, reference
|
source = Gem::Source::Git.new name, repository, reference
|
||||||
source.root_dir = @root_dir
|
source.root_dir = @root_dir
|
||||||
|
source.remote = @remote
|
||||||
|
|
||||||
source.specs.each do |spec|
|
source.specs.each do |spec|
|
||||||
git_spec = Gem::Resolver::GitSpecification.new self, spec, source
|
git_spec = Gem::Resolver::GitSpecification.new self, spec, source
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
class Gem::Resolver::IndexSet < Gem::Resolver::Set
|
class Gem::Resolver::IndexSet < Gem::Resolver::Set
|
||||||
|
|
||||||
def initialize source = nil # :nodoc:
|
def initialize source = nil # :nodoc:
|
||||||
|
super()
|
||||||
|
|
||||||
@f =
|
@f =
|
||||||
if source then
|
if source then
|
||||||
sources = Gem::SourceList.from [source]
|
sources = Gem::SourceList.from [source]
|
||||||
|
@ -34,6 +36,8 @@ class Gem::Resolver::IndexSet < Gem::Resolver::Set
|
||||||
def find_all req
|
def find_all req
|
||||||
res = []
|
res = []
|
||||||
|
|
||||||
|
return res unless @remote
|
||||||
|
|
||||||
name = req.dependency.name
|
name = req.dependency.name
|
||||||
|
|
||||||
@all[name].each do |uri, n|
|
@all[name].each do |uri, n|
|
||||||
|
|
|
@ -24,14 +24,17 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
|
||||||
# Creates a new InstallerSet that will look for gems in +domain+.
|
# Creates a new InstallerSet that will look for gems in +domain+.
|
||||||
|
|
||||||
def initialize domain
|
def initialize domain
|
||||||
|
super()
|
||||||
|
|
||||||
@domain = domain
|
@domain = domain
|
||||||
|
@remote = consider_remote?
|
||||||
|
|
||||||
@f = Gem::SpecFetcher.fetcher
|
@f = Gem::SpecFetcher.fetcher
|
||||||
|
|
||||||
@always_install = []
|
@always_install = []
|
||||||
@ignore_dependencies = false
|
@ignore_dependencies = false
|
||||||
@ignore_installed = false
|
@ignore_installed = false
|
||||||
@remote_set = Gem::Resolver::BestSet.new if consider_remote?
|
@remote_set = Gem::Resolver::BestSet.new
|
||||||
@specs = {}
|
@specs = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -120,5 +123,16 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remote= remote # :nodoc:
|
||||||
|
case @domain
|
||||||
|
when :local then
|
||||||
|
@domain = :both if remote
|
||||||
|
when :remote then
|
||||||
|
@domain = nil unless remote
|
||||||
|
when :both then
|
||||||
|
@domain = :local unless remote
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set
|
||||||
# Creates a new LockSet from the given +source+
|
# Creates a new LockSet from the given +source+
|
||||||
|
|
||||||
def initialize source
|
def initialize source
|
||||||
|
super()
|
||||||
|
|
||||||
@source = Gem::Source::Lock.new source
|
@source = Gem::Source::Lock.new source
|
||||||
@specs = []
|
@specs = []
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,15 @@
|
||||||
|
|
||||||
class Gem::Resolver::Set
|
class Gem::Resolver::Set
|
||||||
|
|
||||||
|
##
|
||||||
|
# Set to true to disable network access for this set
|
||||||
|
|
||||||
|
attr_accessor :remote
|
||||||
|
|
||||||
|
def initialize # :nodoc:
|
||||||
|
@remote = true
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# The find_all method must be implemented. It returns all Resolver
|
# The find_all method must be implemented. It returns all Resolver
|
||||||
# Specification objects matching the given DependencyRequest +req+.
|
# Specification objects matching the given DependencyRequest +req+.
|
||||||
|
@ -23,5 +32,13 @@ class Gem::Resolver::Set
|
||||||
def prefetch reqs
|
def prefetch reqs
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# When true, this set is allowed to access the network when looking up
|
||||||
|
# specifications or dependencies.
|
||||||
|
|
||||||
|
def remote? # :nodoc:
|
||||||
|
@remote
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ class Gem::Resolver::VendorSet < Gem::Resolver::Set
|
||||||
attr_reader :specs # :nodoc:
|
attr_reader :specs # :nodoc:
|
||||||
|
|
||||||
def initialize # :nodoc:
|
def initialize # :nodoc:
|
||||||
|
super()
|
||||||
|
|
||||||
@directories = {}
|
@directories = {}
|
||||||
@specs = {}
|
@specs = {}
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,6 +23,11 @@ class Gem::Source::Git < Gem::Source
|
||||||
|
|
||||||
attr_reader :reference
|
attr_reader :reference
|
||||||
|
|
||||||
|
##
|
||||||
|
# When false the cache for this repository will not be updated.
|
||||||
|
|
||||||
|
attr_accessor :remote
|
||||||
|
|
||||||
##
|
##
|
||||||
# The git repository this gem is sourced from.
|
# The git repository this gem is sourced from.
|
||||||
|
|
||||||
|
@ -53,6 +58,7 @@ class Gem::Source::Git < Gem::Source
|
||||||
@reference = reference
|
@reference = reference
|
||||||
@need_submodules = submodules
|
@need_submodules = submodules
|
||||||
|
|
||||||
|
@remote = true
|
||||||
@root_dir = Gem.dir
|
@root_dir = Gem.dir
|
||||||
@git = ENV['git'] || 'git'
|
@git = ENV['git'] || 'git'
|
||||||
end
|
end
|
||||||
|
@ -85,6 +91,8 @@ class Gem::Source::Git < Gem::Source
|
||||||
def checkout # :nodoc:
|
def checkout # :nodoc:
|
||||||
cache
|
cache
|
||||||
|
|
||||||
|
return false unless File.exist? repo_cache_dir
|
||||||
|
|
||||||
unless File.exist? install_dir then
|
unless File.exist? install_dir then
|
||||||
system @git, 'clone', '--quiet', '--no-checkout',
|
system @git, 'clone', '--quiet', '--no-checkout',
|
||||||
repo_cache_dir, install_dir
|
repo_cache_dir, install_dir
|
||||||
|
@ -107,6 +115,8 @@ class Gem::Source::Git < Gem::Source
|
||||||
# Creates a local cache repository for the git gem.
|
# Creates a local cache repository for the git gem.
|
||||||
|
|
||||||
def cache # :nodoc:
|
def cache # :nodoc:
|
||||||
|
return unless @remote
|
||||||
|
|
||||||
if File.exist? repo_cache_dir then
|
if File.exist? repo_cache_dir then
|
||||||
Dir.chdir repo_cache_dir do
|
Dir.chdir repo_cache_dir do
|
||||||
system @git, 'fetch', '--quiet', '--force', '--tags',
|
system @git, 'fetch', '--quiet', '--force', '--tags',
|
||||||
|
@ -142,6 +152,8 @@ class Gem::Source::Git < Gem::Source
|
||||||
# The directory where the git gem will be installed.
|
# The directory where the git gem will be installed.
|
||||||
|
|
||||||
def install_dir # :nodoc:
|
def install_dir # :nodoc:
|
||||||
|
return unless File.exist? repo_cache_dir
|
||||||
|
|
||||||
File.join base_dir, 'gems', "#{@name}-#{dir_shortref}"
|
File.join base_dir, 'gems', "#{@name}-#{dir_shortref}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -177,6 +189,8 @@ class Gem::Source::Git < Gem::Source
|
||||||
def specs
|
def specs
|
||||||
checkout
|
checkout
|
||||||
|
|
||||||
|
return [] unless install_dir
|
||||||
|
|
||||||
Dir.chdir install_dir do
|
Dir.chdir install_dir do
|
||||||
Dir['{,*,*/*}.gemspec'].map do |spec_file|
|
Dir['{,*,*/*}.gemspec'].map do |spec_file|
|
||||||
directory = File.dirname spec_file
|
directory = File.dirname spec_file
|
||||||
|
|
|
@ -115,6 +115,23 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
||||||
assert File.exist?(path), msg
|
assert File.exist?(path), msg
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Sets the ENABLE_SHARED entry in RbConfig::CONFIG to +value+ and restores
|
||||||
|
# the original value when the block ends
|
||||||
|
|
||||||
|
def enable_shared value
|
||||||
|
enable_shared = RbConfig::CONFIG['ENABLE_SHARED']
|
||||||
|
RbConfig::CONFIG['ENABLE_SHARED'] = value
|
||||||
|
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
if enable_shared then
|
||||||
|
RbConfig::CONFIG['enable_shared'] = enable_shared
|
||||||
|
else
|
||||||
|
RbConfig::CONFIG.delete 'enable_shared'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# TODO: move to minitest
|
# TODO: move to minitest
|
||||||
def refute_path_exists path, msg = nil
|
def refute_path_exists path, msg = nil
|
||||||
msg = message(msg) { "Expected path '#{path}' to not exist" }
|
msg = message(msg) { "Expected path '#{path}' to not exist" }
|
||||||
|
@ -1248,11 +1265,18 @@ Also, a list:
|
||||||
|
|
||||||
class StaticSet
|
class StaticSet
|
||||||
|
|
||||||
|
##
|
||||||
|
# A StaticSet ignores remote because it has a fixed set of gems.
|
||||||
|
|
||||||
|
attr_accessor :remote
|
||||||
|
|
||||||
##
|
##
|
||||||
# Creates a new StaticSet for the given +specs+
|
# Creates a new StaticSet for the given +specs+
|
||||||
|
|
||||||
def initialize(specs)
|
def initialize(specs)
|
||||||
@specs = specs
|
@specs = specs
|
||||||
|
|
||||||
|
@remote = true
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -22,6 +22,11 @@
|
||||||
# 3. 1.0.a.2
|
# 3. 1.0.a.2
|
||||||
# 4. 0.9
|
# 4. 0.9
|
||||||
#
|
#
|
||||||
|
# If you want to specify a version restriction that includes both prereleases
|
||||||
|
# and regular releases of the 1.x series this is the best way:
|
||||||
|
#
|
||||||
|
# s.add_dependency 'example', '>= 1.0.0.a', '< 2.0.0'
|
||||||
|
#
|
||||||
# == How Software Changes
|
# == How Software Changes
|
||||||
#
|
#
|
||||||
# Users expect to be able to specify a version constraint that gives them
|
# Users expect to be able to specify a version constraint that gives them
|
||||||
|
|
|
@ -199,30 +199,21 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_default_exec_format
|
def test_self_default_exec_format
|
||||||
orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name']
|
ruby_install_name 'ruby' do
|
||||||
RbConfig::CONFIG['ruby_install_name'] = 'ruby'
|
|
||||||
|
|
||||||
assert_equal '%s', Gem.default_exec_format
|
assert_equal '%s', Gem.default_exec_format
|
||||||
ensure
|
end
|
||||||
RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_default_exec_format_18
|
def test_self_default_exec_format_18
|
||||||
orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name']
|
ruby_install_name 'ruby18' do
|
||||||
RbConfig::CONFIG['ruby_install_name'] = 'ruby18'
|
|
||||||
|
|
||||||
assert_equal '%s18', Gem.default_exec_format
|
assert_equal '%s18', Gem.default_exec_format
|
||||||
ensure
|
end
|
||||||
RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_default_exec_format_jruby
|
def test_self_default_exec_format_jruby
|
||||||
orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name']
|
ruby_install_name 'jruby' do
|
||||||
RbConfig::CONFIG['ruby_install_name'] = 'jruby'
|
|
||||||
|
|
||||||
assert_equal 'j%s', Gem.default_exec_format
|
assert_equal 'j%s', Gem.default_exec_format
|
||||||
ensure
|
end
|
||||||
RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_default_sources
|
def test_self_default_sources
|
||||||
|
@ -340,21 +331,15 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_extension_dir_shared
|
def test_self_extension_dir_shared
|
||||||
enable_shared, RbConfig::CONFIG['ENABLE_SHARED'] =
|
enable_shared 'yes' do
|
||||||
RbConfig::CONFIG['ENABLE_SHARED'], 'yes'
|
|
||||||
|
|
||||||
assert_equal Gem.ruby_api_version, Gem.extension_api_version
|
assert_equal Gem.ruby_api_version, Gem.extension_api_version
|
||||||
ensure
|
end
|
||||||
RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_extension_dir_static
|
def test_self_extension_dir_static
|
||||||
enable_shared, RbConfig::CONFIG['ENABLE_SHARED'] =
|
enable_shared 'no' do
|
||||||
RbConfig::CONFIG['ENABLE_SHARED'], 'no'
|
|
||||||
|
|
||||||
assert_equal "#{Gem.ruby_api_version}-static", Gem.extension_api_version
|
assert_equal "#{Gem.ruby_api_version}-static", Gem.extension_api_version
|
||||||
ensure
|
end
|
||||||
RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_find_files
|
def test_self_find_files
|
||||||
|
@ -1339,6 +1324,19 @@ class TestGem < Gem::TestCase
|
||||||
ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
|
ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ruby_install_name name
|
||||||
|
orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name']
|
||||||
|
RbConfig::CONFIG['ruby_install_name'] = name
|
||||||
|
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
if orig_RUBY_INSTALL_NAME then
|
||||||
|
RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME
|
||||||
|
else
|
||||||
|
RbConfig::CONFIG.delete 'ruby_install_name'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def with_plugin(path)
|
def with_plugin(path)
|
||||||
test_plugin_path = File.expand_path("test/rubygems/plugin/#{path}",
|
test_plugin_path = File.expand_path("test/rubygems/plugin/#{path}",
|
||||||
@@project_dir)
|
@@project_dir)
|
||||||
|
|
|
@ -42,7 +42,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_class_build_rbconfig_make_prog
|
def test_class_build_rbconfig_make_prog
|
||||||
configure_args = RbConfig::CONFIG['configure_args']
|
configure_args do
|
||||||
|
|
||||||
File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
|
File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
|
||||||
extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
|
extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
|
||||||
|
@ -58,15 +58,14 @@ class TestGemExtExtConfBuilder < Gem::TestCase
|
||||||
assert_contains_make_command 'clean', output[2]
|
assert_contains_make_command 'clean', output[2]
|
||||||
assert_contains_make_command '', output[4]
|
assert_contains_make_command '', output[4]
|
||||||
assert_contains_make_command 'install', output[6]
|
assert_contains_make_command 'install', output[6]
|
||||||
ensure
|
end
|
||||||
RbConfig::CONFIG['configure_args'] = configure_args
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_class_build_env_make
|
def test_class_build_env_make
|
||||||
configure_args, env_make = RbConfig::CONFIG['configure_args'], ENV.delete('make')
|
env_make = ENV.delete 'make'
|
||||||
RbConfig::CONFIG['configure_args'] = ''
|
|
||||||
ENV['make'] = 'anothermake'
|
ENV['make'] = 'anothermake'
|
||||||
|
|
||||||
|
configure_args '' do
|
||||||
File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
|
File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
|
||||||
extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
|
extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
|
||||||
end
|
end
|
||||||
|
@ -81,8 +80,8 @@ class TestGemExtExtConfBuilder < Gem::TestCase
|
||||||
|
|
||||||
assert_equal "creating Makefile\n", output[1]
|
assert_equal "creating Makefile\n", output[1]
|
||||||
assert_contains_make_command 'clean', output[2]
|
assert_contains_make_command 'clean', output[2]
|
||||||
|
end
|
||||||
ensure
|
ensure
|
||||||
RbConfig::CONFIG['configure_args'] = configure_args
|
|
||||||
ENV['make'] = env_make
|
ENV['make'] = env_make
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -108,6 +107,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase
|
||||||
assert_equal 'extconf failed, exit code 1', error.message
|
assert_equal 'extconf failed, exit code 1', error.message
|
||||||
|
|
||||||
assert_equal("#{Gem.ruby} extconf.rb", output[0])
|
assert_equal("#{Gem.ruby} extconf.rb", output[0])
|
||||||
|
assert_path_exists File.join @dest_path, 'mkmf.log'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_class_build_unconventional
|
def test_class_build_unconventional
|
||||||
|
@ -188,5 +188,19 @@ end
|
||||||
assert_equal 'Makefile not found', error.message
|
assert_equal 'Makefile not found', error.message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def configure_args args = nil
|
||||||
|
configure_args = RbConfig::CONFIG['configure_args']
|
||||||
|
RbConfig::CONFIG['configure_args'] = args if args
|
||||||
|
|
||||||
|
yield
|
||||||
|
|
||||||
|
ensure
|
||||||
|
if configure_args then
|
||||||
|
RbConfig::CONFIG['configure_args'] = configure_args
|
||||||
|
else
|
||||||
|
RbConfig::CONFIG.delete 'configure_args'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ version = \">= 0\"
|
||||||
if ARGV.first
|
if ARGV.first
|
||||||
str = ARGV.first
|
str = ARGV.first
|
||||||
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
|
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
|
||||||
if str =~ /\\A_(.*)_\\z/
|
if str =~ /\\A_(.*)_\\z/ and Gem::Version.correct?($1) then
|
||||||
version = $1
|
version = $1
|
||||||
ARGV.shift
|
ARGV.shift
|
||||||
end
|
end
|
||||||
|
@ -102,7 +102,11 @@ load Gem.bin_path('a', 'executable', version)
|
||||||
ensure
|
ensure
|
||||||
Object.const_set :RUBY_FRAMEWORK_VERSION, orig_RUBY_FRAMEWORK_VERSION if
|
Object.const_set :RUBY_FRAMEWORK_VERSION, orig_RUBY_FRAMEWORK_VERSION if
|
||||||
orig_RUBY_FRAMEWORK_VERSION
|
orig_RUBY_FRAMEWORK_VERSION
|
||||||
|
if orig_bindir then
|
||||||
RbConfig::CONFIG['bindir'] = orig_bindir
|
RbConfig::CONFIG['bindir'] = orig_bindir
|
||||||
|
else
|
||||||
|
RbConfig::CONFIG.delete 'bindir'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_check_executable_overwrite_format_executable
|
def test_check_executable_overwrite_format_executable
|
||||||
|
|
|
@ -72,6 +72,20 @@ class TestGemPackageTarHeader < Gem::Package::TarTestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_initialize_typeflag
|
||||||
|
header = {
|
||||||
|
:mode => '',
|
||||||
|
:name => '',
|
||||||
|
:prefix => '',
|
||||||
|
:size => '',
|
||||||
|
:typeflag => '',
|
||||||
|
}
|
||||||
|
|
||||||
|
tar_header = Gem::Package::TarHeader.new header
|
||||||
|
|
||||||
|
assert_equal '0', tar_header.typeflag
|
||||||
|
end
|
||||||
|
|
||||||
def test_empty_eh
|
def test_empty_eh
|
||||||
refute_empty @tar_header
|
refute_empty @tar_header
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,11 @@ class TestGemPlatform < Gem::TestCase
|
||||||
|
|
||||||
assert_equal expected, platform.to_a, 'i386-mswin32 VC6'
|
assert_equal expected, platform.to_a, 'i386-mswin32 VC6'
|
||||||
ensure
|
ensure
|
||||||
|
if orig_RUBY_SO_NAME then
|
||||||
RbConfig::CONFIG['RUBY_SO_NAME'] = orig_RUBY_SO_NAME
|
RbConfig::CONFIG['RUBY_SO_NAME'] = orig_RUBY_SO_NAME
|
||||||
|
else
|
||||||
|
RbConfig::CONFIG.delete 'RUBY_SO_NAME'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_initialize_platform
|
def test_initialize_platform
|
||||||
|
|
|
@ -208,15 +208,15 @@ gems:
|
||||||
fetcher.instance_variable_set :@test_data, data
|
fetcher.instance_variable_set :@test_data, data
|
||||||
|
|
||||||
unless blow then
|
unless blow then
|
||||||
def fetcher.fetch_path arg
|
def fetcher.fetch_path arg, *rest
|
||||||
@test_arg = arg
|
@test_arg = arg
|
||||||
@test_data
|
@test_data
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
def fetcher.fetch_path arg
|
def fetcher.fetch_path arg, *rest
|
||||||
# OMG I'm such an ass
|
# OMG I'm such an ass
|
||||||
class << self; remove_method :fetch_path; end
|
class << self; remove_method :fetch_path; end
|
||||||
def self.fetch_path arg
|
def self.fetch_path arg, *rest
|
||||||
@test_arg = arg
|
@test_arg = arg
|
||||||
@test_data
|
@test_data
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
require 'rubygems/test_case'
|
require 'rubygems/test_case'
|
||||||
require 'rubygems/request'
|
require 'rubygems/request'
|
||||||
require 'ostruct'
|
require 'ostruct'
|
||||||
|
require 'base64'
|
||||||
|
|
||||||
class TestGemRequest < Gem::TestCase
|
class TestGemRequest < Gem::TestCase
|
||||||
|
|
||||||
|
CA_CERT_FILE = cert_path 'ca'
|
||||||
|
CHILD_CERT = load_cert 'child'
|
||||||
|
PUBLIC_CERT = load_cert 'public'
|
||||||
|
PUBLIC_CERT_FILE = cert_path 'public'
|
||||||
|
SSL_CERT = load_cert 'ssl'
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@proxies = %w[http_proxy HTTP_PROXY http_proxy_user HTTP_PROXY_USER http_proxy_pass HTTP_PROXY_PASS no_proxy NO_PROXY]
|
@proxies = %w[http_proxy HTTP_PROXY http_proxy_user HTTP_PROXY_USER http_proxy_pass HTTP_PROXY_PASS no_proxy NO_PROXY]
|
||||||
@old_proxies = @proxies.map {|k| ENV[k] }
|
@old_proxies = @proxies.map {|k| ENV[k] }
|
||||||
|
@ -62,6 +69,44 @@ class TestGemRequest < Gem::TestCase
|
||||||
assert_equal URI(@proxy_uri), proxy
|
assert_equal URI(@proxy_uri), proxy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_configure_connection_for_https
|
||||||
|
connection = Net::HTTP.new 'localhost', 443
|
||||||
|
|
||||||
|
request = Gem::Request.new URI('https://example'), nil, nil, nil
|
||||||
|
|
||||||
|
def request.add_rubygems_trusted_certs store
|
||||||
|
store.add_cert TestGemRequest::PUBLIC_CERT
|
||||||
|
end
|
||||||
|
|
||||||
|
request.configure_connection_for_https connection
|
||||||
|
|
||||||
|
cert_store = connection.cert_store
|
||||||
|
|
||||||
|
assert cert_store.verify CHILD_CERT
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_configure_connection_for_https_ssl_ca_cert
|
||||||
|
ssl_ca_cert, Gem.configuration.ssl_ca_cert =
|
||||||
|
Gem.configuration.ssl_ca_cert, CA_CERT_FILE
|
||||||
|
|
||||||
|
connection = Net::HTTP.new 'localhost', 443
|
||||||
|
|
||||||
|
request = Gem::Request.new URI('https://example'), nil, nil, nil
|
||||||
|
|
||||||
|
def request.add_rubygems_trusted_certs store
|
||||||
|
store.add_cert TestGemRequest::PUBLIC_CERT
|
||||||
|
end
|
||||||
|
|
||||||
|
request.configure_connection_for_https connection
|
||||||
|
|
||||||
|
cert_store = connection.cert_store
|
||||||
|
|
||||||
|
assert cert_store.verify CHILD_CERT
|
||||||
|
assert cert_store.verify SSL_CERT
|
||||||
|
ensure
|
||||||
|
Gem.configuration.ssl_ca_cert = ssl_ca_cert
|
||||||
|
end
|
||||||
|
|
||||||
def test_get_proxy_from_env_fallback
|
def test_get_proxy_from_env_fallback
|
||||||
ENV['http_proxy'] = @proxy_uri
|
ENV['http_proxy'] = @proxy_uri
|
||||||
|
|
||||||
|
@ -124,6 +169,30 @@ class TestGemRequest < Gem::TestCase
|
||||||
assert_equal :junk, response.body
|
assert_equal :junk, response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_fetch_basic_auth
|
||||||
|
uri = URI.parse "https://user:pass@example.rubygems/specs.#{Gem.marshal_version}"
|
||||||
|
@request = Gem::Request.new(uri, Net::HTTP::Get, nil, nil)
|
||||||
|
conn = util_stub_connection_for :body => :junk, :code => 200
|
||||||
|
|
||||||
|
@request.fetch
|
||||||
|
|
||||||
|
auth_header = conn.payload['Authorization']
|
||||||
|
|
||||||
|
assert_equal "Basic #{Base64.encode64('user:pass')}".strip, auth_header
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_fetch_basic_auth_encoded
|
||||||
|
uri = URI.parse "https://user:%7BDEScede%7Dpass@example.rubygems/specs.#{Gem.marshal_version}"
|
||||||
|
@request = Gem::Request.new(uri, Net::HTTP::Get, nil, nil)
|
||||||
|
conn = util_stub_connection_for :body => :junk, :code => 200
|
||||||
|
|
||||||
|
@request.fetch
|
||||||
|
|
||||||
|
auth_header = conn.payload['Authorization']
|
||||||
|
|
||||||
|
assert_equal "Basic #{Base64.encode64('user:{DEScede}pass')}".strip, auth_header
|
||||||
|
end
|
||||||
|
|
||||||
def test_fetch_head
|
def test_fetch_head
|
||||||
uri = URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}"
|
uri = URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}"
|
||||||
@request = Gem::Request.new(uri, Net::HTTP::Get, nil, nil)
|
@request = Gem::Request.new(uri, Net::HTTP::Get, nil, nil)
|
||||||
|
|
|
@ -59,6 +59,8 @@ class TestGemRequestSet < Gem::TestCase
|
||||||
assert_includes installed, 'a-2'
|
assert_includes installed, 'a-2'
|
||||||
assert_path_exists File.join @gemhome, 'gems', 'a-2'
|
assert_path_exists File.join @gemhome, 'gems', 'a-2'
|
||||||
assert_path_exists 'gem.deps.rb.lock'
|
assert_path_exists 'gem.deps.rb.lock'
|
||||||
|
|
||||||
|
assert rs.remote
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_install_from_gemdeps_install_dir
|
def test_install_from_gemdeps_install_dir
|
||||||
|
@ -89,6 +91,25 @@ class TestGemRequestSet < Gem::TestCase
|
||||||
refute_path_exists File.join Gem.dir, 'gems', 'a-2'
|
refute_path_exists File.join Gem.dir, 'gems', 'a-2'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_install_from_gemdeps_local
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.gem 'a', 2
|
||||||
|
end
|
||||||
|
|
||||||
|
rs = Gem::RequestSet.new
|
||||||
|
|
||||||
|
open 'gem.deps.rb', 'w' do |io|
|
||||||
|
io.puts 'gem "a"'
|
||||||
|
io.flush
|
||||||
|
|
||||||
|
assert_raises Gem::UnsatisfiableDependencyError do
|
||||||
|
rs.install_from_gemdeps :gemdeps => io.path, :domain => :local
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
refute rs.remote
|
||||||
|
end
|
||||||
|
|
||||||
def test_install_from_gemdeps_lockfile
|
def test_install_from_gemdeps_lockfile
|
||||||
spec_fetcher do |fetcher|
|
spec_fetcher do |fetcher|
|
||||||
fetcher.gem 'a', 1
|
fetcher.gem 'a', 1
|
||||||
|
|
|
@ -33,6 +33,14 @@ class TestGemResolver < Gem::TestCase
|
||||||
assert_same Gem::Resolver, Gem::DependencyResolver
|
assert_same Gem::Resolver, Gem::DependencyResolver
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_self_compose_sets_best_set
|
||||||
|
best_set = @DR::BestSet.new
|
||||||
|
|
||||||
|
composed = @DR.compose_sets best_set
|
||||||
|
|
||||||
|
assert_equal best_set, composed
|
||||||
|
end
|
||||||
|
|
||||||
def test_self_compose_sets_multiple
|
def test_self_compose_sets_multiple
|
||||||
index_set = @DR::IndexSet.new
|
index_set = @DR::IndexSet.new
|
||||||
vendor_set = @DR::VendorSet.new
|
vendor_set = @DR::VendorSet.new
|
||||||
|
|
|
@ -17,6 +17,14 @@ class TestGemResolverAPISet < Gem::TestCase
|
||||||
assert_equal Gem::Source.new(URI('https://rubygems.org')), set.source
|
assert_equal Gem::Source.new(URI('https://rubygems.org')), set.source
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_initialize_deeper_uri
|
||||||
|
set = @DR::APISet.new 'https://rubygemsserver.com/mygems/api/v1/dependencies'
|
||||||
|
|
||||||
|
assert_equal URI('https://rubygemsserver.com/mygems/api/v1/dependencies'), set.dep_uri
|
||||||
|
assert_equal URI('https://rubygemsserver.com/mygems/'), set.uri
|
||||||
|
assert_equal Gem::Source.new(URI('https://rubygemsserver.com/mygems/')), set.source
|
||||||
|
end
|
||||||
|
|
||||||
def test_initialize_uri
|
def test_initialize_uri
|
||||||
set = @DR::APISet.new @dep_uri
|
set = @DR::APISet.new @dep_uri
|
||||||
|
|
||||||
|
@ -74,6 +82,15 @@ class TestGemResolverAPISet < Gem::TestCase
|
||||||
assert_equal expected, set.find_all(a_dep)
|
assert_equal expected, set.find_all(a_dep)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_find_all_local
|
||||||
|
set = @DR::APISet.new @dep_uri
|
||||||
|
set.remote = false
|
||||||
|
|
||||||
|
a_dep = @DR::DependencyRequest.new dep('a'), nil
|
||||||
|
|
||||||
|
assert_empty set.find_all(a_dep)
|
||||||
|
end
|
||||||
|
|
||||||
def test_find_all_missing
|
def test_find_all_missing
|
||||||
spec_fetcher
|
spec_fetcher
|
||||||
|
|
||||||
|
@ -163,5 +180,29 @@ class TestGemResolverAPISet < Gem::TestCase
|
||||||
set.prefetch [a_dep, b_dep]
|
set.prefetch [a_dep, b_dep]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_prefetch_local
|
||||||
|
spec_fetcher
|
||||||
|
|
||||||
|
data = [
|
||||||
|
{ :name => 'a',
|
||||||
|
:number => '1',
|
||||||
|
:platform => 'ruby',
|
||||||
|
:dependencies => [], },
|
||||||
|
]
|
||||||
|
|
||||||
|
@fetcher.data["#{@dep_uri}?gems=a,b"] = Marshal.dump data
|
||||||
|
@fetcher.data["#{@dep_uri}?gems=b"] = Marshal.dump []
|
||||||
|
|
||||||
|
set = @DR::APISet.new @dep_uri
|
||||||
|
set.remote = false
|
||||||
|
|
||||||
|
a_dep = @DR::DependencyRequest.new dep('a'), nil
|
||||||
|
b_dep = @DR::DependencyRequest.new dep('b'), nil
|
||||||
|
|
||||||
|
set.prefetch [a_dep, b_dep]
|
||||||
|
|
||||||
|
assert_empty set.instance_variable_get :@data
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,12 @@ class TestGemResolverBestSet < Gem::TestCase
|
||||||
@DR = Gem::Resolver
|
@DR = Gem::Resolver
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_initialize
|
||||||
|
set = @DR::BestSet.new
|
||||||
|
|
||||||
|
assert_empty set.sets
|
||||||
|
end
|
||||||
|
|
||||||
def test_find_all_index
|
def test_find_all_index
|
||||||
spec_fetcher do |fetcher|
|
spec_fetcher do |fetcher|
|
||||||
fetcher.spec 'a', 1
|
fetcher.spec 'a', 1
|
||||||
|
@ -26,5 +32,49 @@ class TestGemResolverBestSet < Gem::TestCase
|
||||||
assert_equal %w[a-1], found.map { |s| s.full_name }
|
assert_equal %w[a-1], found.map { |s| s.full_name }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_find_all_local
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
|
fetcher.spec 'a', 2
|
||||||
|
fetcher.spec 'b', 1
|
||||||
|
end
|
||||||
|
|
||||||
|
set = @DR::BestSet.new
|
||||||
|
set.remote = false
|
||||||
|
|
||||||
|
dependency = dep 'a', '~> 1'
|
||||||
|
|
||||||
|
req = @DR::DependencyRequest.new dependency, nil
|
||||||
|
|
||||||
|
found = set.find_all req
|
||||||
|
|
||||||
|
assert_empty found
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_prefetch
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
|
end
|
||||||
|
|
||||||
|
set = @DR::BestSet.new
|
||||||
|
|
||||||
|
set.prefetch []
|
||||||
|
|
||||||
|
refute_empty set.sets
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_prefetch_local
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
|
end
|
||||||
|
|
||||||
|
set = @DR::BestSet.new
|
||||||
|
set.remote = false
|
||||||
|
|
||||||
|
set.prefetch []
|
||||||
|
|
||||||
|
assert_empty set.sets
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
18
test/rubygems/test_gem_resolver_composed_set.rb
Normal file
18
test/rubygems/test_gem_resolver_composed_set.rb
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
require 'rubygems/test_case'
|
||||||
|
|
||||||
|
class TestGemResolverComposedSet < Gem::TestCase
|
||||||
|
|
||||||
|
def test_remote_equals
|
||||||
|
best_set = Gem::Resolver::BestSet.new
|
||||||
|
current_set = Gem::Resolver::CurrentSet.new
|
||||||
|
|
||||||
|
set = Gem::Resolver::ComposedSet.new best_set, current_set
|
||||||
|
|
||||||
|
set.remote = false
|
||||||
|
|
||||||
|
refute best_set.remote?
|
||||||
|
refute current_set.remote?
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
|
@ -70,6 +70,21 @@ class TestGemResolverGitSet < Gem::TestCase
|
||||||
assert_equal [@set.specs['a']], found
|
assert_equal [@set.specs['a']], found
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_find_all_local
|
||||||
|
name, _, repository, = git_gem
|
||||||
|
|
||||||
|
@set.add_git_gem name, repository, 'master', false
|
||||||
|
@set.remote = false
|
||||||
|
|
||||||
|
dependency = dep 'a', '~> 1.0'
|
||||||
|
req = Gem::Resolver::DependencyRequest.new dependency, nil
|
||||||
|
@reqs.add req
|
||||||
|
|
||||||
|
@set.prefetch @reqs
|
||||||
|
|
||||||
|
assert_empty @set.find_all dependency
|
||||||
|
end
|
||||||
|
|
||||||
def test_root_dir
|
def test_root_dir
|
||||||
assert_equal Gem.dir, @set.root_dir
|
assert_equal Gem.dir, @set.root_dir
|
||||||
|
|
||||||
|
|
|
@ -24,5 +24,40 @@ class TestGemResolverIndexSet < Gem::TestCase
|
||||||
refute_same Gem::SpecFetcher.fetcher, fetcher
|
refute_same Gem::SpecFetcher.fetcher, fetcher
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_find_all
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
|
fetcher.spec 'a', 2
|
||||||
|
fetcher.spec 'b', 1
|
||||||
|
end
|
||||||
|
|
||||||
|
set = @DR::BestSet.new
|
||||||
|
|
||||||
|
dependency = dep 'a', '~> 1'
|
||||||
|
|
||||||
|
req = @DR::DependencyRequest.new dependency, nil
|
||||||
|
|
||||||
|
found = set.find_all req
|
||||||
|
|
||||||
|
assert_equal %w[a-1], found.map { |s| s.full_name }
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_find_all_local
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
|
fetcher.spec 'a', 2
|
||||||
|
fetcher.spec 'b', 1
|
||||||
|
end
|
||||||
|
|
||||||
|
set = @DR::BestSet.new
|
||||||
|
set.remote = false
|
||||||
|
|
||||||
|
dependency = dep 'a', '~> 1'
|
||||||
|
|
||||||
|
req = @DR::DependencyRequest.new dependency, nil
|
||||||
|
|
||||||
|
assert_empty set.find_all req
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,34 @@ require 'rubygems/test_case'
|
||||||
|
|
||||||
class TestGemResolverInstallerSet < Gem::TestCase
|
class TestGemResolverInstallerSet < Gem::TestCase
|
||||||
|
|
||||||
|
def test_consider_local_eh
|
||||||
|
set = Gem::Resolver::InstallerSet.new :remote
|
||||||
|
|
||||||
|
refute set.consider_local?
|
||||||
|
|
||||||
|
set = Gem::Resolver::InstallerSet.new :both
|
||||||
|
|
||||||
|
assert set.consider_local?
|
||||||
|
|
||||||
|
set = Gem::Resolver::InstallerSet.new :local
|
||||||
|
|
||||||
|
assert set.consider_local?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_consider_remote_eh
|
||||||
|
set = Gem::Resolver::InstallerSet.new :remote
|
||||||
|
|
||||||
|
assert set.consider_remote?
|
||||||
|
|
||||||
|
set = Gem::Resolver::InstallerSet.new :both
|
||||||
|
|
||||||
|
assert set.consider_remote?
|
||||||
|
|
||||||
|
set = Gem::Resolver::InstallerSet.new :local
|
||||||
|
|
||||||
|
refute set.consider_remote?
|
||||||
|
end
|
||||||
|
|
||||||
def test_load_spec
|
def test_load_spec
|
||||||
specs = spec_fetcher do |fetcher|
|
specs = spec_fetcher do |fetcher|
|
||||||
fetcher.spec 'a', 2
|
fetcher.spec 'a', 2
|
||||||
|
@ -18,5 +46,47 @@ class TestGemResolverInstallerSet < Gem::TestCase
|
||||||
assert_equal specs["a-2-#{Gem::Platform.local}"].full_name, spec.full_name
|
assert_equal specs["a-2-#{Gem::Platform.local}"].full_name, spec.full_name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_remote_equals_both
|
||||||
|
set = Gem::Resolver::InstallerSet.new :both
|
||||||
|
set.remote = true
|
||||||
|
|
||||||
|
assert set.consider_local?
|
||||||
|
assert set.consider_remote?
|
||||||
|
|
||||||
|
set = Gem::Resolver::InstallerSet.new :both
|
||||||
|
set.remote = false
|
||||||
|
|
||||||
|
assert set.consider_local?
|
||||||
|
refute set.consider_remote?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_remote_equals_local
|
||||||
|
set = Gem::Resolver::InstallerSet.new :local
|
||||||
|
set.remote = true
|
||||||
|
|
||||||
|
assert set.consider_local?
|
||||||
|
assert set.consider_remote?
|
||||||
|
|
||||||
|
set = Gem::Resolver::InstallerSet.new :local
|
||||||
|
set.remote = false
|
||||||
|
|
||||||
|
assert set.consider_local?
|
||||||
|
refute set.consider_remote?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_remote_equals_remote
|
||||||
|
set = Gem::Resolver::InstallerSet.new :remote
|
||||||
|
set.remote = true
|
||||||
|
|
||||||
|
refute set.consider_local?
|
||||||
|
assert set.consider_remote?
|
||||||
|
|
||||||
|
set = Gem::Resolver::InstallerSet.new :remote
|
||||||
|
set.remote = false
|
||||||
|
|
||||||
|
refute set.consider_local?
|
||||||
|
refute set.consider_remote?
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,26 @@ class TestGemSourceGit < Gem::TestCase
|
||||||
assert_path_exists File.join @source.install_dir, 'a.gemspec'
|
assert_path_exists File.join @source.install_dir, 'a.gemspec'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_checkout_local
|
||||||
|
@source.remote = false
|
||||||
|
|
||||||
|
@source.checkout
|
||||||
|
|
||||||
|
install_dir = File.join Gem.dir, 'bundler', 'gems', "a-#{@head[0..11]}"
|
||||||
|
|
||||||
|
refute_path_exists File.join install_dir, 'a.gemspec'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_checkout_local_cached
|
||||||
|
@source.cache
|
||||||
|
|
||||||
|
@source.remote = false
|
||||||
|
|
||||||
|
@source.checkout
|
||||||
|
|
||||||
|
assert_path_exists File.join @source.install_dir, 'a.gemspec'
|
||||||
|
end
|
||||||
|
|
||||||
def test_checkout_submodules
|
def test_checkout_submodules
|
||||||
source = Gem::Source::Git.new @name, @repository, 'master', true
|
source = Gem::Source::Git.new @name, @repository, 'master', true
|
||||||
|
|
||||||
|
@ -54,6 +74,14 @@ class TestGemSourceGit < Gem::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_cache_local
|
||||||
|
@source.remote = false
|
||||||
|
|
||||||
|
@source.cache
|
||||||
|
|
||||||
|
refute_path_exists @source.repo_cache_dir
|
||||||
|
end
|
||||||
|
|
||||||
def test_dir_shortref
|
def test_dir_shortref
|
||||||
@source.cache
|
@source.cache
|
||||||
|
|
||||||
|
@ -99,6 +127,12 @@ class TestGemSourceGit < Gem::TestCase
|
||||||
assert_equal expected, @source.install_dir
|
assert_equal expected, @source.install_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_install_dir_local
|
||||||
|
@source.remote = false
|
||||||
|
|
||||||
|
assert_nil @source.install_dir
|
||||||
|
end
|
||||||
|
|
||||||
def test_repo_cache_dir
|
def test_repo_cache_dir
|
||||||
expected =
|
expected =
|
||||||
File.join Gem.dir, 'cache', 'bundler', 'git', "a-#{@hash}"
|
File.join Gem.dir, 'cache', 'bundler', 'git', "a-#{@hash}"
|
||||||
|
@ -211,6 +245,15 @@ class TestGemSourceGit < Gem::TestCase
|
||||||
assert_equal extension_dir, b_spec.extension_dir
|
assert_equal extension_dir, b_spec.extension_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_specs_local
|
||||||
|
source = Gem::Source::Git.new @name, @repository, 'master', true
|
||||||
|
source.remote = false
|
||||||
|
|
||||||
|
capture_io do
|
||||||
|
assert_empty source.specs
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_uri_hash
|
def test_uri_hash
|
||||||
assert_equal @hash, @source.uri_hash
|
assert_equal @hash, @source.uri_hash
|
||||||
|
|
||||||
|
|
|
@ -1789,9 +1789,7 @@ dependencies: []
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_require_paths
|
def test_require_paths
|
||||||
enable_shared, RbConfig::CONFIG['ENABLE_SHARED'] =
|
enable_shared 'no' do
|
||||||
RbConfig::CONFIG['ENABLE_SHARED'], 'no'
|
|
||||||
|
|
||||||
ext_spec
|
ext_spec
|
||||||
|
|
||||||
@ext.require_path = 'lib'
|
@ext.require_path = 'lib'
|
||||||
|
@ -1801,8 +1799,7 @@ dependencies: []
|
||||||
relative_install_dir = ext_install_dir.relative_path_from full_gem_path
|
relative_install_dir = ext_install_dir.relative_path_from full_gem_path
|
||||||
|
|
||||||
assert_equal [relative_install_dir.to_s, 'lib'], @ext.require_paths
|
assert_equal [relative_install_dir.to_s, 'lib'], @ext.require_paths
|
||||||
ensure
|
end
|
||||||
RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_source
|
def test_source
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue