mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update Rubygems 2.6.10
*2ee5bf9fd3
*be510dd409
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6219b68fb5
commit
5d43821536
22 changed files with 235 additions and 56 deletions
|
@ -10,7 +10,7 @@ require 'rbconfig'
|
||||||
require 'thread'
|
require 'thread'
|
||||||
|
|
||||||
module Gem
|
module Gem
|
||||||
VERSION = '2.6.8'
|
VERSION = "2.6.10"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Must be first since it unloads the prelude from 1.9.2
|
# Must be first since it unloads the prelude from 1.9.2
|
||||||
|
|
|
@ -47,7 +47,7 @@ class Gem::Commands::SetupCommand < Gem::Command
|
||||||
end
|
end
|
||||||
|
|
||||||
add_option '--[no-]document [TYPES]', Array,
|
add_option '--[no-]document [TYPES]', Array,
|
||||||
'Generate documentation for RubyGems.',
|
'Generate documentation for RubyGems',
|
||||||
'List the documentation types you wish to',
|
'List the documentation types you wish to',
|
||||||
'generate. For example: rdoc,ri' do |value, options|
|
'generate. For example: rdoc,ri' do |value, options|
|
||||||
options[:document] = case value
|
options[:document] = case value
|
||||||
|
|
|
@ -44,7 +44,7 @@ module Kernel
|
||||||
spec = Gem.find_unresolved_default_spec(path)
|
spec = Gem.find_unresolved_default_spec(path)
|
||||||
if spec
|
if spec
|
||||||
Gem.remove_unresolved_default_spec(spec)
|
Gem.remove_unresolved_default_spec(spec)
|
||||||
gem(spec.name)
|
Kernel.send(:gem, spec.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
# If there are no unresolved deps, then we can use just try
|
# If there are no unresolved deps, then we can use just try
|
||||||
|
|
|
@ -48,9 +48,11 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
|
||||||
run cmd, results
|
run cmd, results
|
||||||
ensure
|
ensure
|
||||||
if File.exist? 'mkmf.log'
|
if File.exist? 'mkmf.log'
|
||||||
results << "To see why this extension failed to compile, please check" \
|
unless $?.success? then
|
||||||
" the mkmf.log which can be found here:\n"
|
results << "To see why this extension failed to compile, please check" \
|
||||||
results << " " + File.join(dest_path, 'mkmf.log') + "\n"
|
" the mkmf.log which can be found here:\n"
|
||||||
|
results << " " + File.join(dest_path, 'mkmf.log') + "\n"
|
||||||
|
end
|
||||||
FileUtils.mv 'mkmf.log', dest_path
|
FileUtils.mv 'mkmf.log', dest_path
|
||||||
end
|
end
|
||||||
siteconf.unlink
|
siteconf.unlink
|
||||||
|
|
|
@ -9,7 +9,7 @@ class Gem::Ext::RakeBuilder < Gem::Ext::Builder
|
||||||
|
|
||||||
def self.build(extension, directory, dest_path, results, args=[], lib_dir=nil)
|
def self.build(extension, directory, dest_path, results, args=[], lib_dir=nil)
|
||||||
if File.basename(extension) =~ /mkrf_conf/i then
|
if File.basename(extension) =~ /mkrf_conf/i then
|
||||||
cmd = "#{Gem.ruby} #{File.basename extension}"
|
cmd = "#{Gem.ruby} #{File.basename extension}".dup
|
||||||
cmd << " #{args.join " "}" unless args.empty?
|
cmd << " #{args.join " "}" unless args.empty?
|
||||||
run cmd, results
|
run cmd, results
|
||||||
end
|
end
|
||||||
|
|
|
@ -119,6 +119,7 @@ module Gem::Resolver::Molinillo
|
||||||
# {Vertex#successors}
|
# {Vertex#successors}
|
||||||
def ==(other)
|
def ==(other)
|
||||||
return false unless other
|
return false unless other
|
||||||
|
return true if equal?(other)
|
||||||
vertices.each do |name, vertex|
|
vertices.each do |name, vertex|
|
||||||
other_vertex = other.vertex_named(name)
|
other_vertex = other.vertex_named(name)
|
||||||
return false unless other_vertex
|
return false unless other_vertex
|
||||||
|
@ -134,6 +135,7 @@ module Gem::Resolver::Molinillo
|
||||||
def add_child_vertex(name, payload, parent_names, requirement)
|
def add_child_vertex(name, payload, parent_names, requirement)
|
||||||
root = !parent_names.delete(nil) { true }
|
root = !parent_names.delete(nil) { true }
|
||||||
vertex = add_vertex(name, payload, root)
|
vertex = add_vertex(name, payload, root)
|
||||||
|
vertex.explicit_requirements << requirement if root
|
||||||
parent_names.each do |parent_name|
|
parent_names.each do |parent_name|
|
||||||
parent_node = vertex_named(parent_name)
|
parent_node = vertex_named(parent_name)
|
||||||
add_edge(parent_node, vertex, requirement)
|
add_edge(parent_node, vertex, requirement)
|
||||||
|
@ -152,7 +154,7 @@ module Gem::Resolver::Molinillo
|
||||||
# Detaches the {#vertex_named} `name` {Vertex} from the graph, recursively
|
# Detaches the {#vertex_named} `name` {Vertex} from the graph, recursively
|
||||||
# removing any non-root vertices that were orphaned in the process
|
# removing any non-root vertices that were orphaned in the process
|
||||||
# @param [String] name
|
# @param [String] name
|
||||||
# @return [void]
|
# @return [Array<Vertex>] the vertices which have been detached
|
||||||
def detach_vertex_named(name)
|
def detach_vertex_named(name)
|
||||||
log.detach_vertex_named(self, name)
|
log.detach_vertex_named(self, name)
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,16 +14,23 @@ module Gem::Resolver::Molinillo
|
||||||
|
|
||||||
# (see Action#up)
|
# (see Action#up)
|
||||||
def up(graph)
|
def up(graph)
|
||||||
return unless @vertex = graph.vertices.delete(name)
|
return [] unless @vertex = graph.vertices.delete(name)
|
||||||
|
|
||||||
|
removed_vertices = [@vertex]
|
||||||
@vertex.outgoing_edges.each do |e|
|
@vertex.outgoing_edges.each do |e|
|
||||||
v = e.destination
|
v = e.destination
|
||||||
v.incoming_edges.delete(e)
|
v.incoming_edges.delete(e)
|
||||||
graph.detach_vertex_named(v.name) unless v.root? || v.predecessors.any?
|
if !v.root? && v.incoming_edges.empty?
|
||||||
|
removed_vertices.concat graph.detach_vertex_named(v.name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@vertex.incoming_edges.each do |e|
|
@vertex.incoming_edges.each do |e|
|
||||||
v = e.origin
|
v = e.origin
|
||||||
v.outgoing_edges.delete(e)
|
v.outgoing_edges.delete(e)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
removed_vertices
|
||||||
end
|
end
|
||||||
|
|
||||||
# (see Action#down)
|
# (see Action#down)
|
||||||
|
|
|
@ -81,6 +81,7 @@ module Gem::Resolver::Molinillo
|
||||||
# @return [Boolean] whether the two vertices are equal, determined
|
# @return [Boolean] whether the two vertices are equal, determined
|
||||||
# by a recursive traversal of each {Vertex#successors}
|
# by a recursive traversal of each {Vertex#successors}
|
||||||
def ==(other)
|
def ==(other)
|
||||||
|
return true if equal?(other)
|
||||||
shallow_eql?(other) &&
|
shallow_eql?(other) &&
|
||||||
successors.to_set == other.successors.to_set
|
successors.to_set == other.successors.to_set
|
||||||
end
|
end
|
||||||
|
@ -89,6 +90,7 @@ module Gem::Resolver::Molinillo
|
||||||
# @return [Boolean] whether the two vertices are equal, determined
|
# @return [Boolean] whether the two vertices are equal, determined
|
||||||
# solely by {#name} and {#payload} equality
|
# solely by {#name} and {#payload} equality
|
||||||
def shallow_eql?(other)
|
def shallow_eql?(other)
|
||||||
|
return true if equal?(other)
|
||||||
other &&
|
other &&
|
||||||
name == other.name &&
|
name == other.name &&
|
||||||
payload == other.payload
|
payload == other.payload
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
module Gem::Resolver::Molinillo
|
module Gem::Resolver::Molinillo
|
||||||
# The version of Gem::Resolver::Molinillo.
|
# The version of Gem::Resolver::Molinillo.
|
||||||
VERSION = '0.5.3'.freeze
|
VERSION = '0.5.5'.freeze
|
||||||
end
|
end
|
||||||
|
|
|
@ -194,18 +194,20 @@ module Gem::Resolver::Molinillo
|
||||||
def state_index_for_unwind
|
def state_index_for_unwind
|
||||||
current_requirement = requirement
|
current_requirement = requirement
|
||||||
existing_requirement = requirement_for_existing_name(name)
|
existing_requirement = requirement_for_existing_name(name)
|
||||||
until current_requirement.nil?
|
index = -1
|
||||||
current_state = find_state_for(current_requirement)
|
[current_requirement, existing_requirement].each do |r|
|
||||||
return states.index(current_state) if state_any?(current_state)
|
until r.nil?
|
||||||
current_requirement = parent_of(current_requirement)
|
current_state = find_state_for(r)
|
||||||
|
if state_any?(current_state)
|
||||||
|
current_index = states.index(current_state)
|
||||||
|
index = current_index if current_index > index
|
||||||
|
break
|
||||||
|
end
|
||||||
|
r = parent_of(r)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
until existing_requirement.nil?
|
index
|
||||||
existing_state = find_state_for(existing_requirement)
|
|
||||||
return states.index(existing_state) if state_any?(existing_state)
|
|
||||||
existing_requirement = parent_of(existing_requirement)
|
|
||||||
end
|
|
||||||
-1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [Object] the requirement that led to `requirement` being added
|
# @return [Object] the requirement that led to `requirement` being added
|
||||||
|
@ -364,19 +366,17 @@ module Gem::Resolver::Molinillo
|
||||||
if matching_deps.empty? && !succ.root? && succ.predecessors.to_a == [vertex]
|
if matching_deps.empty? && !succ.root? && succ.predecessors.to_a == [vertex]
|
||||||
debug(depth) { "Removing orphaned spec #{succ.name} after swapping #{name}" }
|
debug(depth) { "Removing orphaned spec #{succ.name} after swapping #{name}" }
|
||||||
succ.requirements.each { |r| @parent_of.delete(r) }
|
succ.requirements.each { |r| @parent_of.delete(r) }
|
||||||
activated.detach_vertex_named(succ.name)
|
|
||||||
|
|
||||||
all_successor_names = succ.recursive_successors.map(&:name)
|
removed_names = activated.detach_vertex_named(succ.name).map(&:name)
|
||||||
|
requirements.delete_if do |r|
|
||||||
requirements.delete_if do |requirement|
|
# the only removed vertices are those with no other requirements,
|
||||||
requirement_name = name_for(requirement)
|
# so it's safe to delete only based upon name here
|
||||||
(requirement_name == succ.name) || all_successor_names.include?(requirement_name)
|
removed_names.include?(name_for(r))
|
||||||
end
|
end
|
||||||
elsif !matching_deps.include?(outgoing_edge.requirement)
|
elsif !matching_deps.include?(outgoing_edge.requirement)
|
||||||
activated.delete_edge(outgoing_edge)
|
activated.delete_edge(outgoing_edge)
|
||||||
requirements.delete(outgoing_edge.requirement)
|
requirements.delete(outgoing_edge.requirement)
|
||||||
end
|
end
|
||||||
matching_deps.delete(outgoing_edge.requirement)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
require 'webrick'
|
require 'webrick'
|
||||||
require 'zlib'
|
require 'zlib'
|
||||||
require 'erb'
|
require 'erb'
|
||||||
|
require 'uri'
|
||||||
|
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'rubygems/rdoc'
|
require 'rubygems/rdoc'
|
||||||
|
@ -68,7 +69,7 @@ class Gem::Server
|
||||||
<h1>Summary</h1>
|
<h1>Summary</h1>
|
||||||
<p>There are <%=values["gem_count"]%> gems installed:</p>
|
<p>There are <%=values["gem_count"]%> gems installed:</p>
|
||||||
<p>
|
<p>
|
||||||
<%= values["specs"].map { |v| "<a href\"##{u v["name"]}\">#{h v["name"]}</a>" }.join ', ' %>.
|
<%= values["specs"].map { |v| "<a href=\"##{u v["name"]}\">#{h v["name"]}</a>" }.join ', ' %>.
|
||||||
<h1>Gems</h1>
|
<h1>Gems</h1>
|
||||||
|
|
||||||
<dl>
|
<dl>
|
||||||
|
@ -81,20 +82,20 @@ class Gem::Server
|
||||||
<b><%=h spec["name"]%> <%=h spec["version"]%></b>
|
<b><%=h spec["name"]%> <%=h spec["version"]%></b>
|
||||||
|
|
||||||
<% if spec["ri_installed"] || spec["rdoc_installed"] then %>
|
<% if spec["ri_installed"] || spec["rdoc_installed"] then %>
|
||||||
<a href="<%=u spec["doc_path"]%>">[rdoc]</a>
|
<a href="<%=spec["doc_path"]%>">[rdoc]</a>
|
||||||
<% else %>
|
<% else %>
|
||||||
<span title="rdoc not installed">[rdoc]</span>
|
<span title="rdoc not installed">[rdoc]</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if spec["homepage"] then %>
|
<% if spec["homepage"] then %>
|
||||||
<a href="<%=u spec["homepage"]%>" title="<%=h spec["homepage"]%>">[www]</a>
|
<a href="<%=uri_encode spec["homepage"]%>" title="<%=h spec["homepage"]%>">[www]</a>
|
||||||
<% else %>
|
<% else %>
|
||||||
<span title="no homepage available">[www]</span>
|
<span title="no homepage available">[www]</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if spec["has_deps"] then %>
|
<% if spec["has_deps"] then %>
|
||||||
- depends on
|
- depends on
|
||||||
<%= spec["dependencies"].map { |v| "<a href=\"##{u v["name"]}>#{h v["name"]}</a>" }.join ', ' %>.
|
<%= spec["dependencies"].map { |v| "<a href=\"##{u v["name"]}\">#{h v["name"]}</a>" }.join ', ' %>.
|
||||||
<% end %>
|
<% end %>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>
|
<dd>
|
||||||
|
@ -455,6 +456,12 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
||||||
end.max
|
end.max
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def uri_encode(str)
|
||||||
|
str.gsub(URI::UNSAFE) do |match|
|
||||||
|
match.each_byte.map { |c| sprintf('%%%02X', c.ord) }.join
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def doc_root gem_name
|
def doc_root gem_name
|
||||||
if have_rdoc_4_plus? then
|
if have_rdoc_4_plus? then
|
||||||
"/doc_root/#{u gem_name}/"
|
"/doc_root/#{u gem_name}/"
|
||||||
|
|
|
@ -39,7 +39,12 @@ class Gem::StubSpecification < Gem::BasicSpecification
|
||||||
def initialize data, extensions
|
def initialize data, extensions
|
||||||
parts = data[PREFIX.length..-1].split(" ".freeze, 4)
|
parts = data[PREFIX.length..-1].split(" ".freeze, 4)
|
||||||
@name = parts[0].freeze
|
@name = parts[0].freeze
|
||||||
@version = Gem::Version.new parts[1]
|
@version = if Gem::Version.correct?(parts[1])
|
||||||
|
Gem::Version.new(parts[1])
|
||||||
|
else
|
||||||
|
Gem::Version.new(0)
|
||||||
|
end
|
||||||
|
|
||||||
@platform = Gem::Platform.new parts[2]
|
@platform = Gem::Platform.new parts[2]
|
||||||
@extensions = extensions
|
@extensions = extensions
|
||||||
@full_name = if platform == Gem::Platform::RUBY
|
@full_name = if platform == Gem::Platform::RUBY
|
||||||
|
|
|
@ -204,8 +204,12 @@ class Gem::Version
|
||||||
# series of digits or ASCII letters separated by dots.
|
# series of digits or ASCII letters separated by dots.
|
||||||
|
|
||||||
def initialize version
|
def initialize version
|
||||||
raise ArgumentError, "Malformed version number string #{version}" unless
|
unless self.class.correct?(version)
|
||||||
self.class.correct?(version)
|
raise ArgumentError, "Malformed version number string #{version}"
|
||||||
|
end
|
||||||
|
|
||||||
|
# If version is an empty string convert it to 0
|
||||||
|
version = 0 if version =~ /\A\s*\Z/
|
||||||
|
|
||||||
@version = version.to_s.strip.gsub("-",".pre.")
|
@version = version.to_s.strip.gsub("-",".pre.")
|
||||||
@segments = nil
|
@segments = nil
|
||||||
|
|
|
@ -1451,6 +1451,7 @@ class TestGem < Gem::TestCase
|
||||||
ENV['RUBYGEMS_GEMDEPS'] = "-"
|
ENV['RUBYGEMS_GEMDEPS'] = "-"
|
||||||
|
|
||||||
out = `#{Gem.ruby.dup.untaint} -I "#{LIB_PATH.untaint}" -rubygems -e "p Gem.loaded_specs.values.map(&:full_name).sort"`
|
out = `#{Gem.ruby.dup.untaint} -I "#{LIB_PATH.untaint}" -rubygems -e "p Gem.loaded_specs.values.map(&:full_name).sort"`
|
||||||
|
out.sub!(/, "openssl-#{Gem::Version::VERSION_PATTERN}"/, "")
|
||||||
|
|
||||||
assert_equal '["a-1", "b-1", "c-1"]', out.strip
|
assert_equal '["a-1", "b-1", "c-1"]', out.strip
|
||||||
end
|
end
|
||||||
|
@ -1484,6 +1485,7 @@ class TestGem < Gem::TestCase
|
||||||
out = Dir.chdir "sub1" do
|
out = Dir.chdir "sub1" do
|
||||||
`#{Gem.ruby.dup.untaint} -I "#{LIB_PATH.untaint}" -rubygems -e "p Gem.loaded_specs.values.map(&:full_name).sort"`
|
`#{Gem.ruby.dup.untaint} -I "#{LIB_PATH.untaint}" -rubygems -e "p Gem.loaded_specs.values.map(&:full_name).sort"`
|
||||||
end
|
end
|
||||||
|
out.sub!(/, "openssl-#{Gem::Version::VERSION_PATTERN}"/, "")
|
||||||
|
|
||||||
Dir.rmdir "sub1"
|
Dir.rmdir "sub1"
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,29 @@ class TestGemExtExtConfBuilder < Gem::TestCase
|
||||||
|
|
||||||
assert_match(/^#{Gem.ruby}.* extconf.rb/, output[1])
|
assert_match(/^#{Gem.ruby}.* extconf.rb/, output[1])
|
||||||
assert_match(File.join(@dest_path, 'mkmf.log'), output[4])
|
assert_match(File.join(@dest_path, 'mkmf.log'), output[4])
|
||||||
|
assert_includes(output, "To see why this extension failed to compile, please check the mkmf.log which can be found here:\n")
|
||||||
|
|
||||||
|
assert_path_exists File.join @dest_path, 'mkmf.log'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_class_build_extconf_success_without_warning
|
||||||
|
if vc_windows? && !nmake_found?
|
||||||
|
skip("test_class_build_extconf_fail skipped - nmake not found")
|
||||||
|
end
|
||||||
|
|
||||||
|
File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
|
||||||
|
extconf.puts "require 'mkmf'"
|
||||||
|
extconf.puts "File.open('mkmf.log', 'w'){|f| f.write('a')}"
|
||||||
|
extconf.puts "create_makefile 'foo'"
|
||||||
|
end
|
||||||
|
|
||||||
|
output = []
|
||||||
|
|
||||||
|
Dir.chdir @ext do
|
||||||
|
Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
|
||||||
|
end
|
||||||
|
|
||||||
|
refute_includes(output, "To see why this extension failed to compile, please check the mkmf.log which can be found here:\n")
|
||||||
|
|
||||||
assert_path_exists File.join @dest_path, 'mkmf.log'
|
assert_path_exists File.join @dest_path, 'mkmf.log'
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,14 +14,7 @@ class TestGemExtRakeBuilder < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_class_build
|
def test_class_build
|
||||||
File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf|
|
create_temp_mkrf_file('task :default')
|
||||||
mkrf_conf.puts <<-EO_MKRF
|
|
||||||
File.open("Rakefile","w") do |f|
|
|
||||||
f.puts "task :default"
|
|
||||||
end
|
|
||||||
EO_MKRF
|
|
||||||
end
|
|
||||||
|
|
||||||
output = []
|
output = []
|
||||||
realdir = nil # HACK /tmp vs. /private/tmp
|
realdir = nil # HACK /tmp vs. /private/tmp
|
||||||
|
|
||||||
|
@ -39,15 +32,31 @@ class TestGemExtRakeBuilder < Gem::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_class_build_fail
|
# https://github.com/rubygems/rubygems/pull/1819
|
||||||
File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf|
|
#
|
||||||
mkrf_conf.puts <<-EO_MKRF
|
# It should not fail with a non-empty args list either
|
||||||
File.open("Rakefile","w") do |f|
|
def test_class_build_with_args
|
||||||
f.puts "task :default do abort 'fail' end"
|
create_temp_mkrf_file('task :default')
|
||||||
end
|
output = []
|
||||||
EO_MKRF
|
realdir = nil # HACK /tmp vs. /private/tmp
|
||||||
end
|
|
||||||
|
|
||||||
|
build_rake_in do |rake|
|
||||||
|
Dir.chdir @ext do
|
||||||
|
realdir = Dir.pwd
|
||||||
|
non_empty_args_list = ['']
|
||||||
|
Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', nil, @dest_path, output, non_empty_args_list
|
||||||
|
end
|
||||||
|
|
||||||
|
output = output.join "\n"
|
||||||
|
|
||||||
|
refute_match %r%^rake failed:%, output
|
||||||
|
assert_match %r%^#{Regexp.escape @@ruby} mkrf_conf\.rb%, output
|
||||||
|
assert_match %r%^#{Regexp.escape rake} RUBYARCHDIR=#{Regexp.escape @dest_path} RUBYLIBDIR=#{Regexp.escape @dest_path}%, output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_class_build_fail
|
||||||
|
create_temp_mkrf_file("task :default do abort 'fail' end")
|
||||||
output = []
|
output = []
|
||||||
|
|
||||||
build_rake_in(false) do |rake|
|
build_rake_in(false) do |rake|
|
||||||
|
@ -60,6 +69,14 @@ class TestGemExtRakeBuilder < Gem::TestCase
|
||||||
assert_match %r%^rake failed%, error.message
|
assert_match %r%^rake failed%, error.message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_temp_mkrf_file(rakefile_content)
|
||||||
|
File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf|
|
||||||
|
mkrf_conf.puts <<-EO_MKRF
|
||||||
|
File.open("Rakefile","w") do |f|
|
||||||
|
f.puts "#{rakefile_content}"
|
||||||
|
end
|
||||||
|
EO_MKRF
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
|
||||||
fetcher = Gem::RemoteFetcher.new nil
|
fetcher = Gem::RemoteFetcher.new nil
|
||||||
@fetcher = fetcher
|
@fetcher = fetcher
|
||||||
def fetcher.request(uri, request_class, last_modified = nil)
|
def fetcher.request(uri, request_class, last_modified = nil)
|
||||||
raise SocketError, "tarded"
|
raise SocketError, "oops"
|
||||||
end
|
end
|
||||||
|
|
||||||
uri = 'http://gems.example.com/yaml'
|
uri = 'http://gems.example.com/yaml'
|
||||||
|
@ -171,7 +171,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
|
||||||
fetcher.fetch_size uri
|
fetcher.fetch_size uri
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal "SocketError: tarded (#{uri})", e.message
|
assert_equal "SocketError: oops (#{uri})", e.message
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_no_proxy
|
def test_no_proxy
|
||||||
|
|
|
@ -392,6 +392,22 @@ class TestGemServer < Gem::TestCase
|
||||||
Marshal.load(Gem.gunzip(@res.body))
|
Marshal.load(Gem.gunzip(@res.body))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_uri_encode
|
||||||
|
url_safe = @server.uri_encode 'http://rubyonrails.org/">malicious_content</a>'
|
||||||
|
assert_equal url_safe, 'http://rubyonrails.org/%22%3Emalicious_content%3C/a%3E'
|
||||||
|
end
|
||||||
|
|
||||||
|
# Regression test for issue #1793: incorrect URL encoding.
|
||||||
|
# Checking that no URLs have had '://' incorrectly encoded
|
||||||
|
def test_regression_1793
|
||||||
|
data = StringIO.new "GET / HTTP/1.0\r\n\r\n"
|
||||||
|
@req.parse data
|
||||||
|
|
||||||
|
@server.root @req, @res
|
||||||
|
|
||||||
|
refute_match %r|%3A%2F%2F|, @res.body
|
||||||
|
end
|
||||||
|
|
||||||
def util_listen
|
def util_listen
|
||||||
webrick = Object.new
|
webrick = Object.new
|
||||||
webrick.instance_variable_set :@listeners, []
|
webrick.instance_variable_set :@listeners, []
|
||||||
|
|
|
@ -1260,7 +1260,7 @@ dependencies: []
|
||||||
s.version = '1'
|
s.version = '1'
|
||||||
end
|
end
|
||||||
|
|
||||||
spec.instance_variable_set :@licenses, Object.new.singleton_class
|
spec.instance_variable_set :@licenses, (class << (Object.new);self;end)
|
||||||
spec.loaded_from = '/path/to/file'
|
spec.loaded_from = '/path/to/file'
|
||||||
|
|
||||||
e = assert_raises Gem::FormatException do
|
e = assert_raises Gem::FormatException do
|
||||||
|
|
|
@ -33,6 +33,20 @@ class TestStubSpecification < Gem::TestCase
|
||||||
assert_equal %w[ext/stub_e/extconf.rb], stub.extensions
|
assert_equal %w[ext/stub_e/extconf.rb], stub.extensions
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_initialize_version
|
||||||
|
stub = stub_with_version
|
||||||
|
|
||||||
|
assert_equal 'stub_v', stub.name
|
||||||
|
assert_equal v(2), stub.version
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_initialize_with_empty_version
|
||||||
|
stub = stub_without_version
|
||||||
|
|
||||||
|
assert_equal 'stub_v', stub.name
|
||||||
|
assert_equal v(0), stub.version
|
||||||
|
end
|
||||||
|
|
||||||
def test_initialize_missing_stubline
|
def test_initialize_missing_stubline
|
||||||
stub = Gem::StubSpecification.gemspec_stub(BAR, @base_dir, @gems_dir)
|
stub = Gem::StubSpecification.gemspec_stub(BAR, @base_dir, @gems_dir)
|
||||||
assert_equal "bar", stub.name
|
assert_equal "bar", stub.name
|
||||||
|
@ -164,6 +178,53 @@ class TestStubSpecification < Gem::TestCase
|
||||||
assert stub.to_spec.instance_variable_get :@ignored
|
assert stub.to_spec.instance_variable_get :@ignored
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def stub_with_version
|
||||||
|
spec = File.join @gemhome, 'specifications', 'stub_e-2.gemspec'
|
||||||
|
open spec, 'w' do |io|
|
||||||
|
io.write <<-STUB
|
||||||
|
# -*- encoding: utf-8 -*-
|
||||||
|
# stub: stub_v 2 ruby lib
|
||||||
|
|
||||||
|
Gem::Specification.new do |s|
|
||||||
|
s.name = 'stub_v'
|
||||||
|
s.version = Gem::Version.new '2'
|
||||||
|
end
|
||||||
|
STUB
|
||||||
|
|
||||||
|
io.flush
|
||||||
|
|
||||||
|
stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, 'gems')
|
||||||
|
|
||||||
|
yield stub if block_given?
|
||||||
|
|
||||||
|
return stub
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def stub_without_version
|
||||||
|
spec = File.join @gemhome, 'specifications', 'stub-2.gemspec'
|
||||||
|
open spec, 'w' do |io|
|
||||||
|
io.write <<-STUB
|
||||||
|
# -*- encoding: utf-8 -*-
|
||||||
|
# stub: stub_v ruby lib
|
||||||
|
|
||||||
|
Gem::Specification.new do |s|
|
||||||
|
s.name = 'stub_v'
|
||||||
|
s.version = ""
|
||||||
|
end
|
||||||
|
STUB
|
||||||
|
|
||||||
|
io.flush
|
||||||
|
|
||||||
|
stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, 'gems')
|
||||||
|
|
||||||
|
yield stub if block_given?
|
||||||
|
|
||||||
|
return stub
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
def stub_with_extension
|
def stub_with_extension
|
||||||
spec = File.join @gemhome, 'specifications', 'stub_e-2.gemspec'
|
spec = File.join @gemhome, 'specifications', 'stub_e-2.gemspec'
|
||||||
open spec, 'w' do |io|
|
open spec, 'w' do |io|
|
||||||
|
|
|
@ -91,6 +91,12 @@ class TestGemVersion < Gem::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_empty_version
|
||||||
|
["", " ", " "].each do |empty|
|
||||||
|
assert_equal "0", Gem::Version.new(empty).version
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_prerelease
|
def test_prerelease
|
||||||
assert_prerelease "1.2.0.a"
|
assert_prerelease "1.2.0.a"
|
||||||
assert_prerelease "2.9.b"
|
assert_prerelease "2.9.b"
|
||||||
|
|
|
@ -341,6 +341,31 @@ class TestGemRequire < Gem::TestCase
|
||||||
Kernel::RUBYGEMS_ACTIVATION_MONITOR.exit
|
Kernel::RUBYGEMS_ACTIVATION_MONITOR.exit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_require_when_gem_defined
|
||||||
|
default_gem_spec = new_default_spec("default", "2.0.0.0",
|
||||||
|
nil, "default/gem.rb")
|
||||||
|
install_default_specs(default_gem_spec)
|
||||||
|
c = Class.new do
|
||||||
|
def self.gem(*args)
|
||||||
|
raise "received #gem with #{args.inspect}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
assert c.send(:require, "default/gem")
|
||||||
|
assert_equal %w(default-2.0.0.0), loaded_spec_names
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_require_default_when_gem_defined
|
||||||
|
a = new_spec("a", "1", nil, "lib/a.rb")
|
||||||
|
install_specs a
|
||||||
|
c = Class.new do
|
||||||
|
def self.gem(*args)
|
||||||
|
raise "received #gem with #{args.inspect}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
assert c.send(:require, "a")
|
||||||
|
assert_equal %w(a-1), loaded_spec_names
|
||||||
|
end
|
||||||
|
|
||||||
def silence_warnings
|
def silence_warnings
|
||||||
old_verbose, $VERBOSE = $VERBOSE, false
|
old_verbose, $VERBOSE = $VERBOSE, false
|
||||||
yield
|
yield
|
||||||
|
|
Loading…
Reference in a new issue