* lib/rubygems: Update to RubyGems master commit 2a74263. This fixes

several bugs in RubyGems 2.2.0.preview.1.

* test/rubygems:  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2013-10-16 00:14:16 +00:00
Родитель cfe1458078
Коммит 28918eac58
62 изменённых файлов: 1270 добавлений и 3847 удалений

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

@ -1,3 +1,10 @@
Wed Oct 16 09:12:23 2013 Eric Hodel <drbrain@segment7.net>
* lib/rubygems: Update to RubyGems master commit 2a74263. This fixes
several bugs in RubyGems 2.2.0.preview.1.
* test/rubygems: ditto.
Wed Oct 16 07:25:02 2013 Aman Gupta <ruby@tmm1.net>
* gc.c (gc_mark_roots): rename roots to be categories

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

@ -8,7 +8,7 @@
require 'rbconfig'
module Gem
VERSION = '2.2.0.preview.1'
VERSION = '2.2.0'
end
# Must be first since it unloads the prelude from 1.9.2
@ -139,6 +139,7 @@ module Gem
build_info
cache
doc
extensions
gems
specifications
]
@ -158,6 +159,7 @@ module Gem
@path_to_default_spec_map = {}
@platforms = []
@ruby = nil
@ruby_api_version = nil
@sources = nil
@post_build_hooks ||= []
@ -822,6 +824,14 @@ module Gem
@ruby
end
##
# Returns a String containing the API compatibility version of Ruby
def self.ruby_api_version
@ruby_api_version ||=
"#{ConfigMap[:MAJOR]}.#{ConfigMap[:MINOR]}.#{ConfigMap[:TEENY]}"
end
##
# Returns the latest release-version specification for the gem +name+.

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

@ -38,11 +38,12 @@ class Gem::BasicSpecification
# Return true if this spec can require +file+.
def contains_requirable_file? file
root = full_gem_path
build_extensions
suffixes = Gem.suffixes
require_paths.any? do |lib|
base = "#{root}/#{lib}/#{file}"
full_require_paths.any? do |dir|
base = "#{dir}/#{file}"
suffixes.any? { |suf| File.file? "#{base}#{suf}" }
end
end
@ -52,6 +53,27 @@ class Gem::BasicSpecification
File.dirname(loaded_from) == self.class.default_specifications_dir
end
##
# The directory the named +extension+ was installed into after being built.
#
# Usage:
#
# spec.extensions.each do |ext|
# puts spec.extension_install_dir ext
# end
def extension_install_dir
ruby_api_version =
if 'no' == RbConfig::CONFIG['ENABLE_SHARED'] then
"#{Gem.ruby_api_version}-static"
else
Gem.ruby_api_version
end
File.join base_dir, 'extensions', Gem::Platform.local.to_s,
ruby_api_version, full_name
end
def find_full_gem_path # :nodoc:
# TODO: also, shouldn't it default to full_name if it hasn't been written?
path = File.expand_path File.join(gems_dir, full_name)
@ -83,6 +105,28 @@ class Gem::BasicSpecification
end
end
##
# Full paths in the gem to add to <code>$LOAD_PATH</code> when this gem is
# activated.
def full_require_paths
full_paths = @require_paths.map do |path|
File.join full_gem_path, path
end
full_paths << extension_install_dir unless @extensions.empty?
full_paths
end
##
# Returns the full path to this spec's gem directory.
# eg: /usr/local/lib/ruby/1.8/gems/mygem-1.0
def gem_dir
@gem_dir ||= File.expand_path File.join(gems_dir, full_name)
end
##
# Returns the full path to the gems directory containing this spec's
# gem directory. eg: /usr/local/lib/ruby/1.8/gems
@ -119,10 +163,30 @@ class Gem::BasicSpecification
end
##
# Require paths of the gem
# Paths in the gem to add to <code>$LOAD_PATH</code> when this gem is
# activated.
#
# See also #require_paths=
#
# If you have an extension you do not need to add <code>"ext"</code> to the
# require path, the extension build process will copy the extension files
# into "lib" for you.
#
# The default value is <code>"lib"</code>
#
# Usage:
#
# # If all library files are in the root directory...
# spec.require_path = '.'
def require_paths
raise NotImplementedError
return @require_paths if @extensions.empty?
relative_extension_install_dir =
File.join '..', '..', '..', 'extensions', Gem::Platform.local.to_s,
Gem.ruby_api_version, full_name
@require_paths + [relative_extension_install_dir]
end
##

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

@ -161,11 +161,11 @@ is too hard to use.
:latest
end
if options[:name].source.empty?
if name.source.empty?
spec_tuples = fetcher.detect(type) { true }
else
spec_tuples = fetcher.detect(type) do |name_tuple|
options[:name] === name_tuple.name
name === name_tuple.name
end
end

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

@ -154,8 +154,7 @@ To remove a source use the --remove argument:
end
def list? # :nodoc:
!(options[:list] ||
options[:add] ||
!(options[:add] ||
options[:clear_all] ||
options[:remove] ||
options[:update])

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

@ -110,7 +110,9 @@ command to remove old versions.
fetcher = Gem::SpecFetcher.fetcher
spec_tuples, _ = fetcher.search_for_dependency dependency
spec_tuples, errors = fetcher.search_for_dependency dependency
raise errors.first unless errors.empty?
spec_tuples
end

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

@ -34,6 +34,9 @@ module Gem
RubyGemsVersion = VERSION
RbConfigPriorities = %w[
MAJOR
MINOR
TEENY
EXEEXT RUBY_SO_NAME arch bindir datadir libdir ruby_install_name
ruby_version rubylibprefix sitedir sitelibdir vendordir vendorlibdir
rubylibdir

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

@ -5,6 +5,7 @@
#++
require 'rubygems/user_interaction'
require 'rbconfig'
##
# Gem::ConfigFile RubyGems options and gem command options from gemrc.

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

@ -38,6 +38,8 @@ module Kernel
def require path
RUBYGEMS_ACTIVATION_MONITOR.enter
path = path.to_path if path.respond_to? :to_path
spec = Gem.find_unresolved_default_spec(path)
if spec
Gem.remove_unresolved_default_spec(spec)

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

@ -74,12 +74,6 @@ class Gem::DependencyInstaller
@only_install_dir = !!options[:install_dir]
@install_dir = options[:install_dir] || Gem.dir
if options[:install_dir] then
# HACK shouldn't change the global settings, needed for -i behavior
# maybe move to the install command? See also github #442
Gem::Specification.dirs = @install_dir
end
options = DEFAULT_OPTIONS.merge options
@bin_dir = options[:bin_dir]
@ -409,7 +403,9 @@ class Gem::DependencyInstaller
request_set.soft_missing = true
end
request_set.resolve Gem::DependencyResolver.compose_sets(as, installer_set)
composed_set = Gem::DependencyResolver.compose_sets as, installer_set
request_set.resolve composed_set
request_set
end

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

@ -30,7 +30,7 @@ class Gem::DependencyResolver::IndexSet
name = req.dependency.name
@all[name].each do |uri, n|
if req.dependency.match? n
if req.dependency.match? n then
res << Gem::DependencyResolver::IndexSpecification.new(
self, n.name, n.version, uri, n.platform)
end

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

@ -13,12 +13,12 @@ class Gem::DependencyResolver::IndexSpecification
attr_reader :version
def initialize set, name, version, source, plat
def initialize set, name, version, source, platform
@set = set
@name = name
@version = version
@source = source
@platform = plat
@platform = platform.to_s
@spec = nil
end

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

@ -87,7 +87,11 @@ class Gem::DependencyResolver::InstallerSet
end
def inspect # :nodoc:
'#<%s domain: %s specs: %p>' % [ self.class, @domain, @specs.keys ]
always_install = @always_install.map { |s| s.full_name }
'#<%s domain: %s specs: %p always install: %p>' % [
self.class, @domain, @specs.keys, always_install,
]
end
##
@ -131,5 +135,20 @@ class Gem::DependencyResolver::InstallerSet
def prefetch(reqs)
end
def pretty_print q # :nodoc:
q.group 2, '[InstallerSet', ']' do
q.breakable
q.text "domain: #{@domain}"
q.breakable
q.text 'specs: '
q.pp @specs.keys
q.breakable
q.text 'always install: '
q.pp @always_install
end
end
end

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

@ -24,6 +24,7 @@ class Gem::Doctor
['build_info', '.info'],
['cache', '.gem'],
['doc', ''],
['extensions', ''],
['gems', ''],
]

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

@ -85,5 +85,10 @@ module Gem
def wordy
"Unable to download data from #{@source.uri} - #{@error.message}"
end
##
# The "exception" alias allows you to call raise on a SourceFetchProblem.
alias exception error
end
end

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

@ -11,6 +11,7 @@ require 'rubygems'
module Gem::Ext; end
require 'rubygems/ext/build_error'
require 'rubygems/ext/builder'
require 'rubygems/ext/configure_builder'
require 'rubygems/ext/ext_conf_builder'

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

@ -0,0 +1,6 @@
##
# Raised when there is an error while building extensions.
class Gem::Ext::BuildError < Gem::InstallError
end

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

@ -19,6 +19,11 @@ class Gem::Ext::Builder
CHDIR_MUTEX = Mutex.new # :nodoc:
##
# `make` targets to run when building the extension
MAKE_TARGETS = ['clean', '', 'install'] # :nodoc:
attr_accessor :build_args # :nodoc:
def self.class_name
@ -28,7 +33,7 @@ class Gem::Ext::Builder
def self.make(dest_path, results)
unless File.exist? 'Makefile' then
raise Gem::InstallError, "Makefile not found:\n\n#{results.join "\n"}"
raise Gem::InstallError, 'Makefile not found'
end
# try to find make program from Ruby configure arguments first
@ -40,7 +45,7 @@ class Gem::Ext::Builder
destdir = '"DESTDIR=%s"' % ENV['DESTDIR'] if RUBY_VERSION > '2.0'
['', 'install'].each do |target|
self::MAKE_TARGETS.each do |target|
# Pass DESTDIR via command line to override what's in MAKEFLAGS
cmd = [
make_program,
@ -74,15 +79,24 @@ class Gem::Ext::Builder
unless $?.success? then
results << "Building has failed. See above output for more information on the failure." if verbose
raise Gem::InstallError, "#{command_name || class_name} failed:\n\n#{results.join "\n"}"
exit_reason =
if $?.exited? then
", exit code #{$?.exitstatus}"
elsif $?.signaled? then
", uncaught signal #{$?.termsig}"
end
raise Gem::InstallError, "#{command_name || class_name} failed#{exit_reason}"
end
end
##
# Creates a new extension builder for +spec+ using the given +build_args+.
# The gem for +spec+ is unpacked in +gem_dir+.
# Creates a new extension builder for +spec+. If the +spec+ does not yet
# have build arguments, saved, set +build_args+ which is an ARGV-style
# array.
def initialize spec, build_args
def initialize spec, build_args = spec.build_args
@spec = spec
@build_args = build_args
@gem_dir = spec.gem_dir
@ -113,12 +127,10 @@ class Gem::Ext::Builder
end
##
# Logs the build +output+ in +build_dir+, then raises ExtensionBuildError.
# Logs the build +output+ in +build_dir+, then raises Gem::Ext::BuildError.
def build_error build_dir, output, backtrace = nil # :nodoc:
gem_make_out = File.join build_dir, 'gem_make.out'
open gem_make_out, 'wb' do |io| io.puts output end
gem_make_out = write_gem_make_out output
message = <<-EOF
ERROR: Failed to build gem native extension.
@ -129,14 +141,15 @@ Gem files will remain installed in #{@gem_dir} for inspection.
Results logged to #{gem_make_out}
EOF
raise Gem::Installer::ExtensionBuildError, message, backtrace
raise Gem::Ext::BuildError, message, backtrace
end
def build_extension extension, dest_path # :nodoc:
results = []
extension ||= '' # I wish I knew why this line existed
extension_dir = File.join @gem_dir, File.dirname(extension)
extension_dir =
File.expand_path File.join @gem_dir, File.dirname(extension)
builder = builder_for extension
@ -151,7 +164,10 @@ EOF
say results.join("\n") if Gem.configuration.really_verbose
end
end
rescue
write_gem_make_out results.join "\n"
rescue => e
results << e.message
build_error extension_dir, results.join("\n"), $@
end
end
@ -170,7 +186,9 @@ EOF
say "This could take a while..."
end
dest_path = File.join @gem_dir, @spec.require_paths.first
dest_path = @spec.extension_install_dir
FileUtils.rm_f @spec.gem_build_complete_path
@ran_rake = false # only run rake once
@ -179,6 +197,21 @@ EOF
build_extension extension, dest_path
end
FileUtils.touch @spec.gem_build_complete_path
end
##
# Writes +output+ to gem_make.out in the extension install directory.
def write_gem_make_out output # :nodoc:
destination = File.join @spec.extension_install_dir, 'gem_make.out'
FileUtils.mkdir_p @spec.extension_install_dir
open destination, 'wb' do |io| io.puts output end
destination
end
end

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

@ -1,4 +1,7 @@
class Gem::Ext::CmakeBuilder < Gem::Ext::Builder
MAKE_TARGETS = ['', 'install'] # :nodoc:
def self.build(extension, directory, dest_path, results)
unless File.exist?('Makefile') then
cmd = "cmake . -DCMAKE_INSTALL_PREFIX=#{dest_path}"

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

@ -126,7 +126,7 @@ class Gem::Indexer
# Builds Marshal quick index gemspecs.
def build_marshal_gemspecs
count = Gem::Specification.count
count = Gem::Specification.count { |s| not s.default_gem? }
progress = ui.progress_reporter count,
"Generating Marshal quick index gemspecs for #{count} gems",
"Complete"
@ -135,6 +135,7 @@ class Gem::Indexer
Gem.time 'Generated Marshal quick index gemspecs' do
Gem::Specification.each do |spec|
next if spec.default_gem?
spec_file_name = "#{spec.original_name}.gemspec.rz"
marshal_name = File.join @quick_marshal_dir, spec_file_name
@ -188,10 +189,13 @@ class Gem::Indexer
# Builds indicies for RubyGems 1.2 and newer. Handles full, latest, prerelease
def build_modern_indicies
prerelease, released = Gem::Specification.partition { |s|
specs = Gem::Specification.reject { |s| s.default_gem? }
prerelease, released = specs.partition { |s|
s.version.prerelease?
}
latest_specs = Gem::Specification.latest_specs
latest_specs =
Gem::Specification.latest_specs.reject { |s| s.default_gem? }
build_modern_index(released.sort, @specs_index, 'specs')
build_modern_index(latest_specs.sort, @latest_specs_index, 'latest specs')

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

@ -32,9 +32,9 @@ class Gem::Installer
ENV_PATHS = %w[/usr/bin/env /bin/env]
##
# Raised when there is an error while building extensions.
#
class ExtensionBuildError < Gem::InstallError; end
# Deprecated in favor of Gem::Ext::BuildError
ExtensionBuildError = Gem::Ext::BuildError # :nodoc:
include Gem::UserInteraction
@ -667,7 +667,7 @@ TEXT
end
##
# Logs the build +output+ in +build_dir+, then raises ExtensionBuildError.
# Logs the build +output+ in +build_dir+, then raises Gem::Ext::BuildError.
#
# TODO: Delete this for RubyGems 3. It remains for API compatibility

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

@ -339,13 +339,9 @@ EOM
def extract_tar_gz io, destination_dir, pattern = "*" # :nodoc:
open_tar_gz io do |tar|
tar.each do |entry|
# Some entries start with "./" which fnmatch does not like, see github
# issue #644
full_name = entry.full_name.sub %r%\A\./%, ''
next unless File.fnmatch pattern, entry.full_name, File::FNM_DOTMATCH
next unless File.fnmatch pattern, full_name
destination = install_location full_name, destination_dir
destination = install_location entry.full_name, destination_dir
FileUtils.rm_rf destination
@ -395,6 +391,7 @@ EOM
destination_dir = File.realpath destination_dir if
File.respond_to? :realpath
destination_dir = File.expand_path destination_dir
destination = File.join destination_dir, filename
destination = File.expand_path destination

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

@ -78,8 +78,8 @@ class Gem::Request
net_http_args += [
@proxy_uri.host,
@proxy_uri.port,
@proxy_uri.user,
@proxy_uri.password
Gem::UriFormatter.new(@proxy_uri.user).unescape,
Gem::UriFormatter.new(@proxy_uri.password).unescape,
]
end
@ -114,8 +114,7 @@ class Gem::Request
request.add_field 'Keep-Alive', '30'
if @last_modified then
@last_modified = @last_modified.utc
request.add_field 'If-Modified-Since', @last_modified.rfc2822
request.add_field 'If-Modified-Since', @last_modified.httpdate
end
yield request if block_given?

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

@ -60,11 +60,14 @@ class Gem::RequestSet
specs = []
sorted_requests.each do |req|
if req.installed? and
@always_install.none? { |spec| spec == req.spec.spec } then
if req.installed? then
req.spec.spec.build_extensions
if @always_install.none? { |spec| spec == req.spec.spec } then
yield req, nil if block_given?
next
end
end
path = req.download cache_dir

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

@ -97,7 +97,7 @@ class Gem::Source::Local < Gem::Source
if data = @specs[name]
data.last.spec
else
raise Gem::Exception, "Unable to find spec for '#{name}'"
raise Gem::Exception, "Unable to find spec for #{name.inspect}"
end
end

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

@ -225,13 +225,14 @@ class Gem::SpecFetcher
tuples =
begin
cache[source.uri] ||= source.load_specs(type)
cache[source.uri] ||=
source.load_specs(type).sort_by { |tup| tup.name }
rescue Gem::RemoteFetcher::FetchError
raise unless gracefully_ignore
[]
end
tuples.sort_by { |tup| tup.name }
tuples
end
end

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

@ -35,18 +35,8 @@ class Date; end
# end
#
# Starting in RubyGems 2.0, a Specification can hold arbitrary
# metadata. This metadata is accessed via Specification#metadata
# and has the following restrictions:
#
# * Must be a Hash object
# * All keys and values must be Strings
# * Keys can be a maximum of 128 bytes and values can be a
# maximum of 1024 bytes
# * All strings must be UTF8, no binary data is allowed
#
# For example, to add metadata for the location of a bugtracker:
#
# s.metadata = { "bugtracker" => "http://somewhere.com/blah" }
# metadata. See #metadata for restrictions on the format and size of metadata
# items you may add to a specification.
class Gem::Specification < Gem::BasicSpecification
@ -209,6 +199,8 @@ class Gem::Specification < Gem::BasicSpecification
# Paths in the gem to add to <code>$LOAD_PATH</code> when this gem is
# activated.
#
# See also #require_paths
#
# If you have an extension you do not need to add <code>"ext"</code> to the
# require path, the extension build process will copy the extension files
# into "lib" for you.
@ -220,7 +212,7 @@ class Gem::Specification < Gem::BasicSpecification
# # If all library files are in the root directory...
# spec.require_path = '.'
attr_accessor :require_paths
attr_writer :require_paths
##
# The version of RubyGems used to create this gem.
@ -398,10 +390,21 @@ class Gem::Specification < Gem::BasicSpecification
##
# :attr_accessor: metadata
#
# Arbitrary metadata for this gem. An instance of Hash.
# The metadata holds extra data for this gem that may be useful to other
# consumers and is settable by gem authors without requiring an update to
# the rubygems software.
#
# metadata is simply a Symbol => String association that contains arbitary
# data that could be useful to other consumers.
# Metadata items have the following restrictions:
#
# * The metadata must be a Hash object
# * All keys and values must be Strings
# * Keys can be a maximum of 128 bytes and values can be a maximum of 1024
# bytes
# * All strings must be UTF-8, no binary data is allowed
#
# To add metadata for the location of a issue tracker:
#
# s.metadata = { "issue_tracker" => "https://example/issues" }
attr_accessor :metadata
@ -510,6 +513,9 @@ class Gem::Specification < Gem::BasicSpecification
# This should just be the name of your license. The full
# text of the license should be inside of the gem when you build it.
#
# See http://opensource.org/licenses/alphabetical for a list of licenses and
# their abbreviations (or short names).
#
# You can set multiple licenses with #licenses=
#
# Usage:
@ -527,6 +533,8 @@ class Gem::Specification < Gem::BasicSpecification
# This should just be the name of your license. The full
# text of the license should be inside of the gem when you build it.
#
# See #license= for more discussion
#
# Usage:
# spec.licenses = ['MIT', 'GPL-2']
@ -665,8 +673,7 @@ class Gem::Specification < Gem::BasicSpecification
LOAD_CACHE.clear
end
# :nodoc:
def self.each_gemspec(dirs)
def self.each_gemspec(dirs) # :nodoc:
dirs.each do |dir|
Dir[File.join(dir, "*.gemspec")].each do |path|
yield path.untaint
@ -674,16 +681,14 @@ class Gem::Specification < Gem::BasicSpecification
end
end
# :nodoc:
def self.each_stub(dirs)
def self.each_stub(dirs) # :nodoc:
each_gemspec(dirs) do |path|
stub = Gem::StubSpecification.new(path)
yield stub if stub.valid?
end
end
# :nodoc:
def self.each_spec(dirs)
def self.each_spec(dirs) # :nodoc:
each_gemspec(dirs) do |path|
spec = self.load path
yield spec if spec
@ -1379,6 +1384,25 @@ class Gem::Specification < Gem::BasicSpecification
end
end
##
# Builds extensions for this platform if the gem has extensions listed and
# the gem.build_complete file is missing.
def build_extensions # :nodoc:
return if default_gem?
return if File.exist? gem_build_complete_path
return if !File.writable?(base_dir) &&
!File.exist?(File.join(base_dir, 'extensions'))
gem_original_require 'rubygems/ext'
gem_original_require 'rubygems/user_interaction'
Gem::DefaultUserInteraction.use_ui Gem::SilentUI.new do
builder = Gem::Ext::Builder.new self
builder.build_extensions
end
end
##
# Returns the full path to the build info directory
@ -1668,8 +1692,7 @@ class Gem::Specification < Gem::BasicSpecification
spec
end
# :nodoc:
def find_full_gem_path
def find_full_gem_path # :nodoc:
super || File.expand_path(File.join(gems_dir, original_name))
end
private :find_full_gem_path
@ -1679,11 +1702,11 @@ class Gem::Specification < Gem::BasicSpecification
end
##
# Returns the full path to this spec's gem directory.
# eg: /usr/local/lib/ruby/1.8/gems/mygem-1.0
# The path to the gem.build_complete file within the extension install
# directory.
def gem_dir
@gem_dir ||= File.expand_path File.join(gems_dir, full_name)
def gem_build_complete_path # :nodoc:
File.join extension_install_dir, 'gem.build_complete'
end
##
@ -1832,6 +1855,8 @@ class Gem::Specification < Gem::BasicSpecification
##
# Plural accessor for setting licenses
#
# See #license= for details
def licenses
@licenses ||= []
@ -2012,17 +2037,6 @@ class Gem::Specification < Gem::BasicSpecification
self.require_paths = [path]
end
##
# Full paths in the gem to add to <code>$LOAD_PATH</code> when this gem is
# activated.
#
def full_require_paths
require_paths.map do |path|
File.join full_gem_path, path
end
end
##
# The RubyGems version required by this gem
@ -2189,7 +2203,9 @@ class Gem::Specification < Gem::BasicSpecification
mark_version
result = []
result << "# -*- encoding: utf-8 -*-"
result << "#{Gem::StubSpecification::PREFIX}#{name} #{version} #{platform} #{require_paths.join("\0")}"
result << "#{Gem::StubSpecification::PREFIX}#{name} #{version} #{platform} #{@require_paths.join("\0")}"
result << "#{Gem::StubSpecification::PREFIX}#{extensions.join "\0"}" unless
extensions.empty?
result << nil
result << "Gem::Specification.new do |s|"
@ -2204,11 +2220,13 @@ class Gem::Specification < Gem::BasicSpecification
if metadata and !metadata.empty?
result << " s.metadata = #{ruby_code metadata} if s.respond_to? :metadata="
end
result << " s.require_paths = #{ruby_code @require_paths}"
handled = [
:dependencies,
:name,
:platform,
:require_paths,
:required_rubygems_version,
:specification_version,
:version,
@ -2335,6 +2353,7 @@ class Gem::Specification < Gem::BasicSpecification
# checks..
def validate packaging = true
@warnings = 0
require 'rubygems/user_interaction'
extend Gem::UserInteraction
normalize
@ -2365,7 +2384,7 @@ class Gem::Specification < Gem::BasicSpecification
"invalid value for attribute name: \"#{name.inspect}\""
end
if require_paths.empty? then
if @require_paths.empty? then
raise Gem::InvalidSpecificationException,
'specification must have at least one require_path'
end
@ -2458,7 +2477,10 @@ class Gem::Specification < Gem::BasicSpecification
end
}
alert_warning 'licenses is empty' if licenses.empty?
warning <<-warning if licenses.empty?
licenses is empty. Use a license abbreviation from:
http://opensource.org/licenses/alphabetical
warning
validate_permissions
@ -2493,21 +2515,21 @@ class Gem::Specification < Gem::BasicSpecification
%w[author description email homepage summary].each do |attribute|
value = self.send attribute
alert_warning "no #{attribute} specified" if value.nil? or value.empty?
warning "no #{attribute} specified" if value.nil? or value.empty?
end
if description == summary then
alert_warning 'description and summary are identical'
warning 'description and summary are identical'
end
# TODO: raise at some given date
alert_warning "deprecated autorequire specified" if autorequire
warning "deprecated autorequire specified" if autorequire
executables.each do |executable|
executable_path = File.join(bindir, executable)
shebang = File.read(executable_path, 2) == '#!'
alert_warning "#{executable_path} is missing #! line" unless shebang
warning "#{executable_path} is missing #! line" unless shebang
end
dependencies.each do |dep|
@ -2515,11 +2537,15 @@ class Gem::Specification < Gem::BasicSpecification
Gem::Requirement.new(req).prerelease?
end
alert_warning "prerelease dependency on #{dep} is not recommended" if
warning "prerelease dependency on #{dep} is not recommended" if
prerelease_dep
end
true
ensure
if $! or @warnings > 0 then
alert_warning "See http://guides.rubygems.org/specification-reference/ for help"
end
end
##
@ -2530,13 +2556,13 @@ class Gem::Specification < Gem::BasicSpecification
files.each do |file|
next if File.stat(file).mode & 0444 == 0444
alert_warning "#{file} is not world-readable"
warning "#{file} is not world-readable"
end
executables.each do |name|
exec = File.join @bindir, name
next if File.stat(exec).executable?
alert_warning "#{exec} is not executable"
warning "#{exec} is not executable"
end
end
@ -2589,6 +2615,12 @@ class Gem::Specification < Gem::BasicSpecification
end
end
def warning statement # :nodoc:
@warnings += 1
alert_warning statement
end
extend Gem::Deprecate
# TODO:

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

@ -1,90 +0,0 @@
This CA certificate is for verifying HTTPS connection to;
- https://rubygems.org/ (obtained by RubyGems team)
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 1 (0x1)
Signature Algorithm: sha1WithRSAEncryption
Issuer: C=SE, O=AddTrust AB, OU=AddTrust External TTP Network, CN=AddTrust External CA Root
Validity
Not Before: May 30 10:48:38 2000 GMT
Not After : May 30 10:48:38 2020 GMT
Subject: C=SE, O=AddTrust AB, OU=AddTrust External TTP Network, CN=AddTrust External CA Root
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (2048 bit)
Modulus:
00:b7:f7:1a:33:e6:f2:00:04:2d:39:e0:4e:5b:ed:
1f:bc:6c:0f:cd:b5:fa:23:b6:ce:de:9b:11:33:97:
a4:29:4c:7d:93:9f:bd:4a:bc:93:ed:03:1a:e3:8f:
cf:e5:6d:50:5a:d6:97:29:94:5a:80:b0:49:7a:db:
2e:95:fd:b8:ca:bf:37:38:2d:1e:3e:91:41:ad:70:
56:c7:f0:4f:3f:e8:32:9e:74:ca:c8:90:54:e9:c6:
5f:0f:78:9d:9a:40:3c:0e:ac:61:aa:5e:14:8f:9e:
87:a1:6a:50:dc:d7:9a:4e:af:05:b3:a6:71:94:9c:
71:b3:50:60:0a:c7:13:9d:38:07:86:02:a8:e9:a8:
69:26:18:90:ab:4c:b0:4f:23:ab:3a:4f:84:d8:df:
ce:9f:e1:69:6f:bb:d7:42:d7:6b:44:e4:c7:ad:ee:
6d:41:5f:72:5a:71:08:37:b3:79:65:a4:59:a0:94:
37:f7:00:2f:0d:c2:92:72:da:d0:38:72:db:14:a8:
45:c4:5d:2a:7d:b7:b4:d6:c4:ee:ac:cd:13:44:b7:
c9:2b:dd:43:00:25:fa:61:b9:69:6a:58:23:11:b7:
a7:33:8f:56:75:59:f5:cd:29:d7:46:b7:0a:2b:65:
b6:d3:42:6f:15:b2:b8:7b:fb:ef:e9:5d:53:d5:34:
5a:27
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Subject Key Identifier:
AD:BD:98:7A:34:B4:26:F7:FA:C4:26:54:EF:03:BD:E0:24:CB:54:1A
X509v3 Key Usage:
Certificate Sign, CRL Sign
X509v3 Basic Constraints: critical
CA:TRUE
X509v3 Authority Key Identifier:
keyid:AD:BD:98:7A:34:B4:26:F7:FA:C4:26:54:EF:03:BD:E0:24:CB:54:1A
DirName:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root
serial:01
Signature Algorithm: sha1WithRSAEncryption
b0:9b:e0:85:25:c2:d6:23:e2:0f:96:06:92:9d:41:98:9c:d9:
84:79:81:d9:1e:5b:14:07:23:36:65:8f:b0:d8:77:bb:ac:41:
6c:47:60:83:51:b0:f9:32:3d:e7:fc:f6:26:13:c7:80:16:a5:
bf:5a:fc:87:cf:78:79:89:21:9a:e2:4c:07:0a:86:35:bc:f2:
de:51:c4:d2:96:b7:dc:7e:4e:ee:70:fd:1c:39:eb:0c:02:51:
14:2d:8e:bd:16:e0:c1:df:46:75:e7:24:ad:ec:f4:42:b4:85:
93:70:10:67:ba:9d:06:35:4a:18:d3:2b:7a:cc:51:42:a1:7a:
63:d1:e6:bb:a1:c5:2b:c2:36:be:13:0d:e6:bd:63:7e:79:7b:
a7:09:0d:40:ab:6a:dd:8f:8a:c3:f6:f6:8c:1a:42:05:51:d4:
45:f5:9f:a7:62:21:68:15:20:43:3c:99:e7:7c:bd:24:d8:a9:
91:17:73:88:3f:56:1b:31:38:18:b4:71:0f:9a:cd:c8:0e:9e:
8e:2e:1b:e1:8c:98:83:cb:1f:31:f1:44:4c:c6:04:73:49:76:
60:0f:c7:f8:bd:17:80:6b:2e:e9:cc:4c:0e:5a:9a:79:0f:20:
0a:2e:d5:9e:63:26:1e:55:92:94:d8:82:17:5a:7b:d0:bc:c7:
8f:4e:86:04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BALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do
lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc
AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k
-----END CERTIFICATE-----

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

@ -1,90 +0,0 @@
This CA certificate is for verifying HTTPS connection to;
- https://d2chzxaqi4y7f8.cloudfront.net/ (prepared by AWS)
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 927650371 (0x374ad243)
Signature Algorithm: sha1WithRSAEncryption
Issuer: C=US, O=Entrust.net, OU=www.entrust.net/CPS incorp. by ref. (limits liab.), OU=(c) 1999 Entrust.net Limited, CN=Entrust.net Secure Server Certification Authority
Validity
Not Before: May 25 16:09:40 1999 GMT
Not After : May 25 16:39:40 2019 GMT
Subject: C=US, O=Entrust.net, OU=www.entrust.net/CPS incorp. by ref. (limits liab.), OU=(c) 1999 Entrust.net Limited, CN=Entrust.net Secure Server Certification Authority
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (1024 bit)
Modulus:
00:cd:28:83:34:54:1b:89:f3:0f:af:37:91:31:ff:
af:31:60:c9:a8:e8:b2:10:68:ed:9f:e7:93:36:f1:
0a:64:bb:47:f5:04:17:3f:23:47:4d:c5:27:19:81:
26:0c:54:72:0d:88:2d:d9:1f:9a:12:9f:bc:b3:71:
d3:80:19:3f:47:66:7b:8c:35:28:d2:b9:0a:df:24:
da:9c:d6:50:79:81:7a:5a:d3:37:f7:c2:4a:d8:29:
92:26:64:d1:e4:98:6c:3a:00:8a:f5:34:9b:65:f8:
ed:e3:10:ff:fd:b8:49:58:dc:a0:de:82:39:6b:81:
b1:16:19:61:b9:54:b6:e6:43
Exponent: 3 (0x3)
X509v3 extensions:
Netscape Cert Type:
SSL CA, S/MIME CA, Object Signing CA
X509v3 CRL Distribution Points:
Full Name:
DirName: C = US, O = Entrust.net, OU = www.entrust.net/CPS incorp. by ref. (limits liab.), OU = (c) 1999 Entrust.net Limited, CN = Entrust.net Secure Server Certification Authority, CN = CRL1
Full Name:
URI:http://www.entrust.net/CRL/net1.crl
X509v3 Private Key Usage Period:
Not Before: May 25 16:09:40 1999 GMT, Not After: May 25 16:09:40 2019 GMT
X509v3 Key Usage:
Certificate Sign, CRL Sign
X509v3 Authority Key Identifier:
keyid:F0:17:62:13:55:3D:B3:FF:0A:00:6B:FB:50:84:97:F3:ED:62:D0:1A
X509v3 Subject Key Identifier:
F0:17:62:13:55:3D:B3:FF:0A:00:6B:FB:50:84:97:F3:ED:62:D0:1A
X509v3 Basic Constraints:
CA:TRUE
1.2.840.113533.7.65.0:
0
..V4.0....
Signature Algorithm: sha1WithRSAEncryption
90:dc:30:02:fa:64:74:c2:a7:0a:a5:7c:21:8d:34:17:a8:fb:
47:0e:ff:25:7c:8d:13:0a:fb:e4:98:b5:ef:8c:f8:c5:10:0d:
f7:92:be:f1:c3:d5:d5:95:6a:04:bb:2c:ce:26:36:65:c8:31:
c6:e7:ee:3f:e3:57:75:84:7a:11:ef:46:4f:18:f4:d3:98:bb:
a8:87:32:ba:72:f6:3c:e2:3d:9f:d7:1d:d9:c3:60:43:8c:58:
0e:22:96:2f:62:a3:2c:1f:ba:ad:05:ef:ab:32:78:87:a0:54:
73:19:b5:5c:05:f9:52:3e:6d:2d:45:0b:f7:0a:93:ea:ed:06:
f9:b2
-----BEGIN CERTIFICATE-----
MIIE2DCCBEGgAwIBAgIEN0rSQzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC
VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u
ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc
KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u
ZXQgU2VjdXJlIFN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-1,57 +0,0 @@
This CA certificate is for verifying HTTPS connection to;
- https://s3.amazon.com/ (prepared by AWS)
Certificate:
Data:
Version: 1 (0x0)
Serial Number:
7d:d9:fe:07:cf:a8:1e:b7:10:79:67:fb:a7:89:34:c6
Signature Algorithm: sha1WithRSAEncryption
Issuer: C=US, O=VeriSign, Inc., OU=Class 3 Public Primary Certification Authority - G2, OU=(c) 1998 VeriSign, Inc. - For authorized use only, OU=VeriSign Trust Network
Validity
Not Before: May 18 00:00:00 1998 GMT
Not After : Aug 1 23:59:59 2028 GMT
Subject: C=US, O=VeriSign, Inc., OU=Class 3 Public Primary Certification Authority - G2, OU=(c) 1998 VeriSign, Inc. - For authorized use only, OU=VeriSign Trust Network
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (1024 bit)
Modulus:
00:cc:5e:d1:11:5d:5c:69:d0:ab:d3:b9:6a:4c:99:
1f:59:98:30:8e:16:85:20:46:6d:47:3f:d4:85:20:
84:e1:6d:b3:f8:a4:ed:0c:f1:17:0f:3b:f9:a7:f9:
25:d7:c1:cf:84:63:f2:7c:63:cf:a2:47:f2:c6:5b:
33:8e:64:40:04:68:c1:80:b9:64:1c:45:77:c7:d8:
6e:f5:95:29:3c:50:e8:34:d7:78:1f:a8:ba:6d:43:
91:95:8f:45:57:5e:7e:c5:fb:ca:a4:04:eb:ea:97:
37:54:30:6f:bb:01:47:32:33:cd:dc:57:9b:64:69:
61:f8:9b:1d:1c:89:4f:5c:67
Exponent: 65537 (0x10001)
Signature Algorithm: sha1WithRSAEncryption
51:4d:cd:be:5c:cb:98:19:9c:15:b2:01:39:78:2e:4d:0f:67:
70:70:99:c6:10:5a:94:a4:53:4d:54:6d:2b:af:0d:5d:40:8b:
64:d3:d7:ee:de:56:61:92:5f:a6:c4:1d:10:61:36:d3:2c:27:
3c:e8:29:09:b9:11:64:74:cc:b5:73:9f:1c:48:a9:bc:61:01:
ee:e2:17:a6:0c:e3:40:08:3b:0e:e7:eb:44:73:2a:9a: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TT1+7eVmGSX6bEHRBhNtMsJzzoKQm5EWR0zLVznxxIqbxhAe7i
F6YM40AIOw7n60RzKprxaZLvcRTDOaxxp5EJb+RxBrO6WVcmeQD2+A2iMzAo1KpY
oJ2daZH9
-----END CERTIFICATE-----

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -41,6 +41,7 @@ class Gem::StubSpecification < Gem::BasicSpecification
def initialize(filename)
self.loaded_from = filename
@data = nil
@extensions = nil
@spec = nil
end
@ -52,17 +53,31 @@ class Gem::StubSpecification < Gem::BasicSpecification
loaded && loaded.version == version
end
def build_extensions # :nodoc:
return if default_gem?
return if extensions.empty?
to_spec.build_extensions
end
##
# If the gemspec contains a stubline, returns a StubLine instance. Otherwise
# returns the full Gem::Specification.
def data
unless @data
@extensions = []
open loaded_from, OPEN_MODE do |file|
begin
file.readline # discard encoding line
stubline = file.readline.chomp
@data = StubLine.new(stubline) if stubline.start_with?(PREFIX)
if stubline.start_with?(PREFIX) then
@data = StubLine.new stubline
@extensions = $'.split "\0" if
/\A#{PREFIX}/ =~ file.readline.chomp
end
rescue EOFError
end
end
@ -73,6 +88,38 @@ class Gem::StubSpecification < Gem::BasicSpecification
private :data
##
# Extensions for this gem
def extensions
return @extensions if @extensions
data # load
@extensions
end
##
# If a gem has a stub specification it doesn't need to bother with
# compatibility with original_name gems. It was installed with the
# normalized name.
def find_full_gem_path # :nodoc:
path = File.expand_path File.join gems_dir, full_name
path.untaint
path
end
##
# Full paths in the gem to add to <code>$LOAD_PATH</code> when this gem is
# activated.
def full_require_paths
@require_paths ||= data.require_paths
super
end
##
# Name of the gem
@ -92,6 +139,8 @@ class Gem::StubSpecification < Gem::BasicSpecification
def require_paths
@require_paths ||= data.require_paths
super
end
##

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

@ -247,12 +247,9 @@ class Gem::Uninstaller
File.writable?(spec.base_dir)
FileUtils.rm_rf spec.full_gem_path
FileUtils.rm_rf spec.extension_install_dir
# TODO: should this be moved to spec?... I vote eww (also exists in docmgr)
old_platform_name = [spec.name,
spec.version,
spec.original_platform].join '-'
old_platform_name = spec.original_name
gemspec = spec.spec_file
unless File.exist? gemspec then

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

@ -1,3 +1,4 @@
require 'cgi'
require 'uri'
class Gem::UriFormatter
@ -9,7 +10,7 @@ class Gem::UriFormatter
def escape
return unless @uri
escaper.escape @uri
CGI.escape @uri
end
##
@ -21,18 +22,7 @@ class Gem::UriFormatter
def unescape
return unless @uri
escaper.unescape @uri
end
private
def escaper
@uri_parser ||=
begin
URI::Parser.new
rescue NameError
URI
end
CGI.unescape @uri
end
end

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

@ -177,7 +177,7 @@ class Gem::Version
# REFACTOR: There's no real reason this should be separate from #initialize.
def self.create input
if input.respond_to? :version then
if self === input then # check yourself before you wreck yourself
input
elsif input.nil? then
nil

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

@ -0,0 +1,60 @@
require 'rubygems/test_case'
require 'net/https'
require 'rubygems/request'
# = Testing Bundled CA
#
# The tested hosts are explained in detail here: https://github.com/rubygems/rubygems/commit/5e16a5428f973667cabfa07e94ff939e7a83ebd9
#
class TestBundledCA < Gem::TestCase
THIS_FILE = File.expand_path __FILE__
def bundled_certificate_store
store = OpenSSL::X509::Store.new
ssl_cert_glob =
File.expand_path '../../../lib/rubygems/ssl_certs/*.pem', THIS_FILE
Dir[ssl_cert_glob].each do |ssl_cert|
store.add_file ssl_cert
end
store
end
def assert_https(host)
if self.respond_to? :_assertions # minitest <= 4
self._assertions += 1
else # minitest >= 5
self.assertions += 1
end
http = Net::HTTP.new(host, 443)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.cert_store = bundled_certificate_store
http.get('/')
rescue Errno::ENOENT
skip "#{host} seems offline, I can't tell whether ssl would work."
rescue OpenSSL::SSL::SSLError => e
# Only fail for certificate verification errors
if e.message =~ /certificate verify failed/
flunk "#{host} is not verifiable using the included certificates. Error was: #{e.message}"
end
raise
end
def test_accessing_rubygems
assert_https('rubygems.org')
end
def test_accessing_cloudfront
assert_https('d2chzxaqi4y7f8.cloudfront.net')
end
def test_accessing_s3
assert_https('s3.amazonaws.com')
end
end if ENV['TRAVIS']

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

@ -257,7 +257,12 @@ class TestGem < Gem::TestCase
Gem.ensure_gem_subdirectories @gemhome
assert File.directory? File.join(@gemhome, "cache")
assert_path_exists File.join @gemhome, 'build_info'
assert_path_exists File.join @gemhome, 'cache'
assert_path_exists File.join @gemhome, 'doc'
assert_path_exists File.join @gemhome, 'extensions'
assert_path_exists File.join @gemhome, 'gems'
assert_path_exists File.join @gemhome, 'specifications'
end
def test_self_ensure_gem_directories_permissions
@ -639,6 +644,22 @@ class TestGem < Gem::TestCase
Gem::ConfigMap[:EXEEXT] = orig_exe_ext
end
def test_self_ruby_api_version
orig_MAJOR, Gem::ConfigMap[:MAJOR] = Gem::ConfigMap[:MAJOR], '1'
orig_MINOR, Gem::ConfigMap[:MINOR] = Gem::ConfigMap[:MINOR], '2'
orig_TEENY, Gem::ConfigMap[:TEENY] = Gem::ConfigMap[:TEENY], '3'
Gem.instance_variable_set :@ruby_api_version, nil
assert_equal '1.2.3', Gem.ruby_api_version
ensure
Gem.instance_variable_set :@ruby_api_version, nil
Gem::ConfigMap[:MAJOR] = orig_MAJOR
Gem::ConfigMap[:MINOR] = orig_MINOR
Gem::ConfigMap[:TEENY] = orig_TEENY
end
def test_self_ruby_version_1_8_5
util_set_RUBY_VERSION '1.8.5'

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

@ -79,7 +79,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase
assert_equal [], output
if check_licenses
assert_equal "WARNING: licenses is empty\n", @ui.error
assert_match "WARNING: licenses is empty", @ui.error
end
gem_file = File.join @tempdir, File.basename(gem.cache_file)

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

@ -117,8 +117,9 @@ class TestGemCommandsPristineCommand < Gem::TestCase
write_file ext_path do |io|
io.write <<-'RUBY'
File.open "Makefile", "w" do |f|
f.puts "clean:\n\techo cleaned\n"
f.puts "all:\n\techo built\n"
f.puts "install:\n\techo built\n"
f.puts "install:\n\techo installed\n"
end
RUBY
end
@ -177,8 +178,9 @@ class TestGemCommandsPristineCommand < Gem::TestCase
write_file ext_path do |io|
io.write <<-'RUBY'
File.open "Makefile", "w" do |f|
f.puts "clean:\n\techo cleaned\n"
f.puts "all:\n\techo built\n"
f.puts "install:\n\techo built\n"
f.puts "install:\n\techo installed\n"
end
RUBY
end

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

@ -577,5 +577,18 @@ pl \(1\)
assert_equal '', @ui.error
end
def test_show_gems
@cmd.options[:name] = //
@cmd.options[:domain] = :remote
use_ui @ui do
@cmd.send :show_gems, /a/i, false
end
assert_match %r%^a %, @ui.output
refute_match %r%^pl %, @ui.output
assert_empty @ui.error
end
end

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

@ -198,6 +198,23 @@ beta-gems.example.com is not a URI
refute File.exist?(dir), 'cache dir removed'
end
def test_execute_list
@cmd.handle_options %w[--list]
use_ui @ui do
@cmd.execute
end
expected = <<-EOF
*** CURRENT SOURCES ***
#{@gem_repo}
EOF
assert_equal expected, @ui.output
assert_equal '', @ui.error
end
def test_execute_remove
@cmd.handle_options %W[--remove #{@gem_repo}]

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

@ -373,6 +373,36 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
assert user_install, 'user_install must be set on the installer'
end
def test_fetch_remote_gems
expected = [
[Gem::NameTuple.new('a', v(2), Gem::Platform::RUBY),
Gem::Source.new(@gem_repo)],
]
assert_equal expected, @cmd.fetch_remote_gems(@a1)
end
def test_fetch_remote_gems_error
Gem.sources.replace %w[http://nonexistent.example]
assert_raises Gem::RemoteFetcher::FetchError do
@cmd.fetch_remote_gems @a1
end
end
def test_fetch_remote_gems_prerelease
@cmd.options[:prerelease] = true
expected = [
[Gem::NameTuple.new('a', v(2), Gem::Platform::RUBY),
Gem::Source.new(@gem_repo)],
[Gem::NameTuple.new('a', v('3.a'), Gem::Platform::RUBY),
Gem::Source.new(@gem_repo)],
]
assert_equal expected, @cmd.fetch_remote_gems(@a1)
end
def test_handle_options_system
@cmd.handle_options %w[--system]

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

@ -388,6 +388,41 @@ class TestGemDependencyInstaller < Gem::TestCase
assert_equal %w[b-1], inst.installed_gems.map { |s| s.full_name }
end
def test_install_dependency_existing_extension
extconf_rb = File.join @gemhome, 'gems', 'e-1', 'extconf.rb'
FileUtils.mkdir_p File.dirname extconf_rb
open extconf_rb, 'w' do |io|
io.write <<-EXTCONF_RB
require 'mkmf'
create_makefile 'e'
EXTCONF_RB
end
e1 = new_spec 'e', '1', nil, 'extconf.rb' do |s|
s.extensions << 'extconf.rb'
end
e1_gem = File.join @tempdir, 'gems', "#{e1.full_name}.gem"
_, f1_gem = util_gem 'f', '1', 'e' => nil
Gem::Installer.new(e1_gem).install
FileUtils.rm_r e1.extension_install_dir
FileUtils.mv e1_gem, @tempdir
FileUtils.mv f1_gem, @tempdir
inst = nil
Dir.chdir @tempdir do
inst = Gem::DependencyInstaller.new
inst.install 'f'
end
assert_equal %w[f-1], inst.installed_gems.map { |s| s.full_name }
assert_path_exists e1.extension_install_dir
end
def test_install_dependency_old
_, e1_gem = util_gem 'e', '1'
_, f1_gem = util_gem 'f', '1', 'e' => nil

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

@ -1,5 +1,6 @@
require 'rubygems/test_case'
require 'rubygems/dependency_resolver'
require 'rubygems/available_set'
class TestGemDependencyResolverIndexSpecification < Gem::TestCase
@ -18,6 +19,17 @@ class TestGemDependencyResolverIndexSpecification < Gem::TestCase
assert_equal source, spec.source
end
def test_initialize_platform
set = Gem::DependencyResolver::IndexSet.new
source = Gem::Source::Local.new
version = Gem::Version.new '3.0.3'
spec = Gem::DependencyResolver::IndexSpecification.new(
set, 'rails', version, source, Gem::Platform.local)
assert_equal Gem::Platform.local.to_s, spec.platform
end
def test_spec
@fetcher = Gem::FakeFetcher.new
Gem::RemoteFetcher.fetcher = @fetcher
@ -41,6 +53,21 @@ class TestGemDependencyResolverIndexSpecification < Gem::TestCase
assert_equal a_2_p.full_name, spec.full_name
end
def test_spec_local
a_2_p = quick_spec 'a', 2 do |s| s.platform = Gem::Platform.local end
Gem::Package.build a_2_p
source = Gem::Source::Local.new
set = Gem::DependencyResolver::InstallerSet.new :local
set.always_install << a_2_p
i_spec = Gem::DependencyResolver::IndexSpecification.new \
set, 'a', v(2), source, Gem::Platform.local
spec = i_spec.spec
assert_equal a_2_p.full_name, spec.full_name
end
end

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

@ -36,6 +36,9 @@ class TestGemExtBuilder < Gem::TestCase
all:
\t@#{Gem.ruby} -e "puts %Q{all: \#{ENV['DESTDIR']}}"
clean:
\t@#{Gem.ruby} -e "puts %Q{clean: \#{ENV['DESTDIR']}}"
install:
\t@#{Gem.ruby} -e "puts %Q{install: \#{ENV['DESTDIR']}}"
MAKEFILE
@ -46,21 +49,49 @@ install:
results = results.join "\n"
if RUBY_VERSION > '2.0' then
assert_match %r%"DESTDIR=#{ENV['DESTDIR']}" clean$%, results
assert_match %r%"DESTDIR=#{ENV['DESTDIR']}"$%, results
assert_match %r%"DESTDIR=#{ENV['DESTDIR']}" install$%, results
else
refute_match %r%"DESTDIR=#{ENV['DESTDIR']}" clean$%, results
refute_match %r%"DESTDIR=#{ENV['DESTDIR']}"$%, results
refute_match %r%"DESTDIR=#{ENV['DESTDIR']}" install$%, results
end
if /nmake/ !~ results
assert_match %r%^clean: destination$%, results
assert_match %r%^all: destination$%, results
assert_match %r%^install: destination$%, results
end
end
def test_build_extensions
@spec.extensions << 'extconf.rb'
FileUtils.mkdir_p @spec.gem_dir
extconf_rb = File.join @spec.gem_dir, 'extconf.rb'
open extconf_rb, 'w' do |f|
f.write <<-'RUBY'
open 'Makefile', 'w' do |f|
f.puts "clean:\n\techo cleaned"
f.puts "default:\n\techo built"
f.puts "install:\n\techo installed"
end
RUBY
end
use_ui @ui do
@builder.build_extensions
end
assert_path_exists @spec.extension_install_dir
assert_path_exists @spec.gem_build_complete_path
assert_path_exists File.join @spec.extension_install_dir, 'gem_make.out'
end
def test_build_extensions_none
use_ui @ui do
@builder.build_extensions
@ -69,13 +100,30 @@ install:
assert_equal '', @ui.output
assert_equal '', @ui.error
refute File.exist?('gem_make.out')
refute_path_exists File.join @spec.extension_install_dir, 'gem_make.out'
end
def test_build_extensions_rebuild_failure
FileUtils.mkdir_p @spec.extension_install_dir
FileUtils.touch @spec.gem_build_complete_path
@spec.extensions << nil
assert_raises Gem::Ext::BuildError do
use_ui @ui do
@builder.build_extensions
end
end
refute_path_exists @spec.gem_build_complete_path
end
def test_build_extensions_extconf_bad
@spec.extensions << 'extconf.rb'
e = assert_raises Gem::Installer::ExtensionBuildError do
FileUtils.mkdir_p @spec.gem_dir
e = assert_raises Gem::Ext::BuildError do
use_ui @ui do
@builder.build_extensions
end
@ -87,20 +135,22 @@ install:
@ui.output
assert_equal '', @ui.error
gem_make_out = File.join @gemhome, 'gems', @spec.full_name, 'gem_make.out'
gem_make_out = File.join @spec.extension_install_dir, 'gem_make.out'
assert_match %r%#{Regexp.escape Gem.ruby} extconf\.rb%,
File.read(gem_make_out)
assert_match %r%#{Regexp.escape Gem.ruby}: No such file%,
File.read(gem_make_out)
refute_path_exists @spec.gem_build_complete_path
end
def test_build_extensions_unsupported
FileUtils.mkdir_p @spec.gem_dir
gem_make_out = File.join @spec.gem_dir, 'gem_make.out'
gem_make_out = File.join @spec.extension_install_dir, 'gem_make.out'
@spec.extensions << nil
e = assert_raises Gem::Installer::ExtensionBuildError do
e = assert_raises Gem::Ext::BuildError do
use_ui @ui do
@builder.build_extensions
end
@ -113,6 +163,8 @@ install:
assert_equal '', @ui.error
assert_equal "No builder for extension ''\n", File.read(gem_make_out)
refute_path_exists @spec.gem_build_complete_path
ensure
FileUtils.rm_f gem_make_out
end
@ -133,6 +185,7 @@ install:
end
File.open 'Makefile', 'w' do |f|
f.puts "clean:\n\techo cleaned"
f.puts "default:\n\techo built"
f.puts "install:\n\techo installed"
end
@ -146,7 +199,29 @@ install:
path = File.join @spec.gem_dir, "extconf_args"
assert_equal args.inspect, File.read(path).strip
assert File.directory? File.join(@spec.gem_dir, 'lib')
assert_path_exists @spec.extension_install_dir
end
def test_initialize
build_info_dir = File.join @gemhome, 'build_info'
FileUtils.mkdir_p build_info_dir
build_info_file = File.join build_info_dir, "#{@spec.full_name}.info"
open build_info_file, 'w' do |io|
io.puts '--with-foo-dir=/nonexistent'
end
builder = Gem::Ext::Builder.new @spec
assert_equal %w[--with-foo-dir=/nonexistent], builder.build_args
end
def test_initialize_build_args
builder = Gem::Ext::Builder.new @spec, %w[--with-foo-dir=/nonexistent]
assert_equal %w[--with-foo-dir=/nonexistent], builder.build_args
end
end

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

@ -57,13 +57,7 @@ install (FILES test.txt DESTINATION bin)
shell_error_msg = %r{(CMake Error: .*)}
sh_prefix_cmake = "cmake . -DCMAKE_INSTALL_PREFIX="
expected = %r(cmake failed:
#{Regexp.escape sh_prefix_cmake}#{Regexp.escape @dest_path}
#{shell_error_msg}
)
assert_match expected, error.message
assert_match 'cmake failed', error.message
assert_match %r%^#{sh_prefix_cmake}#{Regexp.escape @dest_path}%, output
assert_match %r%#{shell_error_msg}%, output
@ -71,7 +65,7 @@ install (FILES test.txt DESTINATION bin)
def test_self_build_has_makefile
File.open File.join(@ext, 'Makefile'), 'w' do |makefile|
makefile.puts "all:\n\t@echo ok\ninstall:\n\t@echo ok"
makefile.puts "clean:\n\t@echo ok\nall:\n\t@echo ok\ninstall:\n\t@echo ok"
end
output = []

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

@ -6,7 +6,8 @@ class TestGemExtConfigureBuilder < Gem::TestCase
def setup
super
@makefile_body = "all:\n\t@echo ok\ninstall:\n\t@echo ok"
@makefile_body =
"clean:\n\t@echo ok\nall:\n\t@echo ok\ninstall:\n\t@echo ok"
@ext = File.join @tempdir, 'ext'
@dest_path = File.join @tempdir, 'prefix'
@ -30,6 +31,8 @@ class TestGemExtConfigureBuilder < Gem::TestCase
assert_equal "sh ./configure --prefix=#{@dest_path}", output.shift
assert_equal "", output.shift
assert_contains_make_command 'clean', output.shift
assert_match(/^ok$/m, output.shift)
assert_contains_make_command '', output.shift
assert_match(/^ok$/m, output.shift)
assert_contains_make_command 'install', output.shift
@ -49,13 +52,7 @@ class TestGemExtConfigureBuilder < Gem::TestCase
shell_error_msg = %r{(\./configure: .*)|((?:Can't|cannot) open \./configure(?:: No such file or directory)?)}
sh_prefix_configure = "sh ./configure --prefix="
expected = %r(configure failed:
#{Regexp.escape sh_prefix_configure}#{Regexp.escape @dest_path}
(?:.*?: )?#{shell_error_msg}
)
assert_match expected, error.message
assert_match 'configure failed', error.message
assert_equal "#{sh_prefix_configure}#{@dest_path}", output.shift
assert_match %r(#{shell_error_msg}), output.shift
@ -76,8 +73,9 @@ class TestGemExtConfigureBuilder < Gem::TestCase
Gem::Ext::ConfigureBuilder.build nil, nil, @dest_path, output
end
assert_contains_make_command '', output[0]
assert_contains_make_command 'install', output[2]
assert_contains_make_command 'clean', output[0]
assert_contains_make_command '', output[2]
assert_contains_make_command 'install', output[4]
end
end

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

@ -35,8 +35,9 @@ class TestGemExtExtConfBuilder < Gem::TestCase
assert_match(/^#{Gem.ruby} extconf.rb/, output[0])
assert_equal "creating Makefile\n", output[1]
assert_contains_make_command '', output[2]
assert_contains_make_command 'install', output[4]
assert_contains_make_command 'clean', output[2]
assert_contains_make_command '', output[4]
assert_contains_make_command 'install', output[6]
assert_empty Dir.glob(File.join(@ext, 'siteconf*.rb'))
end
@ -54,8 +55,9 @@ class TestGemExtExtConfBuilder < Gem::TestCase
end
assert_equal "creating Makefile\n", output[1]
assert_contains_make_command '', output[2]
assert_contains_make_command 'install', output[4]
assert_contains_make_command 'clean', output[2]
assert_contains_make_command '', output[4]
assert_contains_make_command 'install', output[6]
ensure
RbConfig::CONFIG['configure_args'] = configure_args
end
@ -78,7 +80,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase
end
assert_equal "creating Makefile\n", output[1]
assert_contains_make_command '', output[2]
assert_contains_make_command 'clean', output[2]
ensure
RbConfig::CONFIG['configure_args'] = configure_args
ENV['make'] = env_make
@ -103,10 +105,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase
end
end
assert_match(/\Aextconf failed:
#{Gem.ruby} extconf.rb.*
checking for main\(\) in .*?nonexistent/m, error.message)
assert_equal 'extconf failed, exit code 1', error.message
assert_equal("#{Gem.ruby} extconf.rb", output[0])
end
@ -130,6 +129,7 @@ ruby =
open 'Makefile', 'w' do |io|
io.write <<-Makefile
clean: ruby
all: ruby
install: ruby
@ -147,8 +147,9 @@ end
Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
end
assert_contains_make_command '', output[2]
assert_contains_make_command 'install', output[4]
assert_contains_make_command 'clean', output[2]
assert_contains_make_command '', output[4]
assert_contains_make_command 'install', output[6]
assert_empty Dir.glob(File.join(@ext, 'siteconf*.rb'))
end
@ -163,6 +164,7 @@ end
makefile.puts "# π"
makefile.puts "RUBYARCHDIR = $(foo)$(target_prefix)"
makefile.puts "RUBYLIBDIR = $(bar)$(target_prefix)"
makefile.puts "clean:"
makefile.puts "all:"
makefile.puts "install:"
end
@ -171,8 +173,9 @@ end
Gem::Ext::ExtConfBuilder.make @ext, output
end
assert_contains_make_command '', output[0]
assert_contains_make_command 'install', output[2]
assert_contains_make_command 'clean', output[0]
assert_contains_make_command '', output[2]
assert_contains_make_command 'install', output[4]
end
def test_class_make_no_Makefile
@ -182,13 +185,7 @@ end
end
end
expected = <<-EOF.strip
Makefile not found:
output
EOF
assert_equal expected, error.message
assert_equal 'Makefile not found', error.message
end
end

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

@ -56,9 +56,7 @@ class TestGemExtRakeBuilder < Gem::TestCase
end
end
assert_match %r%^rake failed:%, error.message
assert_match %r%^#{Regexp.escape @@ruby} mkrf_conf\.rb%, error.message
assert_match %r%^#{Regexp.escape rake} RUBYARCHDIR=#{Regexp.escape @dest_path} RUBYLIBDIR=#{Regexp.escape @dest_path}%, error.message
assert_match %r%^rake failed%, error.message
end
end

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

@ -24,6 +24,9 @@ class TestGemIndexer < Gem::TestCase
@d2_0_b = quick_spec 'd', '2.0.b'
util_build_gem @d2_0_b
@default = new_default_spec 'default', 2
install_default_gems @default
@tempdir = File.join(@tempdir, 'indexer')
gems = File.join(@tempdir, 'gems')

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

@ -427,6 +427,19 @@ class TestGemPackage < Gem::Package::TarTestCase
assert_path_exists extracted
end
def test_extract_tar_gz_dot_file
package = Gem::Package.new @gem
tgz_io = util_tar_gz do |tar|
tar.add_file '.dot_file.rb', 0644 do |io| io.write 'hi' end
end
package.extract_tar_gz tgz_io, @destination
extracted = File.join @destination, '.dot_file.rb'
assert_path_exists extracted
end
def test_install_location
package = Gem::Package.new @gem
@ -450,6 +463,22 @@ class TestGemPackage < Gem::Package::TarTestCase
"#{@destination} is not allowed", e.message)
end
def test_install_location_dots
package = Gem::Package.new @gem
file = 'file.rb'
destination = File.join @destination, 'foo', '..', 'bar'
FileUtils.mkdir_p File.join @destination, 'foo'
FileUtils.mkdir_p File.expand_path destination
destination = package.install_location file, destination
# this test only fails on ruby missing File.realpath
assert_equal File.join(@destination, 'bar', 'file.rb'), destination
end
def test_install_location_extra_slash
skip 'no File.realpath on 1.8' if RUBY_VERSION < '1.9'
package = Gem::Package.new @gem

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

@ -89,6 +89,17 @@ class TestGemRequest < Gem::TestCase
assert_equal 'my bar', Gem::UriFormatter.new(proxy.password).unescape
end
def test_get_proxy_from_env_escape
ENV['http_proxy'] = @proxy_uri
ENV['http_proxy_user'] = 'foo@user'
ENV['http_proxy_pass'] = 'my@bar'
proxy = @request.get_proxy_from_env
assert_equal 'foo%40user', proxy.user
assert_equal 'my%40bar', proxy.password
end
def test_get_proxy_from_env_normalize
ENV['HTTP_PROXY'] = 'fakeurl:12345'
@ -126,7 +137,7 @@ class TestGemRequest < Gem::TestCase
def test_fetch_unmodified
uri = URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}"
t = Time.now
t = Time.utc(2013, 1, 2, 3, 4, 5)
@request = Gem::Request.new(uri, Net::HTTP::Get, t, nil)
conn = util_stub_connection_for :body => '', :code => 304
@ -135,7 +146,9 @@ class TestGemRequest < Gem::TestCase
assert_equal 304, response.code
assert_equal '', response.body
assert_equal t.rfc2822, conn.payload['if-modified-since']
modified_header = conn.payload['if-modified-since']
assert_equal 'Wed, 02 Jan 2013 03:04:05 GMT', modified_header
end
def test_user_agent

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

@ -0,0 +1,19 @@
require 'rubygems/test_case'
class TestGemSourceFetchProblem < Gem::TestCase
def test_exception
source = Gem::Source.new @gem_repo
error = RuntimeError.new 'test'
sf = Gem::SourceFetchProblem.new source, error
e = assert_raises RuntimeError do
raise sf
end
assert_equal 'test', e.message
end
end

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

@ -1,6 +1,8 @@
# -*- coding: us-ascii -*-
# -*- coding: UTF-8 -*-
require 'rubygems/test_case'
require 'pathname'
require 'stringio'
require 'rubygems/ext'
require 'rubygems/specification'
class TestGemSpecification < Gem::TestCase
@ -56,12 +58,23 @@ end
end
end
def ext_spec
@ext = quick_spec 'ext', '1' do |s|
s.executable = 'exec'
s.test_file = 'test/suite.rb'
s.extensions = %w[ext/extconf.rb]
s.license = 'MIT'
s.mark_version
s.files = %w[lib/code.rb]
end
end
def setup
super
@a1 = quick_spec 'a', '1' do |s|
s.executable = 'exec'
s.extensions << 'ext/a/extconf.rb'
s.test_file = 'test/suite.rb'
s.requirements << 'A working computer'
s.rubyforge_project = 'example'
@ -1062,6 +1075,170 @@ dependencies: []
assert_equal %w[lib/code.rb app].sort, @a2.files
end
def test_build_extensions
ext_spec
refute_path_exists @ext.extension_install_dir, 'sanity check'
refute_empty @ext.extensions, 'sanity check'
extconf_rb = File.join @ext.gem_dir, @ext.extensions.first
FileUtils.mkdir_p File.dirname extconf_rb
open extconf_rb, 'w' do |f|
f.write <<-'RUBY'
open 'Makefile', 'w' do |f|
f.puts "clean:\n\techo clean"
f.puts "default:\n\techo built"
f.puts "install:\n\techo installed"
end
RUBY
end
@ext.build_extensions
assert_path_exists @ext.extension_install_dir
end
def test_build_extensions_built
ext_spec
refute_empty @ext.extensions, 'sanity check'
gem_build_complete =
File.join @ext.extension_install_dir, 'gem.build_complete'
FileUtils.mkdir_p @ext.extension_install_dir
FileUtils.touch gem_build_complete
@ext.build_extensions
gem_make_out = File.join @ext.extension_install_dir, 'gem_make.out'
refute_path_exists gem_make_out
end
def test_build_extensions_default_gem
spec = new_default_spec 'default', 1
spec.extensions << 'extconf.rb'
extconf_rb = File.join spec.gem_dir, spec.extensions.first
FileUtils.mkdir_p File.dirname extconf_rb
open extconf_rb, 'w' do |f|
f.write <<-'RUBY'
open 'Makefile', 'w' do |f|
f.puts "default:\n\techo built"
f.puts "install:\n\techo installed"
end
RUBY
end
spec.build_extensions
refute_path_exists spec.extension_install_dir
end
def test_build_extensions_error
ext_spec
refute_empty @ext.extensions, 'sanity check'
assert_raises Gem::Ext::BuildError do
@ext.build_extensions
end
end
def test_build_extensions_extensions_dir_unwritable
skip 'chmod not supported' if Gem.win_platform?
ext_spec
refute_empty @ext.extensions, 'sanity check'
extconf_rb = File.join @ext.gem_dir, @ext.extensions.first
FileUtils.mkdir_p File.dirname extconf_rb
open extconf_rb, 'w' do |f|
f.write <<-'RUBY'
open 'Makefile', 'w' do |f|
f.puts "clean:\n\techo clean"
f.puts "default:\n\techo built"
f.puts "install:\n\techo installed"
end
RUBY
end
FileUtils.mkdir_p File.join @ext.base_dir, 'extensions'
FileUtils.chmod 0555, @ext.base_dir
FileUtils.chmod 0555, File.join(@ext.base_dir, 'extensions')
assert_raises Errno::EACCES do
@ext.build_extensions
end
ensure
FileUtils.chmod 0755, File.join(@ext.base_dir, 'extensions')
FileUtils.chmod 0755, @ext.base_dir
end
def test_build_extensions_no_extensions_dir_unwritable
skip 'chmod not supported' if Gem.win_platform?
ext_spec
refute_empty @ext.extensions, 'sanity check'
extconf_rb = File.join @ext.gem_dir, @ext.extensions.first
FileUtils.mkdir_p File.dirname extconf_rb
open extconf_rb, 'w' do |f|
f.write <<-'RUBY'
open 'Makefile', 'w' do |f|
f.puts "clean:\n\techo clean"
f.puts "default:\n\techo built"
f.puts "install:\n\techo installed"
end
RUBY
end
FileUtils.rm_r File.join @gemhome, 'extensions'
FileUtils.chmod 0555, @gemhome
@ext.build_extensions
gem_make_out = File.join @ext.extension_install_dir, 'gem_make.out'
refute_path_exists gem_make_out
ensure
FileUtils.chmod 0755, @gemhome
end
def test_contains_requirable_file_eh
code_rb = File.join @a1.gem_dir, 'lib', 'code.rb'
FileUtils.mkdir_p File.dirname code_rb
FileUtils.touch code_rb
assert @a1.contains_requirable_file? 'code'
end
def test_contains_requirable_file_eh_extension
ext_spec
extconf_rb = File.join @ext.gem_dir, @ext.extensions.first
FileUtils.mkdir_p File.dirname extconf_rb
open extconf_rb, 'w' do |f|
f.write <<-'RUBY'
open 'Makefile', 'w' do |f|
f.puts "clean:\n\techo cleaned"
f.puts "default:\n\techo built"
f.puts "install:\n\techo installed"
end
RUBY
end
refute @ext.contains_requirable_file? 'nonexistent'
assert_path_exists @ext.extension_install_dir
end
def test_date
assert_equal Gem::Specification::TODAY, @a1.date
end
@ -1177,7 +1354,41 @@ dependencies: []
end
def test_extensions
assert_equal ['ext/a/extconf.rb'], @a1.extensions
assert_equal ['ext/extconf.rb'], ext_spec.extensions
end
def test_extension_install_dir_shared
enable_shared, RbConfig::CONFIG['ENABLE_SHARED'] =
RbConfig::CONFIG['ENABLE_SHARED'], 'yes'
ext_spec
refute_empty @ext.extensions
expected =
File.join(@ext.base_dir, 'extensions', Gem::Platform.local.to_s,
Gem.ruby_api_version,@ext.full_name)
assert_equal expected, @ext.extension_install_dir
ensure
RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared
end
def test_extension_install_dir_static
enable_shared, RbConfig::CONFIG['ENABLE_SHARED'] =
RbConfig::CONFIG['ENABLE_SHARED'], 'no'
ext_spec
refute_empty @ext.extensions
expected =
File.join(@ext.base_dir, 'extensions', Gem::Platform.local.to_s,
"#{Gem.ruby_api_version}-static", @ext.full_name)
assert_equal expected, @ext.extension_install_dir
ensure
RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared
end
def test_files
@ -1328,6 +1539,11 @@ dependencies: []
end
end
def test_gem_build_complete_path
expected = File.join @a1.extension_install_dir, 'gem.build_complete'
assert_equal expected, @a1.gem_build_complete_path
end
def test_hash
assert_equal @a1.hash, @a1.hash
assert_equal @a1.hash, @a1.dup.hash
@ -1442,14 +1658,29 @@ dependencies: []
end
def test_require_paths
@a1.require_path = 'lib'
assert_equal %w[lib], @a1.require_paths
ext_spec
@ext.require_path = 'lib'
lib = Pathname File.join @ext.gem_dir, 'lib'
ext_install_dir =
Pathname(@ext.extension_install_dir).relative_path_from lib
assert_equal ['lib', ext_install_dir.to_s], @ext.require_paths
end
def test_full_require_paths
@a1.require_path = 'lib'
assert_equal [File.join(@gemhome, 'gems', @a1.original_name, 'lib')],
@a1.full_require_paths
ext_spec
@ext.require_path = 'lib'
expected = [
File.join(@gemhome, 'gems', @ext.original_name, 'lib'),
@ext.extension_install_dir,
]
assert_equal expected, @ext.full_require_paths
end
def test_require_already_activated
@ -1577,13 +1808,13 @@ Gem::Specification.new do |s|
s.version = "2"
s.required_rubygems_version = Gem::Requirement.new(\"> 0\") if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib", "other"]
s.authors = ["A User"]
s.date = "#{Gem::Specification::TODAY.strftime "%Y-%m-%d"}"
s.description = "This is a test description"
s.email = "example@example.com"
s.files = ["lib/code.rb"]
s.homepage = "http://example.com"
s.require_paths = ["lib", "other"]
s.rubygems_version = "#{Gem::VERSION}"
s.summary = "this is a summary"
@ -1625,12 +1856,12 @@ Gem::Specification.new do |s|
s.version = "2"
s.required_rubygems_version = Gem::Requirement.new(\"> 0\") if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib"]
s.authors = ["A User"]
s.date = "#{Gem::Specification::TODAY.strftime "%Y-%m-%d"}"
s.description = "This is a test description"
s.email = "example@example.com"
s.homepage = "http://example.com"
s.require_paths = ["lib"]
s.rubygems_version = "#{Gem::VERSION}"
s.summary = "this is a summary"
@ -1665,10 +1896,14 @@ end
local = Gem::Platform.local
expected_platform = "[#{local.cpu.inspect}, #{local.os.inspect}, #{local.version.inspect}]"
stub_require_paths =
@c1.instance_variable_get(:@require_paths).join "\u0000"
extensions = @c1.extensions.join "\u0000"
expected = <<-SPEC
# -*- encoding: utf-8 -*-
# stub: a 1 #{win_platform? ? "x86-mswin32-60" : "x86-darwin-8"} lib
# stub: a 1 #{win_platform? ? "x86-mswin32-60" : "x86-darwin-8"} #{stub_require_paths}
# stub: #{extensions}
Gem::Specification.new do |s|
s.name = "a"
@ -1676,6 +1911,7 @@ Gem::Specification.new do |s|
s.platform = Gem::Platform.new(#{expected_platform})
s.required_rubygems_version = Gem::Requirement.new(\">= 0\") if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib"]
s.authors = ["A User"]
s.date = "#{Gem::Specification::TODAY.strftime "%Y-%m-%d"}"
s.description = "This is a test description"
@ -1685,7 +1921,6 @@ Gem::Specification.new do |s|
s.files = ["bin/exec", "ext/a/extconf.rb", "lib/code.rb", "test/suite.rb"]
s.homepage = "http://example.com"
s.licenses = ["MIT"]
s.require_paths = ["lib"]
s.requirements = ["A working computer"]
s.rubyforge_project = "example"
s.rubygems_version = "#{Gem::VERSION}"
@ -1819,7 +2054,7 @@ end
@a1.validate
end
assert_equal "#{w}: no author specified\n", @ui.error, 'error'
assert_match "#{w}: no author specified\n", @ui.error, 'error'
@a1.authors = [Object.new]
@ -1859,7 +2094,7 @@ end
@a1.validate
end
assert_equal "#{w}: deprecated autorequire specified\n",
assert_match "#{w}: deprecated autorequire specified\n",
@ui.error, 'error'
end
end
@ -1880,7 +2115,7 @@ end
#{w}: prerelease dependency on c (>= 2.0.rc2, development) is not recommended
EXPECTED
assert_equal expected, @ui.error, 'warning'
assert_match expected, @ui.error, 'warning'
end
end
@ -1894,7 +2129,7 @@ end
@a1.validate
end
assert_equal "#{w}: no description specified\n", @ui.error, "error"
assert_match "#{w}: no description specified\n", @ui.error, "error"
@ui = Gem::MockGemUi.new
@a1.summary = "this is my summary"
@ -1904,7 +2139,7 @@ end
@a1.validate
end
assert_equal "#{w}: description and summary are identical\n",
assert_match "#{w}: description and summary are identical\n",
@ui.error, "error"
@a1.description = "#{f} (describe your package)"
@ -1935,7 +2170,7 @@ end
@a1.validate
end
assert_equal "#{w}: no email specified\n", @ui.error, "error"
assert_match "#{w}: no email specified\n", @ui.error, "error"
@a1.email = "FIxxxXME (your e-mail)".sub(/xxx/, "")
@ -1963,6 +2198,16 @@ end
assert_equal 'missing value for attribute name', e.message
end
def test_validate_error
assert_raises Gem::InvalidSpecificationException do
use_ui @ui do
Gem::Specification.new.validate
end
end
assert_match 'See http://guides.rubygems.org/specification-reference/ for help', @ui.error
end
def test_validate_executables
util_setup_validate
@ -1979,7 +2224,7 @@ end
assert_equal %w[exec], @a1.executables
assert_equal '', @ui.output, 'output'
assert_equal "#{w}: bin/exec is missing #! line\n", @ui.error, 'error'
assert_match "#{w}: bin/exec is missing #! line\n", @ui.error, 'error'
end
def test_validate_empty_require_paths
@ -2003,6 +2248,7 @@ end
util_setup_validate
@a1.files += ['lib', 'lib2']
@a1.extensions << 'ext/a/extconf.rb'
Dir.chdir @tempdir do
FileUtils.ln_s '/root/path', 'lib2' unless vc_windows?
@ -2042,7 +2288,7 @@ end
@a1.validate
end
assert_equal "#{w}: no homepage specified\n", @ui.error, 'error'
assert_match "#{w}: no homepage specified\n", @ui.error, 'error'
@ui = Gem::MockGemUi.new
@ -2052,7 +2298,7 @@ end
@a1.validate
end
assert_equal "#{w}: no homepage specified\n", @ui.error, 'error'
assert_match "#{w}: no homepage specified\n", @ui.error, 'error'
@a1.homepage = 'over at my cool site'
@ -2064,6 +2310,20 @@ end
end
end
def test_validate_license
util_setup_validate
use_ui @ui do
@a1.licenses.clear
@a1.validate
end
assert_match <<-warning, @ui.error
WARNING: licenses is empty. Use a license abbreviation from:
http://opensource.org/licenses/alphabetical
warning
end
def test_validate_name
util_setup_validate
@ -2168,7 +2428,7 @@ end
@a1.validate
end
assert_equal "#{w}: no summary specified\n", @ui.error, 'error'
assert_match "#{w}: no summary specified\n", @ui.error, 'error'
@a1.summary = "#{f} (describe your package)"
@ -2188,6 +2448,17 @@ end
end
end
def test_validate_warning
util_setup_validate
use_ui @ui do
@a1.licenses.clear
@a1.validate
end
assert_match 'See http://guides.rubygems.org/specification-reference/ for help', @ui.error
end
def test_version
assert_equal Gem::Version.new('1'), @a1.version
end
@ -2390,13 +2661,13 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.metadata = { "one" => "two", "two" => "three" } if s.respond_to? :metadata=
s.require_paths = ["lib"]
s.authors = ["A User"]
s.date = "#{Gem::Specification::TODAY.strftime("%Y-%m-%d")}"
s.description = "This is a test description"
s.email = "example@example.com"
s.files = ["lib/code.rb"]
s.homepage = "http://example.com"
s.require_paths = ["lib"]
s.rubygems_version = "#{Gem::VERSION}"
s.summary = "this is a summary"
end

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

@ -6,15 +6,38 @@ class TestStubSpecification < Gem::TestCase
FOO = File.join SPECIFICATIONS, "foo-0.0.1.gemspec"
BAR = File.join SPECIFICATIONS, "bar-0.0.2.gemspec"
def test_basic
stub = Gem::StubSpecification.new(FOO)
assert_equal "foo", stub.name
assert_equal Gem::Version.new("0.0.1"), stub.version
assert_equal Gem::Platform.new("mswin32"), stub.platform
assert_equal ["lib", "lib/f oo/ext"], stub.require_paths
def setup
super
@foo = Gem::StubSpecification.new FOO
end
def test_missing_stubline
def test_initialize
assert_equal "foo", @foo.name
assert_equal Gem::Version.new("0.0.1"), @foo.version
assert_equal Gem::Platform.new("mswin32"), @foo.platform
assert_equal ["lib", "lib/f oo/ext"], @foo.require_paths
end
def test_initialize_extension
stub = stub_with_extension
gem_dir = File.join stub.gems_dir, stub.full_name
lib = Pathname File.join gem_dir, 'lib'
ext_install_dir =
Pathname(stub.extension_install_dir).relative_path_from lib
ext_install_dir = ext_install_dir.to_s
assert_equal 'stub_e', stub.name
assert_equal v(2), stub.version
assert_equal Gem::Platform::RUBY, stub.platform
assert_equal ['lib', ext_install_dir], stub.require_paths
assert_equal %w[ext/stub_e/extconf.rb], stub.extensions
end
def test_initialize_missing_stubline
stub = Gem::StubSpecification.new(BAR)
assert_equal "bar", stub.name
assert_equal Gem::Version.new("0.0.2"), stub.version
@ -22,9 +45,99 @@ class TestStubSpecification < Gem::TestCase
assert_equal ["lib"], stub.require_paths
end
def test_contains_requirable_file_eh
stub = stub_without_extension
code_rb = File.join stub.gem_dir, 'lib', 'code.rb'
FileUtils.mkdir_p File.dirname code_rb
FileUtils.touch code_rb
assert stub.contains_requirable_file? 'code'
end
def test_contains_requirable_file_eh_extension
stub_with_extension do |stub|
extconf_rb = File.join stub.gem_dir, stub.extensions.first
FileUtils.mkdir_p File.dirname extconf_rb
open extconf_rb, 'w' do |f|
f.write <<-'RUBY'
open 'Makefile', 'w' do |f|
f.puts "clean:\n\techo cleaned"
f.puts "default:\n\techo built"
f.puts "install:\n\techo installed"
end
RUBY
end
refute stub.contains_requirable_file? 'nonexistent'
assert_path_exists stub.extension_install_dir
end
end
def test_full_require_paths
stub = stub_with_extension
expected = [
File.join(stub.full_gem_path, 'lib'),
stub.extension_install_dir,
]
assert_equal expected, stub.full_require_paths
end
def test_to_spec
stub = Gem::StubSpecification.new(FOO)
assert stub.to_spec.is_a?(Gem::Specification)
assert_equal "foo", stub.to_spec.name
assert @foo.to_spec.is_a?(Gem::Specification)
assert_equal "foo", @foo.to_spec.name
end
def stub_with_extension
spec = File.join @gemhome, 'specifications', 'stub_e-2.gemspec'
open spec, 'w' do |io|
io.write <<-STUB
# -*- encoding: utf-8 -*-
# stub: stub_e 2 ruby lib
# stub: ext/stub_e/extconf.rb
Gem::Specification.new do |s|
s.name = 'stub_e'
s.version = Gem::Version.new '2'
s.extensions = ['ext/stub_e/extconf.rb']
end
STUB
io.flush
stub = Gem::StubSpecification.new io.path
yield stub if block_given?
return stub
end
end
def stub_without_extension
spec = File.join @gemhome, 'specifications', 'stub-2.gemspec'
open spec, 'w' do |io|
io.write <<-STUB
# -*- encoding: utf-8 -*-
# stub: stub 2 ruby lib
Gem::Specification.new do |s|
s.name = 'stub'
s.version = Gem::Version.new '2'
end
STUB
io.flush
stub = Gem::StubSpecification.new io.path
yield stub if block_given?
return stub
end
end
end

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

@ -205,6 +205,32 @@ class TestGemUninstaller < Gem::InstallerTestCase
refute_path_exists spec.gem_dir
end
def test_uninstall_extension
@spec.extensions << 'extconf.rb'
write_file File.join(@tempdir, 'extconf.rb') do |io|
io.write <<-RUBY
require 'mkmf'
create_makefile '#{@spec.name}'
RUBY
end
@spec.files += %w[extconf.rb]
use_ui @ui do
path = Gem::Package.build @spec
installer = Gem::Installer.new path
installer.install
end
assert_path_exists @spec.extension_install_dir, 'sanity check'
uninstaller = Gem::Uninstaller.new @spec.name, :executables => true
uninstaller.uninstall
refute_path_exists @spec.extension_install_dir
end
def test_uninstall_nonexistent
uninstaller = Gem::Uninstaller.new 'bogus', :executables => true

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

@ -16,5 +16,13 @@ class TestGemUriFormatter < Gem::TestCase
Gem::UriFormatter.new('example/').normalize
end
def test_escape
assert_equal 'a%40b%5Cc', Gem::UriFormatter.new('a@b\c').escape
end
def test_unescape
assert_equal 'a@b\c', Gem::UriFormatter.new('a%40b%5Cc').unescape
end
end

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

@ -23,14 +23,13 @@ class TestGemVersion < Gem::TestCase
assert_bumped_version_equal "6", "5"
end
# FIX: For "legacy reasons," any object that responds to +version+
# is returned unchanged. I'm not certain why.
# A Gem::Version is already a Gem::Version and therefore not transformed by
# Gem::Version.create
def test_class_create
fake = Object.new
def fake.version; "1.0" end
real = Gem::Version.new(1.0)
assert_same fake, Gem::Version.create(fake)
assert_same real, Gem::Version.create(real)
assert_nil Gem::Version.create(nil)
assert_equal v("5.1"), Gem::Version.create("5.1")

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

@ -67,6 +67,18 @@ class TestGemRequire < Gem::TestCase
end
end
def test_require_can_use_a_pathname_object
a1 = new_spec "a", "1", nil, "lib/test_gem_require_a.rb"
install_specs a1
save_loaded_features do
assert_require Pathname.new 'test_gem_require_a'
assert_equal %w(a-1), loaded_spec_names
assert_equal unresolved_names, []
end
end
def test_activate_via_require_respects_loaded_files
require 'benchmark' # stdlib
save_loaded_features do