mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rubygems: Update to RubyGems master b9213d7. Changes include:
Fixed tests on Windows (I hope) by forcing platform for platform-dependent tests. Fixed File.exists? warnings. Improved testing infrastructure. * test/rubygems: ditto. * test/rdoc/test_rdoc_rubygems_hook.rb: Switch to util_spec like RubyGems. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8f3934261a
commit
44d0a6dcd7
45 changed files with 1068 additions and 906 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
||||||
|
Tue Nov 12 09:16:24 2013 Eric Hodel <drbrain@segment7.net>
|
||||||
|
|
||||||
|
* lib/rubygems: Update to RubyGems master b9213d7. Changes include:
|
||||||
|
|
||||||
|
Fixed tests on Windows (I hope) by forcing platform for
|
||||||
|
platform-dependent tests.
|
||||||
|
|
||||||
|
Fixed File.exists? warnings.
|
||||||
|
|
||||||
|
Improved testing infrastructure.
|
||||||
|
|
||||||
|
* test/rubygems: ditto.
|
||||||
|
|
||||||
|
* test/rdoc/test_rdoc_rubygems_hook.rb: Switch to util_spec like
|
||||||
|
RubyGems.
|
||||||
|
|
||||||
Mon Nov 11 18:31:12 2013 Aman Gupta <ruby@tmm1.net>
|
Mon Nov 11 18:31:12 2013 Aman Gupta <ruby@tmm1.net>
|
||||||
|
|
||||||
* internal.h: move common string/hash flags to include file.
|
* internal.h: move common string/hash flags to include file.
|
||||||
|
|
|
@ -156,6 +156,10 @@ class RDoc::RubygemsHook
|
||||||
args.concat @spec.require_paths
|
args.concat @spec.require_paths
|
||||||
args.concat @spec.extra_rdoc_files
|
args.concat @spec.extra_rdoc_files
|
||||||
|
|
||||||
|
puts
|
||||||
|
p @spec.extra_rdoc_files
|
||||||
|
puts
|
||||||
|
|
||||||
case config_args = Gem.configuration[:rdoc]
|
case config_args = Gem.configuration[:rdoc]
|
||||||
when String then
|
when String then
|
||||||
args = args.concat config_args.split
|
args = args.concat config_args.split
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
|
|
||||||
module Gem
|
module Gem
|
||||||
VERSION = '2.2.0.preview.2'
|
VERSION = '2.2.0'
|
||||||
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
|
||||||
|
|
|
@ -56,8 +56,6 @@ class Gem::Source
|
||||||
# Returns a Set that can fetch specifications from this source.
|
# Returns a Set that can fetch specifications from this source.
|
||||||
|
|
||||||
def dependency_resolver_set # :nodoc:
|
def dependency_resolver_set # :nodoc:
|
||||||
uri = api_uri
|
|
||||||
|
|
||||||
bundler_api_uri = api_uri + './api/v1/dependencies'
|
bundler_api_uri = api_uri + './api/v1/dependencies'
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -1393,7 +1393,7 @@ class Gem::Specification < Gem::BasicSpecification
|
||||||
# Returns the build_args used to install the gem
|
# Returns the build_args used to install the gem
|
||||||
|
|
||||||
def build_args
|
def build_args
|
||||||
if File.exists? build_info_file
|
if File.exist? build_info_file
|
||||||
File.readlines(build_info_file).map { |x| x.strip }
|
File.readlines(build_info_file).map { |x| x.strip }
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -30,7 +30,6 @@ require 'fileutils'
|
||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
require 'uri'
|
require 'uri'
|
||||||
require 'rubygems/package'
|
require 'rubygems/package'
|
||||||
require 'rubygems/test_utilities'
|
|
||||||
require 'pp'
|
require 'pp'
|
||||||
require 'zlib'
|
require 'zlib'
|
||||||
require 'pathname'
|
require 'pathname'
|
||||||
|
@ -84,6 +83,8 @@ end
|
||||||
|
|
||||||
class Gem::TestCase < MiniTest::Unit::TestCase
|
class Gem::TestCase < MiniTest::Unit::TestCase
|
||||||
|
|
||||||
|
attr_accessor :fetcher # :nodoc:
|
||||||
|
|
||||||
def assert_activate expected, *specs
|
def assert_activate expected, *specs
|
||||||
specs.each do |spec|
|
specs.each do |spec|
|
||||||
case spec
|
case spec
|
||||||
|
@ -197,7 +198,8 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
||||||
@orig_gem_path = ENV['GEM_PATH']
|
@orig_gem_path = ENV['GEM_PATH']
|
||||||
|
|
||||||
@current_dir = Dir.pwd
|
@current_dir = Dir.pwd
|
||||||
@ui = Gem::MockGemUi.new
|
@fetcher = nil
|
||||||
|
@ui = Gem::MockGemUi.new
|
||||||
|
|
||||||
tmpdir = File.expand_path Dir.tmpdir
|
tmpdir = File.expand_path Dir.tmpdir
|
||||||
tmpdir.untaint
|
tmpdir.untaint
|
||||||
|
@ -378,7 +380,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
||||||
|
|
||||||
gem = File.join @tempdir, "gems", "#{spec.full_name}.gem"
|
gem = File.join @tempdir, "gems", "#{spec.full_name}.gem"
|
||||||
|
|
||||||
unless File.exists? gem
|
unless File.exist? gem then
|
||||||
use_ui Gem::MockGemUi.new do
|
use_ui Gem::MockGemUi.new do
|
||||||
Dir.chdir @tempdir do
|
Dir.chdir @tempdir do
|
||||||
Gem::Package.build spec
|
Gem::Package.build spec
|
||||||
|
@ -503,28 +505,11 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
||||||
return spec
|
return spec
|
||||||
end
|
end
|
||||||
|
|
||||||
def quick_spec name, version = '2'
|
##
|
||||||
# TODO: deprecate
|
# TODO: remove in RubyGems 3.0
|
||||||
require 'rubygems/specification'
|
|
||||||
|
|
||||||
spec = Gem::Specification.new do |s|
|
def quick_spec name, version = '2' # :nodoc:
|
||||||
s.platform = Gem::Platform::RUBY
|
util_spec name, version
|
||||||
s.name = name
|
|
||||||
s.version = version
|
|
||||||
s.author = 'A User'
|
|
||||||
s.email = 'example@example.com'
|
|
||||||
s.homepage = 'http://example.com'
|
|
||||||
s.summary = "this is a summary"
|
|
||||||
s.description = "This is a test description"
|
|
||||||
|
|
||||||
yield(s) if block_given?
|
|
||||||
end
|
|
||||||
|
|
||||||
spec.loaded_from = spec.spec_file
|
|
||||||
|
|
||||||
Gem::Specification.add_spec spec
|
|
||||||
|
|
||||||
return spec
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -561,7 +546,9 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
||||||
|
|
||||||
def util_clear_gems
|
def util_clear_gems
|
||||||
FileUtils.rm_rf File.join(@gemhome, "gems") # TODO: use Gem::Dirs
|
FileUtils.rm_rf File.join(@gemhome, "gems") # TODO: use Gem::Dirs
|
||||||
|
FileUtils.mkdir File.join(@gemhome, "gems")
|
||||||
FileUtils.rm_rf File.join(@gemhome, "specifications")
|
FileUtils.rm_rf File.join(@gemhome, "specifications")
|
||||||
|
FileUtils.mkdir File.join(@gemhome, "specifications")
|
||||||
Gem::Specification.reset
|
Gem::Specification.reset
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -612,10 +599,11 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Create a new spec (or gem if passed an array of files) and set it
|
# new_spec is deprecated as it is never used.
|
||||||
# up properly. Use this instead of util_spec and util_gem.
|
#
|
||||||
|
# TODO: remove in RubyGems 3.0
|
||||||
|
|
||||||
def new_spec name, version, deps = nil, *files
|
def new_spec name, version, deps = nil, *files # :nodoc:
|
||||||
require 'rubygems/specification'
|
require 'rubygems/specification'
|
||||||
|
|
||||||
spec = Gem::Specification.new do |s|
|
spec = Gem::Specification.new do |s|
|
||||||
|
@ -656,7 +644,8 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_default_spec(name, version, deps = nil, *files)
|
def new_default_spec(name, version, deps = nil, *files)
|
||||||
spec = new_spec(name, version, deps)
|
spec = util_spec name, version, deps
|
||||||
|
|
||||||
spec.loaded_from = File.join(@default_spec_dir, spec.spec_name)
|
spec.loaded_from = File.join(@default_spec_dir, spec.spec_name)
|
||||||
spec.files = files
|
spec.files = files
|
||||||
|
|
||||||
|
@ -674,24 +663,38 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Creates a spec with +name+, +version+ and +deps+.
|
# Creates a spec with +name+, +version+. +deps+ can specify the dependency
|
||||||
|
# or a +block+ can be given for full customization of the specification.
|
||||||
|
|
||||||
def util_spec(name, version, deps = nil, &block)
|
def util_spec name, version = 2, deps = nil # :yields: specification
|
||||||
# TODO: deprecate
|
raise "deps or block, not both" if deps and block_given?
|
||||||
raise "deps or block, not both" if deps and block
|
|
||||||
|
spec = Gem::Specification.new do |s|
|
||||||
|
s.platform = Gem::Platform::RUBY
|
||||||
|
s.name = name
|
||||||
|
s.version = version
|
||||||
|
s.author = 'A User'
|
||||||
|
s.email = 'example@example.com'
|
||||||
|
s.homepage = 'http://example.com'
|
||||||
|
s.summary = "this is a summary"
|
||||||
|
s.description = "This is a test description"
|
||||||
|
|
||||||
|
yield s if block_given?
|
||||||
|
end
|
||||||
|
|
||||||
if deps then
|
if deps then
|
||||||
block = proc do |s|
|
# Since Hash#each is unordered in 1.8, sort the keys and iterate that
|
||||||
# Since Hash#each is unordered in 1.8, sort
|
# way so the tests are deterministic on all implementations.
|
||||||
# the keys and iterate that way so the tests are
|
deps.keys.sort.each do |n|
|
||||||
# deteriminstic on all implementations.
|
spec.add_dependency n, (deps[n] || '>= 0')
|
||||||
deps.keys.sort.each do |n|
|
|
||||||
s.add_dependency n, (deps[n] || '>= 0')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
quick_spec(name, version, &block)
|
spec.loaded_from = spec.spec_file
|
||||||
|
|
||||||
|
Gem::Specification.add_spec spec
|
||||||
|
|
||||||
|
return spec
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -1132,38 +1135,8 @@ Also, a list:
|
||||||
# end
|
# end
|
||||||
|
|
||||||
def spec_fetcher
|
def spec_fetcher
|
||||||
gems = {}
|
Gem::TestCase::SpecFetcherSetup.declare self do |spec_fetcher_setup|
|
||||||
|
yield spec_fetcher_setup if block_given?
|
||||||
fetcher = Object.new
|
|
||||||
fetcher.instance_variable_set :@test, self
|
|
||||||
fetcher.instance_variable_set :@gems, gems
|
|
||||||
|
|
||||||
def fetcher.gem name, version, dependencies = nil, &block
|
|
||||||
spec, gem = @test.util_gem name, version, dependencies, &block
|
|
||||||
|
|
||||||
@gems[spec] = gem
|
|
||||||
|
|
||||||
spec
|
|
||||||
end
|
|
||||||
|
|
||||||
def fetcher.spec name, version, dependencies = nil, &block
|
|
||||||
spec = @test.util_spec name, version, dependencies, &block
|
|
||||||
|
|
||||||
@gems[spec] = nil
|
|
||||||
|
|
||||||
spec
|
|
||||||
end
|
|
||||||
|
|
||||||
yield fetcher
|
|
||||||
|
|
||||||
util_setup_fake_fetcher unless @fetcher
|
|
||||||
util_setup_spec_fetcher(*gems.keys)
|
|
||||||
|
|
||||||
gems.each do |spec, gem|
|
|
||||||
next unless gem
|
|
||||||
|
|
||||||
@fetcher.data["http://gems.example.com/gems/#{spec.file_name}"] =
|
|
||||||
Gem.read_binary(gem)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1318,3 +1291,6 @@ Also, a list:
|
||||||
end if defined?(OpenSSL::SSL)
|
end if defined?(OpenSSL::SSL)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require 'rubygems/test_utilities'
|
||||||
|
|
||||||
|
|
|
@ -159,6 +159,164 @@ class Gem::RemoteFetcher
|
||||||
end
|
end
|
||||||
# :startdoc:
|
# :startdoc:
|
||||||
|
|
||||||
|
##
|
||||||
|
# The SpecFetcherSetup allows easy setup of a remote source in RubyGems tests:
|
||||||
|
#
|
||||||
|
# spec_fetcher do |f|
|
||||||
|
# f.gem 'a', 1
|
||||||
|
# f.spec 'a', 2
|
||||||
|
# f.gem 'b', 1' 'a' => '~> 1.0'
|
||||||
|
# f.clear
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# The above declaration creates two gems, a-1 and b-1, with a dependency from
|
||||||
|
# b to a. The declaration creates an additional spec a-2, but no gem for it
|
||||||
|
# (so it cannot be installed).
|
||||||
|
#
|
||||||
|
# After the gems are created they are removed from Gem.dir.
|
||||||
|
|
||||||
|
class Gem::TestCase::SpecFetcherSetup
|
||||||
|
|
||||||
|
##
|
||||||
|
# Executes a SpecFetcher setup block. Yields an instance then creates the
|
||||||
|
# gems and specifications defined in the instance.
|
||||||
|
|
||||||
|
def self.declare test
|
||||||
|
setup = new test
|
||||||
|
|
||||||
|
yield setup
|
||||||
|
|
||||||
|
setup.execute
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize test # :nodoc:
|
||||||
|
@test = test
|
||||||
|
|
||||||
|
@gems = {}
|
||||||
|
@installed = []
|
||||||
|
@operations = []
|
||||||
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Removes any created gems or specifications from Gem.dir (the default
|
||||||
|
# install location).
|
||||||
|
|
||||||
|
def clear
|
||||||
|
@operations << [:clear]
|
||||||
|
end
|
||||||
|
|
||||||
|
def created_specs
|
||||||
|
created = {}
|
||||||
|
|
||||||
|
@gems.keys.each do |spec|
|
||||||
|
created[spec.full_name] = spec
|
||||||
|
end
|
||||||
|
|
||||||
|
created
|
||||||
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Creates any defined gems or specifications
|
||||||
|
|
||||||
|
def execute # :nodoc:
|
||||||
|
execute_operations
|
||||||
|
|
||||||
|
setup_fetcher
|
||||||
|
|
||||||
|
created_specs
|
||||||
|
end
|
||||||
|
|
||||||
|
def execute_operations # :nodoc:
|
||||||
|
@operations.each do |operation, *arguments|
|
||||||
|
case operation
|
||||||
|
when :clear then
|
||||||
|
@test.util_clear_gems
|
||||||
|
@installed.clear
|
||||||
|
when :gem then
|
||||||
|
spec, gem = @test.util_gem(*arguments, &arguments.pop)
|
||||||
|
|
||||||
|
write_spec spec
|
||||||
|
|
||||||
|
@gems[spec] = gem
|
||||||
|
@installed << spec
|
||||||
|
when :spec then
|
||||||
|
spec = @test.util_spec(*arguments, &arguments.pop)
|
||||||
|
|
||||||
|
write_spec spec
|
||||||
|
|
||||||
|
@gems[spec] = nil
|
||||||
|
@installed << spec
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Creates a gem with +name+, +version+ and +deps+. The created gem can be
|
||||||
|
# downloaded and installed.
|
||||||
|
#
|
||||||
|
# The specification will be yielded before gem creation for customization,
|
||||||
|
# but only the block or the dependencies may be set, not both.
|
||||||
|
|
||||||
|
def gem name, version, dependencies = nil, &block
|
||||||
|
@operations << [:gem, name, version, dependencies, block]
|
||||||
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Creates a legacy platform spec with the name 'pl' and version 1
|
||||||
|
|
||||||
|
def legacy_platform
|
||||||
|
spec 'pl', 1 do |s|
|
||||||
|
s.platform = Gem::Platform.new 'i386-linux'
|
||||||
|
s.instance_variable_set :@original_platform, 'i386-linux'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def setup_fetcher # :nodoc;
|
||||||
|
require 'zlib'
|
||||||
|
require 'socket'
|
||||||
|
require 'rubygems/remote_fetcher'
|
||||||
|
|
||||||
|
@test.fetcher = Gem::FakeFetcher.new
|
||||||
|
Gem::RemoteFetcher.fetcher = @test.fetcher
|
||||||
|
|
||||||
|
Gem::Specification.reset
|
||||||
|
|
||||||
|
@test.util_setup_spec_fetcher(*@gems.keys)
|
||||||
|
|
||||||
|
# This works around util_setup_spec_fetcher adding all created gems to the
|
||||||
|
# installed set.
|
||||||
|
Gem::Specification.reset
|
||||||
|
Gem::Specification.add_specs(*@installed)
|
||||||
|
|
||||||
|
@gems.each do |spec, gem|
|
||||||
|
next unless gem
|
||||||
|
|
||||||
|
@test.fetcher.data["http://gems.example.com/gems/#{spec.file_name}"] =
|
||||||
|
Gem.read_binary(gem)
|
||||||
|
|
||||||
|
FileUtils.cp gem, spec.cache_file
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Creates a spec with +name+, +version+ and +deps+. The created gem can be
|
||||||
|
# downloaded and installed.
|
||||||
|
#
|
||||||
|
# The specification will be yielded before creation for customization,
|
||||||
|
# but only the block or the dependencies may be set, not both.
|
||||||
|
|
||||||
|
def spec name, version, dependencies = nil, &block
|
||||||
|
@operations << [:spec, name, version, dependencies, block]
|
||||||
|
end
|
||||||
|
|
||||||
|
def write_spec spec # :nodoc:
|
||||||
|
open spec.spec_file, 'w' do |io|
|
||||||
|
io.write spec.to_ruby_for_cache
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# A StringIO duck-typed class that uses Tempfile instead of String as the
|
# A StringIO duck-typed class that uses Tempfile instead of String as the
|
||||||
# backing store.
|
# backing store.
|
||||||
|
|
|
@ -10,7 +10,7 @@ class TestRDocRubygemsHook < Gem::TestCase
|
||||||
skip 'requires RubyGems 1.9+' unless
|
skip 'requires RubyGems 1.9+' unless
|
||||||
Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.9')
|
Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.9')
|
||||||
|
|
||||||
@a = quick_spec 'a' do |s|
|
@a = util_spec 'a' do |s|
|
||||||
s.rdoc_options = %w[--main MyTitle]
|
s.rdoc_options = %w[--main MyTitle]
|
||||||
s.extra_rdoc_files = %w[README]
|
s.extra_rdoc_files = %w[README]
|
||||||
end
|
end
|
||||||
|
|
|
@ -116,7 +116,7 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_bin_path_nonexistent_binfile
|
def test_self_bin_path_nonexistent_binfile
|
||||||
quick_spec 'a', '2' do |s|
|
util_spec 'a', '2' do |s|
|
||||||
s.executables = ['exec']
|
s.executables = ['exec']
|
||||||
end
|
end
|
||||||
assert_raises(Gem::GemNotFoundException) do
|
assert_raises(Gem::GemNotFoundException) do
|
||||||
|
@ -125,7 +125,7 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_bin_path_no_bin_file
|
def test_self_bin_path_no_bin_file
|
||||||
quick_spec 'a', '1'
|
util_spec 'a', '1'
|
||||||
assert_raises(ArgumentError) do
|
assert_raises(ArgumentError) do
|
||||||
Gem.bin_path('a', nil, '1')
|
Gem.bin_path('a', nil, '1')
|
||||||
end
|
end
|
||||||
|
@ -139,7 +139,7 @@ class TestGem < Gem::TestCase
|
||||||
|
|
||||||
def test_self_bin_path_bin_file_gone_in_latest
|
def test_self_bin_path_bin_file_gone_in_latest
|
||||||
util_exec_gem
|
util_exec_gem
|
||||||
quick_spec 'a', '10' do |s|
|
util_spec 'a', '10' do |s|
|
||||||
s.executables = []
|
s.executables = []
|
||||||
end
|
end
|
||||||
# Should not find a-10's non-abin (bug)
|
# Should not find a-10's non-abin (bug)
|
||||||
|
@ -183,7 +183,7 @@ class TestGem < Gem::TestCase
|
||||||
fp.puts 'blah'
|
fp.puts 'blah'
|
||||||
end
|
end
|
||||||
|
|
||||||
foo = quick_spec 'foo' do |s| s.files = %w[data/foo.txt] end
|
foo = util_spec 'foo' do |s| s.files = %w[data/foo.txt] end
|
||||||
install_gem foo
|
install_gem foo
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -420,17 +420,15 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_latest_spec_for
|
def test_self_latest_spec_for
|
||||||
a2 = nil
|
gems = spec_fetcher do |fetcher|
|
||||||
|
|
||||||
spec_fetcher do |fetcher|
|
|
||||||
fetcher.spec 'a', 1
|
fetcher.spec 'a', 1
|
||||||
fetcher.spec 'a', '3.a'
|
fetcher.spec 'a', '3.a'
|
||||||
a2 = fetcher.spec 'a', 2
|
fetcher.spec 'a', 2
|
||||||
end
|
end
|
||||||
|
|
||||||
spec = Gem.latest_spec_for 'a'
|
spec = Gem.latest_spec_for 'a'
|
||||||
|
|
||||||
assert_equal a2, spec
|
assert_equal gems['a-2'], spec
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_latest_rubygems_version
|
def test_self_latest_rubygems_version
|
||||||
|
@ -458,7 +456,7 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_loaded_specs
|
def test_self_loaded_specs
|
||||||
foo = quick_spec 'foo'
|
foo = util_spec 'foo'
|
||||||
install_gem foo
|
install_gem foo
|
||||||
|
|
||||||
foo.activate
|
foo.activate
|
||||||
|
@ -959,13 +957,13 @@ class TestGem < Gem::TestCase
|
||||||
fp.puts "class TestGem; PLUGINS_LOADED << 'plugin'; end"
|
fp.puts "class TestGem; PLUGINS_LOADED << 'plugin'; end"
|
||||||
end
|
end
|
||||||
|
|
||||||
foo1 = quick_spec 'foo', '1' do |s|
|
foo1 = util_spec 'foo', '1' do |s|
|
||||||
s.files << plugin_path
|
s.files << plugin_path
|
||||||
end
|
end
|
||||||
|
|
||||||
install_gem foo1
|
install_gem foo1
|
||||||
|
|
||||||
foo2 = quick_spec 'foo', '2' do |s|
|
foo2 = util_spec 'foo', '2' do |s|
|
||||||
s.files << plugin_path
|
s.files << plugin_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1275,7 +1273,7 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def util_exec_gem
|
def util_exec_gem
|
||||||
spec, _ = quick_spec 'a', '4' do |s|
|
spec, _ = util_spec 'a', '4' do |s|
|
||||||
s.executables = ['exec', 'abin']
|
s.executables = ['exec', 'abin']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
|
|
||||||
@gem = quick_spec 'some_gem' do |s|
|
@gem = util_spec 'some_gem' do |s|
|
||||||
s.rubyforge_project = 'example'
|
s.rubyforge_project = 'example'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
|
||||||
|
|
||||||
@cmd = Gem::Commands::CleanupCommand.new
|
@cmd = Gem::Commands::CleanupCommand.new
|
||||||
|
|
||||||
@a_1 = quick_spec 'a', 1
|
@a_1 = util_spec 'a', 1
|
||||||
@a_2 = quick_spec 'a', 2
|
@a_2 = util_spec 'a', 2
|
||||||
|
|
||||||
install_gem @a_1
|
install_gem @a_1
|
||||||
install_gem @a_2
|
install_gem @a_2
|
||||||
|
@ -39,8 +39,8 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_all_dependencies
|
def test_execute_all_dependencies
|
||||||
@b_1 = quick_spec 'b', 1 do |s| s.add_dependency 'a', '1' end
|
@b_1 = util_spec 'b', 1 do |s| s.add_dependency 'a', '1' end
|
||||||
@b_2 = quick_spec 'b', 2 do |s| s.add_dependency 'a', '2' end
|
@b_2 = util_spec 'b', 2 do |s| s.add_dependency 'a', '2' end
|
||||||
|
|
||||||
install_gem @b_1
|
install_gem @b_1
|
||||||
install_gem @b_2
|
install_gem @b_2
|
||||||
|
@ -60,8 +60,8 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
|
||||||
|
|
||||||
Gem.use_paths @gemhome, gemhome2
|
Gem.use_paths @gemhome, gemhome2
|
||||||
|
|
||||||
@b_1 = quick_spec 'b', 1
|
@b_1 = util_spec 'b', 1
|
||||||
@b_2 = quick_spec 'b', 2
|
@b_2 = util_spec 'b', 2
|
||||||
|
|
||||||
install_gem @b_1
|
install_gem @b_1
|
||||||
install_gem @b_2
|
install_gem @b_2
|
||||||
|
@ -78,7 +78,7 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_all_user
|
def test_execute_all_user
|
||||||
@a_1_1 = quick_spec 'a', '1.1'
|
@a_1_1 = util_spec 'a', '1.1'
|
||||||
@a_1_1 = install_gem_user @a_1_1 # pick up user install path
|
@a_1_1 = install_gem_user @a_1_1 # pick up user install path
|
||||||
|
|
||||||
Gem::Specification.dirs = [Gem.dir, Gem.user_dir]
|
Gem::Specification.dirs = [Gem.dir, Gem.user_dir]
|
||||||
|
@ -97,7 +97,7 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
|
||||||
def test_execute_all_user_no_sudo
|
def test_execute_all_user_no_sudo
|
||||||
FileUtils.chmod 0555, @gemhome
|
FileUtils.chmod 0555, @gemhome
|
||||||
|
|
||||||
@a_1_1 = quick_spec 'a', '1.1'
|
@a_1_1 = util_spec 'a', '1.1'
|
||||||
@a_1_1 = install_gem_user @a_1_1 # pick up user install path
|
@a_1_1 = install_gem_user @a_1_1 # pick up user install path
|
||||||
|
|
||||||
Gem::Specification.dirs = [Gem.dir, Gem.user_dir]
|
Gem::Specification.dirs = [Gem.dir, Gem.user_dir]
|
||||||
|
@ -125,10 +125,10 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_keeps_older_versions_with_deps
|
def test_execute_keeps_older_versions_with_deps
|
||||||
@b_1 = quick_spec 'b', 1
|
@b_1 = util_spec 'b', 1
|
||||||
@b_2 = quick_spec 'b', 2
|
@b_2 = util_spec 'b', 2
|
||||||
|
|
||||||
@c = quick_spec 'c', 1 do |s|
|
@c = util_spec 'c', 1 do |s|
|
||||||
s.add_dependency 'b', '1'
|
s.add_dependency 'b', '1'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -146,9 +146,9 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
|
||||||
def test_execute_ignore_default_gem_verbose
|
def test_execute_ignore_default_gem_verbose
|
||||||
Gem.configuration.verbose = :really
|
Gem.configuration.verbose = :really
|
||||||
|
|
||||||
@b_1 = quick_spec 'b', 1
|
@b_1 = util_spec 'b', 1
|
||||||
@b_default = new_default_spec "b", "2"
|
@b_default = new_default_spec "b", "2"
|
||||||
@b_2 = quick_spec 'b', 3
|
@b_2 = util_spec 'b', 3
|
||||||
|
|
||||||
install_gem @b_1
|
install_gem @b_1
|
||||||
install_default_specs @b_default
|
install_default_specs @b_default
|
||||||
|
|
|
@ -8,8 +8,6 @@ class TestGemCommandsDependencyCommand < Gem::TestCase
|
||||||
|
|
||||||
@cmd = Gem::Commands::DependencyCommand.new
|
@cmd = Gem::Commands::DependencyCommand.new
|
||||||
@cmd.options[:domain] = :local
|
@cmd.options[:domain] = :local
|
||||||
|
|
||||||
util_setup_fake_fetcher true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute
|
def test_execute
|
||||||
|
@ -30,6 +28,13 @@ class TestGemCommandsDependencyCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_no_args
|
def test_execute_no_args
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
|
fetcher.spec 'a', '2.a'
|
||||||
|
fetcher.spec 'dep_x', 1, 'x' => '>= 1'
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:args] = []
|
@cmd.options[:args] = []
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
|
@ -41,23 +46,11 @@ Gem a-1
|
||||||
|
|
||||||
Gem a-2.a
|
Gem a-2.a
|
||||||
|
|
||||||
Gem a-2
|
|
||||||
|
|
||||||
Gem a-3.a
|
|
||||||
|
|
||||||
Gem a_evil-9
|
|
||||||
|
|
||||||
Gem b-2
|
|
||||||
|
|
||||||
Gem c-1.2
|
|
||||||
|
|
||||||
Gem dep_x-1
|
Gem dep_x-1
|
||||||
x (>= 1)
|
x (>= 1)
|
||||||
|
|
||||||
Gem pl-1-x86-linux
|
Gem pl-1-x86-linux
|
||||||
|
|
||||||
Gem x-1
|
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
assert_equal expected, @ui.output
|
assert_equal expected, @ui.output
|
||||||
|
@ -78,7 +71,7 @@ Gem x-1
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_pipe_format
|
def test_execute_pipe_format
|
||||||
quick_spec 'foo' do |gem|
|
util_spec 'foo' do |gem|
|
||||||
gem.add_dependency 'bar', '> 1'
|
gem.add_dependency 'bar', '> 1'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -94,6 +87,13 @@ Gem x-1
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_regexp
|
def test_execute_regexp
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
|
fetcher.spec 'a', '2.a'
|
||||||
|
fetcher.spec 'a_evil', 9
|
||||||
|
fetcher.spec 'b', 2
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:args] = %w[/[ab]/]
|
@cmd.options[:args] = %w[/[ab]/]
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
|
@ -105,10 +105,6 @@ Gem a-1
|
||||||
|
|
||||||
Gem a-2.a
|
Gem a-2.a
|
||||||
|
|
||||||
Gem a-2
|
|
||||||
|
|
||||||
Gem a-3.a
|
|
||||||
|
|
||||||
Gem a_evil-9
|
Gem a_evil-9
|
||||||
|
|
||||||
Gem b-2
|
Gem b-2
|
||||||
|
@ -187,7 +183,10 @@ ERROR: Only reverse dependencies for local gems are supported.
|
||||||
@fetcher = Gem::FakeFetcher.new
|
@fetcher = Gem::FakeFetcher.new
|
||||||
Gem::RemoteFetcher.fetcher = @fetcher
|
Gem::RemoteFetcher.fetcher = @fetcher
|
||||||
|
|
||||||
util_setup_spec_fetcher @a1, @a2
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
|
fetcher.spec 'a', 2
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:args] = %w[a]
|
@cmd.options[:args] = %w[a]
|
||||||
@cmd.options[:domain] = :remote
|
@cmd.options[:domain] = :remote
|
||||||
|
@ -202,11 +201,9 @@ ERROR: Only reverse dependencies for local gems are supported.
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_prerelease
|
def test_execute_prerelease
|
||||||
@fetcher = Gem::FakeFetcher.new
|
spec_fetcher do |fetcher|
|
||||||
Gem::RemoteFetcher.fetcher = @fetcher
|
fetcher.spec 'a', '2.a'
|
||||||
|
end
|
||||||
util_clear_gems
|
|
||||||
util_setup_spec_fetcher @a2_pre
|
|
||||||
|
|
||||||
@cmd.options[:args] = %w[a]
|
@cmd.options[:args] = %w[a]
|
||||||
@cmd.options[:domain] = :remote
|
@cmd.options[:domain] = :remote
|
||||||
|
|
|
@ -12,15 +12,13 @@ class TestGemCommandsFetchCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute
|
def test_execute
|
||||||
util_setup_fake_fetcher
|
specs = spec_fetcher do |fetcher|
|
||||||
util_setup_spec_fetcher @a2
|
fetcher.gem 'a', 2
|
||||||
|
end
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
|
|
||||||
File.read(@a2.cache_file)
|
|
||||||
|
|
||||||
refute_path_exists File.join(@tempdir, 'cache'), 'sanity check'
|
refute_path_exists File.join(@tempdir, 'cache'), 'sanity check'
|
||||||
|
|
||||||
@cmd.options[:args] = [@a2.name]
|
@cmd.options[:args] = %w[a]
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
Dir.chdir @tempdir do
|
Dir.chdir @tempdir do
|
||||||
|
@ -28,24 +26,23 @@ class TestGemCommandsFetchCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_path_exists(File.join(@tempdir, @a2.file_name),
|
a2 = specs['a-2']
|
||||||
"#{@a2.full_name} not fetched")
|
|
||||||
|
assert_path_exists(File.join(@tempdir, a2.file_name),
|
||||||
|
"#{a2.full_name} not fetched")
|
||||||
refute_path_exists File.join(@tempdir, 'cache'),
|
refute_path_exists File.join(@tempdir, 'cache'),
|
||||||
'gem repository directories must not be created'
|
'gem repository directories must not be created'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_latest
|
def test_execute_latest
|
||||||
util_setup_fake_fetcher
|
specs = spec_fetcher do |fetcher|
|
||||||
util_setup_spec_fetcher @a1, @a2
|
fetcher.gem 'a', 1
|
||||||
|
fetcher.gem 'a', 2
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
|
end
|
||||||
File.read(@a1.cache_file)
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
|
|
||||||
File.read(@a2.cache_file)
|
|
||||||
|
|
||||||
refute_path_exists File.join(@tempdir, 'cache'), 'sanity check'
|
refute_path_exists File.join(@tempdir, 'cache'), 'sanity check'
|
||||||
|
|
||||||
@cmd.options[:args] = [@a2.name]
|
@cmd.options[:args] = %w[a]
|
||||||
@cmd.options[:version] = req('>= 0.1')
|
@cmd.options[:version] = req('>= 0.1')
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
|
@ -54,23 +51,20 @@ class TestGemCommandsFetchCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_path_exists(File.join(@tempdir, @a2.file_name),
|
a2 = specs['a-2']
|
||||||
"#{@a2.full_name} not fetched")
|
assert_path_exists(File.join(@tempdir, a2.file_name),
|
||||||
|
"#{a2.full_name} not fetched")
|
||||||
refute_path_exists File.join(@tempdir, 'cache'),
|
refute_path_exists File.join(@tempdir, 'cache'),
|
||||||
'gem repository directories must not be created'
|
'gem repository directories must not be created'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_prerelease
|
def test_execute_prerelease
|
||||||
util_setup_fake_fetcher true
|
specs = spec_fetcher do |fetcher|
|
||||||
util_clear_gems
|
fetcher.gem 'a', 2
|
||||||
util_setup_spec_fetcher @a2, @a2_pre
|
fetcher.gem 'a', '2.a'
|
||||||
|
end
|
||||||
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
|
@cmd.options[:args] = %w[a]
|
||||||
File.read(@a2.cache_file)
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
|
|
||||||
File.read(@a2_pre.cache_file)
|
|
||||||
|
|
||||||
@cmd.options[:args] = [@a2.name]
|
|
||||||
@cmd.options[:prerelease] = true
|
@cmd.options[:prerelease] = true
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
|
@ -79,21 +73,19 @@ class TestGemCommandsFetchCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_path_exists(File.join(@tempdir, @a2.file_name),
|
a2 = specs['a-2']
|
||||||
"#{@a2.full_name} not fetched")
|
|
||||||
|
assert_path_exists(File.join(@tempdir, a2.file_name),
|
||||||
|
"#{a2.full_name} not fetched")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_specific_prerelease
|
def test_execute_specific_prerelease
|
||||||
util_setup_fake_fetcher true
|
specs = spec_fetcher do |fetcher|
|
||||||
util_clear_gems
|
fetcher.gem 'a', 2
|
||||||
util_setup_spec_fetcher @a2, @a2_pre
|
fetcher.gem 'a', '2.a'
|
||||||
|
end
|
||||||
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
|
@cmd.options[:args] = %w[a]
|
||||||
File.read(@a2.cache_file)
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
|
|
||||||
File.read(@a2_pre.cache_file)
|
|
||||||
|
|
||||||
@cmd.options[:args] = [@a2.name]
|
|
||||||
@cmd.options[:prerelease] = true
|
@cmd.options[:prerelease] = true
|
||||||
@cmd.options[:version] = "2.a"
|
@cmd.options[:version] = "2.a"
|
||||||
|
|
||||||
|
@ -103,18 +95,19 @@ class TestGemCommandsFetchCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_path_exists(File.join(@tempdir, @a2_pre.file_name),
|
a2_pre = specs['a-2.a']
|
||||||
"#{@a2_pre.full_name} not fetched")
|
|
||||||
|
assert_path_exists(File.join(@tempdir, a2_pre.file_name),
|
||||||
|
"#{a2_pre.full_name} not fetched")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_version
|
def test_execute_version
|
||||||
util_setup_fake_fetcher
|
specs = spec_fetcher do |fetcher|
|
||||||
util_setup_spec_fetcher @a1, @a2
|
fetcher.gem 'a', 1
|
||||||
|
fetcher.gem 'a', 2
|
||||||
|
end
|
||||||
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
|
@cmd.options[:args] = %w[a]
|
||||||
File.read(@a1.cache_file)
|
|
||||||
|
|
||||||
@cmd.options[:args] = [@a2.name]
|
|
||||||
@cmd.options[:version] = Gem::Requirement.new '1'
|
@cmd.options[:version] = Gem::Requirement.new '1'
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
|
@ -123,8 +116,10 @@ class TestGemCommandsFetchCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_path_exists(File.join(@tempdir, @a1.file_name),
|
a1 = specs['a-1']
|
||||||
"#{@a1.full_name} not fetched")
|
|
||||||
|
assert_path_exists(File.join(@tempdir, a1.file_name),
|
||||||
|
"#{a1.full_name} not fetched")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,15 +27,12 @@ class TestGemCommandsInstallCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_exclude_prerelease
|
def test_execute_exclude_prerelease
|
||||||
util_setup_fake_fetcher :prerelease
|
spec_fetcher do |fetcher|
|
||||||
util_setup_spec_fetcher
|
fetcher.gem 'a', 2
|
||||||
|
fetcher.gem 'a', '2.pre'
|
||||||
|
end
|
||||||
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
|
@cmd.options[:args] = %w[a]
|
||||||
read_binary(@a2.cache_file)
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
|
|
||||||
read_binary(@a2_pre.cache_file)
|
|
||||||
|
|
||||||
@cmd.options[:args] = [@a2.name]
|
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
|
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
|
||||||
|
@ -47,18 +44,17 @@ class TestGemCommandsInstallCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_explicit_version_includes_prerelease
|
def test_execute_explicit_version_includes_prerelease
|
||||||
util_setup_fake_fetcher :prerelease
|
specs = spec_fetcher do |fetcher|
|
||||||
util_setup_spec_fetcher
|
fetcher.gem 'a', 2
|
||||||
|
fetcher.gem 'a', '2.a'
|
||||||
|
end
|
||||||
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
|
a2_pre = specs['a-2.a']
|
||||||
read_binary(@a2.cache_file)
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
|
|
||||||
read_binary(@a2_pre.cache_file)
|
|
||||||
|
|
||||||
@cmd.handle_options [@a2_pre.name, '--version', @a2_pre.version.to_s,
|
@cmd.handle_options [a2_pre.name, '--version', a2_pre.version.to_s,
|
||||||
"--no-ri", "--no-rdoc"]
|
"--no-ri", "--no-rdoc"]
|
||||||
assert @cmd.options[:prerelease]
|
assert @cmd.options[:prerelease]
|
||||||
assert @cmd.options[:version].satisfied_by?(@a2_pre.version)
|
assert @cmd.options[:version].satisfied_by?(a2_pre.version)
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
|
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
|
||||||
|
@ -70,12 +66,15 @@ class TestGemCommandsInstallCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_local
|
def test_execute_local
|
||||||
util_setup_fake_fetcher
|
specs = spec_fetcher do |fetcher|
|
||||||
|
fetcher.gem 'a', 2
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:domain] = :local
|
@cmd.options[:domain] = :local
|
||||||
|
|
||||||
FileUtils.mv @a2.cache_file, @tempdir
|
FileUtils.mv specs['a-2'].cache_file, @tempdir
|
||||||
|
|
||||||
@cmd.options[:args] = [@a2.name]
|
@cmd.options[:args] = %w[a]
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
orig_dir = Dir.pwd
|
orig_dir = Dir.pwd
|
||||||
|
@ -97,12 +96,15 @@ class TestGemCommandsInstallCommand < Gem::TestCase
|
||||||
def test_execute_no_user_install
|
def test_execute_no_user_install
|
||||||
skip 'skipped on MS Windows (chmod has no effect)' if win_platform?
|
skip 'skipped on MS Windows (chmod has no effect)' if win_platform?
|
||||||
|
|
||||||
util_setup_fake_fetcher
|
specs = spec_fetcher do |fetcher|
|
||||||
|
fetcher.gem 'a', 2
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:user_install] = false
|
@cmd.options[:user_install] = false
|
||||||
|
|
||||||
FileUtils.mv @a2.cache_file, @tempdir
|
FileUtils.mv specs['a-2'].cache_file, @tempdir
|
||||||
|
|
||||||
@cmd.options[:args] = [@a2.name]
|
@cmd.options[:args] = %w[a]
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
orig_dir = Dir.pwd
|
orig_dir = Dir.pwd
|
||||||
|
@ -122,7 +124,8 @@ class TestGemCommandsInstallCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_local_missing
|
def test_execute_local_missing
|
||||||
util_setup_fake_fetcher
|
spec_fetcher
|
||||||
|
|
||||||
@cmd.options[:domain] = :local
|
@cmd.options[:domain] = :local
|
||||||
|
|
||||||
@cmd.options[:args] = %w[no_such_gem]
|
@cmd.options[:args] = %w[no_such_gem]
|
||||||
|
@ -147,8 +150,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_nonexistent
|
def test_execute_nonexistent
|
||||||
util_setup_fake_fetcher
|
spec_fetcher
|
||||||
util_setup_spec_fetcher
|
|
||||||
|
|
||||||
@cmd.options[:args] = %w[nonexistent]
|
@cmd.options[:args] = %w[nonexistent]
|
||||||
|
|
||||||
|
@ -163,8 +165,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_bad_source
|
def test_execute_bad_source
|
||||||
util_setup_fake_fetcher
|
spec_fetcher
|
||||||
util_setup_spec_fetcher
|
|
||||||
|
|
||||||
# This is needed because we need to exercise the cache path
|
# This is needed because we need to exercise the cache path
|
||||||
# within SpecFetcher
|
# within SpecFetcher
|
||||||
|
@ -197,8 +198,9 @@ class TestGemCommandsInstallCommand < Gem::TestCase
|
||||||
misspelled = "nonexistent_with_hint"
|
misspelled = "nonexistent_with_hint"
|
||||||
correctly_spelled = "non_existent_with_hint"
|
correctly_spelled = "non_existent_with_hint"
|
||||||
|
|
||||||
util_setup_fake_fetcher
|
spec_fetcher do |fetcher|
|
||||||
util_setup_spec_fetcher quick_spec(correctly_spelled, '2')
|
fetcher.spec correctly_spelled, 2
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:args] = [misspelled]
|
@cmd.options[:args] = [misspelled]
|
||||||
|
|
||||||
|
@ -221,8 +223,10 @@ ERROR: Possible alternatives: non_existent_with_hint
|
||||||
misspelled = "non-existent_with-hint"
|
misspelled = "non-existent_with-hint"
|
||||||
correctly_spelled = "nonexistent-with_hint"
|
correctly_spelled = "nonexistent-with_hint"
|
||||||
|
|
||||||
util_setup_fake_fetcher
|
spec_fetcher do |fetcher|
|
||||||
util_setup_spec_fetcher quick_spec(correctly_spelled, '2')
|
fetcher.spec correctly_spelled, 2
|
||||||
|
fetcher.clear
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:args] = [misspelled]
|
@cmd.options[:args] = [misspelled]
|
||||||
|
|
||||||
|
@ -257,17 +261,13 @@ ERROR: Possible alternatives: non_existent_with_hint
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_prerelease_skipped_when_no_flag_set
|
def test_execute_prerelease_skipped_when_no_flag_set
|
||||||
util_setup_fake_fetcher :prerelease
|
spec_fetcher do |fetcher|
|
||||||
util_clear_gems
|
fetcher.gem 'a', 1
|
||||||
util_setup_spec_fetcher @a1, @a2_pre
|
fetcher.gem 'a', '3.a'
|
||||||
|
end
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
|
|
||||||
read_binary(@a1.cache_file)
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
|
|
||||||
read_binary(@a2_pre.cache_file)
|
|
||||||
|
|
||||||
@cmd.options[:prerelease] = false
|
@cmd.options[:prerelease] = false
|
||||||
@cmd.options[:args] = [@a2_pre.name]
|
@cmd.options[:args] = %w[a]
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
|
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
|
||||||
|
@ -279,17 +279,14 @@ ERROR: Possible alternatives: non_existent_with_hint
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_prerelease_wins_over_previous_ver
|
def test_execute_prerelease_wins_over_previous_ver
|
||||||
util_setup_fake_fetcher :prerelease
|
spec_fetcher do |fetcher|
|
||||||
util_clear_gems
|
fetcher.gem 'a', 1
|
||||||
util_setup_spec_fetcher @a1, @a2_pre
|
fetcher.gem 'a', '2.a'
|
||||||
|
fetcher.clear
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
|
end
|
||||||
read_binary(@a1.cache_file)
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
|
|
||||||
read_binary(@a2_pre.cache_file)
|
|
||||||
|
|
||||||
@cmd.options[:prerelease] = true
|
@cmd.options[:prerelease] = true
|
||||||
@cmd.options[:args] = [@a2_pre.name]
|
@cmd.options[:args] = %w[a]
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
|
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
|
||||||
|
@ -301,17 +298,13 @@ ERROR: Possible alternatives: non_existent_with_hint
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_prerelease_skipped_when_non_pre_available
|
def test_execute_prerelease_skipped_when_non_pre_available
|
||||||
util_setup_fake_fetcher :prerelease
|
spec_fetcher do |fetcher|
|
||||||
util_clear_gems
|
fetcher.gem 'a', '2.pre'
|
||||||
util_setup_spec_fetcher @a2, @a2_pre
|
fetcher.gem 'a', 2
|
||||||
|
end
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
|
|
||||||
read_binary(@a2.cache_file)
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
|
|
||||||
read_binary(@a2_pre.cache_file)
|
|
||||||
|
|
||||||
@cmd.options[:prerelease] = true
|
@cmd.options[:prerelease] = true
|
||||||
@cmd.options[:args] = [@a2_pre.name]
|
@cmd.options[:args] = %w[a]
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
|
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
|
||||||
|
@ -323,16 +316,19 @@ ERROR: Possible alternatives: non_existent_with_hint
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_rdoc
|
def test_execute_rdoc
|
||||||
util_setup_fake_fetcher
|
specs = spec_fetcher do |fetcher|
|
||||||
|
fetcher.gem 'a', 2
|
||||||
|
end
|
||||||
|
|
||||||
Gem.done_installing(&Gem::RDoc.method(:generation_hook))
|
Gem.done_installing(&Gem::RDoc.method(:generation_hook))
|
||||||
|
|
||||||
@cmd.options[:document] = %w[rdoc ri]
|
@cmd.options[:document] = %w[rdoc ri]
|
||||||
@cmd.options[:domain] = :local
|
@cmd.options[:domain] = :local
|
||||||
|
|
||||||
FileUtils.mv @a2.cache_file, @tempdir
|
a2 = specs['a-2']
|
||||||
|
FileUtils.mv a2.cache_file, @tempdir
|
||||||
|
|
||||||
@cmd.options[:args] = [@a2.name]
|
@cmd.options[:args] = %w[a]
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
# Don't use Dir.chdir with a block, it warnings a lot because
|
# Don't use Dir.chdir with a block, it warnings a lot because
|
||||||
|
@ -351,22 +347,25 @@ ERROR: Possible alternatives: non_existent_with_hint
|
||||||
|
|
||||||
wait_for_child_process_to_exit
|
wait_for_child_process_to_exit
|
||||||
|
|
||||||
assert_path_exists File.join(@a2.doc_dir, 'ri')
|
assert_path_exists File.join(a2.doc_dir, 'ri')
|
||||||
assert_path_exists File.join(@a2.doc_dir, 'rdoc')
|
assert_path_exists File.join(a2.doc_dir, 'rdoc')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_saves_build_args
|
def test_execute_saves_build_args
|
||||||
util_setup_fake_fetcher
|
specs = spec_fetcher do |fetcher|
|
||||||
|
fetcher.gem 'a', 2
|
||||||
|
end
|
||||||
|
|
||||||
args = %w!--with-awesome=true --more-awesome=yes!
|
args = %w!--with-awesome=true --more-awesome=yes!
|
||||||
|
|
||||||
Gem::Command.build_args = args
|
Gem::Command.build_args = args
|
||||||
|
|
||||||
|
a2 = specs['a-2']
|
||||||
|
FileUtils.mv a2.cache_file, @tempdir
|
||||||
|
|
||||||
@cmd.options[:domain] = :local
|
@cmd.options[:domain] = :local
|
||||||
|
|
||||||
FileUtils.mv @a2.cache_file, @tempdir
|
@cmd.options[:args] = %w[a]
|
||||||
|
|
||||||
@cmd.options[:args] = [@a2.name]
|
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
# Don't use Dir.chdir with a block, it warnings a lot because
|
# Don't use Dir.chdir with a block, it warnings a lot because
|
||||||
|
@ -383,21 +382,19 @@ ERROR: Possible alternatives: non_existent_with_hint
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
path = @a2.build_info_file
|
path = a2.build_info_file
|
||||||
assert_path_exists path
|
assert_path_exists path
|
||||||
|
|
||||||
assert_equal args, @a2.build_args
|
assert_equal args, a2.build_args
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def test_execute_remote
|
def test_execute_remote
|
||||||
util_setup_fake_fetcher
|
spec_fetcher do |fetcher|
|
||||||
util_setup_spec_fetcher
|
fetcher.gem 'a', 2
|
||||||
|
end
|
||||||
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
|
@cmd.options[:args] = %w[a]
|
||||||
read_binary(@a2.cache_file)
|
|
||||||
|
|
||||||
@cmd.options[:args] = [@a2.name]
|
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
|
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
|
||||||
|
@ -411,17 +408,22 @@ ERROR: Possible alternatives: non_existent_with_hint
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_remote_ignores_files
|
def test_execute_remote_ignores_files
|
||||||
util_setup_fake_fetcher
|
specs = spec_fetcher do |fetcher|
|
||||||
util_setup_spec_fetcher
|
fetcher.gem 'a', 1
|
||||||
|
fetcher.gem 'a', 2
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:domain] = :remote
|
@cmd.options[:domain] = :remote
|
||||||
|
|
||||||
FileUtils.mv @a2.cache_file, @tempdir
|
a1 = specs['a-1']
|
||||||
|
a2 = specs['a-2']
|
||||||
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
|
FileUtils.mv a2.cache_file, @tempdir
|
||||||
read_binary(@a1.cache_file)
|
|
||||||
|
|
||||||
@cmd.options[:args] = [@a2.name]
|
@fetcher.data["#{@gem_repo}gems/#{a2.file_name}"] =
|
||||||
|
read_binary(a1.cache_file)
|
||||||
|
|
||||||
|
@cmd.options[:args] = [a2.name]
|
||||||
|
|
||||||
gemdir = File.join @gemhome, 'specifications'
|
gemdir = File.join @gemhome, 'specifications'
|
||||||
|
|
||||||
|
@ -451,14 +453,17 @@ ERROR: Possible alternatives: non_existent_with_hint
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_two
|
def test_execute_two
|
||||||
util_setup_fake_fetcher
|
specs = spec_fetcher do |fetcher|
|
||||||
|
fetcher.gem 'a', 2
|
||||||
|
fetcher.gem 'b', 2
|
||||||
|
end
|
||||||
|
|
||||||
|
FileUtils.mv specs['a-2'].cache_file, @tempdir
|
||||||
|
FileUtils.mv specs['b-2'].cache_file, @tempdir
|
||||||
|
|
||||||
@cmd.options[:domain] = :local
|
@cmd.options[:domain] = :local
|
||||||
|
|
||||||
FileUtils.mv @a2.cache_file, @tempdir
|
@cmd.options[:args] = %w[a b]
|
||||||
|
|
||||||
FileUtils.mv @b2.cache_file, @tempdir
|
|
||||||
|
|
||||||
@cmd.options[:args] = [@a2.name, @b2.name]
|
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
orig_dir = Dir.pwd
|
orig_dir = Dir.pwd
|
||||||
|
@ -498,17 +503,17 @@ ERROR: Possible alternatives: non_existent_with_hint
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_conservative
|
def test_execute_conservative
|
||||||
util_setup_fake_fetcher
|
spec_fetcher do |fetcher|
|
||||||
util_setup_spec_fetcher
|
fetcher.gem 'b', 2
|
||||||
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@b2.file_name}"] =
|
fetcher.clear
|
||||||
read_binary(@b2.cache_file)
|
|
||||||
|
|
||||||
uninstall_gem(@b2)
|
fetcher.gem 'a', 2
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:conservative] = true
|
@cmd.options[:conservative] = true
|
||||||
|
|
||||||
@cmd.options[:args] = [@a2.name, @b2.name]
|
@cmd.options[:args] = %w[a b]
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
orig_dir = Dir.pwd
|
orig_dir = Dir.pwd
|
||||||
|
@ -529,14 +534,14 @@ ERROR: Possible alternatives: non_existent_with_hint
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_parses_requirement_from_gemname
|
def test_parses_requirement_from_gemname
|
||||||
util_setup_fake_fetcher
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.gem 'a', 2
|
||||||
|
fetcher.gem 'b', 2
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:domain] = :local
|
@cmd.options[:domain] = :local
|
||||||
|
|
||||||
FileUtils.mv @a2.cache_file, @tempdir
|
req = "a:10.0"
|
||||||
|
|
||||||
FileUtils.mv @b2.cache_file, @tempdir
|
|
||||||
|
|
||||||
req = "#{@a2.name}:10.0"
|
|
||||||
|
|
||||||
@cmd.options[:args] = [req]
|
@cmd.options[:args] = [req]
|
||||||
|
|
||||||
|
@ -581,15 +586,14 @@ ERROR: Possible alternatives: non_existent_with_hint
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_source_problems_even_on_success
|
def test_show_source_problems_even_on_success
|
||||||
util_setup_fake_fetcher
|
spec_fetcher do |fetcher|
|
||||||
util_setup_spec_fetcher
|
fetcher.gem 'a', 2
|
||||||
|
fetcher.clear
|
||||||
|
end
|
||||||
|
|
||||||
Gem.sources << "http://nonexistent.example"
|
Gem.sources << "http://nonexistent.example"
|
||||||
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
|
@cmd.options[:args] = %w[a]
|
||||||
read_binary(@a2.cache_file)
|
|
||||||
|
|
||||||
@cmd.options[:args] = [@a2.name]
|
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
|
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
|
||||||
|
@ -608,11 +612,9 @@ ERROR: Possible alternatives: non_existent_with_hint
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_uses_from_a_gemdeps
|
def test_execute_uses_from_a_gemdeps
|
||||||
util_setup_fake_fetcher
|
spec_fetcher do |fetcher|
|
||||||
util_setup_spec_fetcher
|
fetcher.gem 'a', 2
|
||||||
|
end
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
|
|
||||||
read_binary(@a2.cache_file)
|
|
||||||
|
|
||||||
File.open @gemdeps, "w" do |f|
|
File.open @gemdeps, "w" do |f|
|
||||||
f << "gem 'a'"
|
f << "gem 'a'"
|
||||||
|
@ -632,12 +634,10 @@ ERROR: Possible alternatives: non_existent_with_hint
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_installs_from_a_gemdeps
|
def test_execute_installs_from_a_gemdeps
|
||||||
util_setup_fake_fetcher
|
spec_fetcher do |fetcher|
|
||||||
util_setup_spec_fetcher @a2
|
fetcher.gem 'a', 2
|
||||||
util_clear_gems
|
fetcher.clear
|
||||||
|
end
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
|
|
||||||
read_binary(@a2.cache_file)
|
|
||||||
|
|
||||||
File.open @gemdeps, "w" do |f|
|
File.open @gemdeps, "w" do |f|
|
||||||
f << "gem 'a'"
|
f << "gem 'a'"
|
||||||
|
@ -657,15 +657,11 @@ ERROR: Possible alternatives: non_existent_with_hint
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_installs_deps_a_gemdeps
|
def test_execute_installs_deps_a_gemdeps
|
||||||
q, q_gem = util_gem 'q', '1.0'
|
spec_fetcher do |fetcher|
|
||||||
r, r_gem = util_gem 'r', '2.0', 'q' => nil
|
fetcher.gem 'q', '1.0'
|
||||||
|
fetcher.gem 'r', '2.0', 'q' => nil
|
||||||
util_setup_fake_fetcher
|
fetcher.clear
|
||||||
util_setup_spec_fetcher q, r
|
end
|
||||||
util_clear_gems
|
|
||||||
|
|
||||||
add_to_fetcher q, q_gem
|
|
||||||
add_to_fetcher r, r_gem
|
|
||||||
|
|
||||||
File.open @gemdeps, "w" do |f|
|
File.open @gemdeps, "w" do |f|
|
||||||
f << "gem 'r'"
|
f << "gem 'r'"
|
||||||
|
@ -688,16 +684,13 @@ ERROR: Possible alternatives: non_existent_with_hint
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_uses_deps_a_gemdeps
|
def test_execute_uses_deps_a_gemdeps
|
||||||
q, _ = util_gem 'q', '1.0'
|
spec_fetcher do |fetcher|
|
||||||
r, r_gem = util_gem 'r', '2.0', 'q' => nil
|
fetcher.gem 'r', '2.0', 'q' => nil
|
||||||
|
|
||||||
util_setup_fake_fetcher
|
fetcher.clear
|
||||||
util_setup_spec_fetcher q, r
|
|
||||||
util_clear_gems
|
|
||||||
|
|
||||||
add_to_fetcher r, r_gem
|
fetcher.spec 'q', '1.0'
|
||||||
|
end
|
||||||
Gem::Specification.add_specs q
|
|
||||||
|
|
||||||
File.open @gemdeps, "w" do |f|
|
File.open @gemdeps, "w" do |f|
|
||||||
f << "gem 'r'"
|
f << "gem 'r'"
|
||||||
|
@ -720,15 +713,11 @@ ERROR: Possible alternatives: non_existent_with_hint
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_installs_deps_a_gemdeps_into_a_path
|
def test_execute_installs_deps_a_gemdeps_into_a_path
|
||||||
q, q_gem = util_gem 'q', '1.0'
|
spec_fetcher do |fetcher|
|
||||||
r, r_gem = util_gem 'r', '2.0', 'q' => nil
|
fetcher.gem 'q', '1.0'
|
||||||
|
fetcher.gem 'r', '2.0', 'q' => nil
|
||||||
util_setup_fake_fetcher
|
fetcher.clear
|
||||||
util_setup_spec_fetcher q, r
|
end
|
||||||
util_clear_gems
|
|
||||||
|
|
||||||
add_to_fetcher q, q_gem
|
|
||||||
add_to_fetcher r, r_gem
|
|
||||||
|
|
||||||
File.open @gemdeps, "w" do |f|
|
File.open @gemdeps, "w" do |f|
|
||||||
f << "gem 'r'"
|
f << "gem 'r'"
|
||||||
|
@ -755,17 +744,13 @@ ERROR: Possible alternatives: non_existent_with_hint
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_with_gemdeps_path_ignores_system
|
def test_execute_with_gemdeps_path_ignores_system
|
||||||
q, q_gem = util_gem 'q', '1.0'
|
specs = spec_fetcher do |fetcher|
|
||||||
r, r_gem = util_gem 'r', '2.0', 'q' => nil
|
fetcher.gem 'q', '1.0'
|
||||||
|
fetcher.gem 'r', '2.0', 'q' => nil
|
||||||
|
fetcher.clear
|
||||||
|
end
|
||||||
|
|
||||||
util_setup_fake_fetcher
|
Gem::Specification.add_specs specs['q-1.0']
|
||||||
util_setup_spec_fetcher q, r
|
|
||||||
util_clear_gems
|
|
||||||
|
|
||||||
add_to_fetcher q, q_gem
|
|
||||||
add_to_fetcher r, r_gem
|
|
||||||
|
|
||||||
Gem::Specification.add_specs q
|
|
||||||
|
|
||||||
File.open @gemdeps, "w" do |f|
|
File.open @gemdeps, "w" do |f|
|
||||||
f << "gem 'r'"
|
f << "gem 'r'"
|
||||||
|
@ -792,16 +777,12 @@ ERROR: Possible alternatives: non_existent_with_hint
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_uses_deps_a_gemdeps_with_a_path
|
def test_execute_uses_deps_a_gemdeps_with_a_path
|
||||||
q, q_gem = util_gem 'q', '1.0'
|
specs = spec_fetcher do |fetcher|
|
||||||
r, r_gem = util_gem 'r', '2.0', 'q' => nil
|
fetcher.gem 'q', '1.0'
|
||||||
|
fetcher.gem 'r', '2.0', 'q' => nil
|
||||||
|
end
|
||||||
|
|
||||||
util_setup_fake_fetcher
|
i = Gem::Installer.new specs['q-1.0'].cache_file, :install_dir => "gf-path"
|
||||||
util_setup_spec_fetcher q, r
|
|
||||||
util_clear_gems
|
|
||||||
|
|
||||||
add_to_fetcher r, r_gem
|
|
||||||
|
|
||||||
i = Gem::Installer.new q_gem, :install_dir => "gf-path"
|
|
||||||
i.install
|
i.install
|
||||||
|
|
||||||
assert File.file?("gf-path/specifications/q-1.0.gemspec"), "not installed"
|
assert File.file?("gf-path/specifications/q-1.0.gemspec"), "not installed"
|
||||||
|
|
|
@ -8,9 +8,9 @@ class TestGemCommandsListCommand < Gem::TestCase
|
||||||
|
|
||||||
@cmd = Gem::Commands::ListCommand.new
|
@cmd = Gem::Commands::ListCommand.new
|
||||||
|
|
||||||
util_setup_fake_fetcher
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'c', 1
|
||||||
@si = util_setup_spec_fetcher @a1, @a2, @pl1
|
end
|
||||||
|
|
||||||
@fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do
|
@fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do
|
||||||
raise Gem::RemoteFetcher::FetchError
|
raise Gem::RemoteFetcher::FetchError
|
||||||
|
|
|
@ -17,13 +17,11 @@ class TestGemCommandsOutdatedCommand < Gem::TestCase
|
||||||
spec_fetcher do |fetcher|
|
spec_fetcher do |fetcher|
|
||||||
fetcher.spec 'foo', '1.0'
|
fetcher.spec 'foo', '1.0'
|
||||||
fetcher.spec 'foo', '2.0'
|
fetcher.spec 'foo', '2.0'
|
||||||
|
fetcher.clear
|
||||||
|
fetcher.gem 'foo', '0.1'
|
||||||
|
fetcher.gem 'foo', '0.2'
|
||||||
end
|
end
|
||||||
|
|
||||||
quick_gem 'foo', '0.1'
|
|
||||||
quick_gem 'foo', '0.2'
|
|
||||||
|
|
||||||
Gem::Specification.reset
|
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute
|
def test_execute
|
||||||
a = quick_spec 'a' do |s|
|
a = util_spec 'a' do |s|
|
||||||
s.executables = %w[foo]
|
s.executables = %w[foo]
|
||||||
s.files = %w[bin/foo lib/a.rb]
|
s.files = %w[bin/foo lib/a.rb]
|
||||||
end
|
end
|
||||||
|
@ -51,7 +51,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_all
|
def test_execute_all
|
||||||
a = quick_spec 'a' do |s| s.executables = %w[foo] end
|
a = util_spec 'a' do |s| s.executables = %w[foo] end
|
||||||
write_file File.join(@tempdir, 'bin', 'foo') do |fp|
|
write_file File.join(@tempdir, 'bin', 'foo') do |fp|
|
||||||
fp.puts "#!/usr/bin/ruby"
|
fp.puts "#!/usr/bin/ruby"
|
||||||
end
|
end
|
||||||
|
@ -81,7 +81,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_env_shebang
|
def test_execute_env_shebang
|
||||||
a = quick_spec 'a' do |s|
|
a = util_spec 'a' do |s|
|
||||||
s.executables = %w[foo]
|
s.executables = %w[foo]
|
||||||
s.files = %w[bin/foo]
|
s.files = %w[bin/foo]
|
||||||
end
|
end
|
||||||
|
@ -111,7 +111,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_extensions_explicit
|
def test_execute_extensions_explicit
|
||||||
a = quick_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end
|
a = util_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end
|
||||||
|
|
||||||
ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb'
|
ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb'
|
||||||
write_file ext_path do |io|
|
write_file ext_path do |io|
|
||||||
|
@ -124,7 +124,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
b = quick_spec 'b'
|
b = util_spec 'b'
|
||||||
|
|
||||||
install_gem a
|
install_gem a
|
||||||
install_gem b
|
install_gem b
|
||||||
|
@ -147,7 +147,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_no_extension
|
def test_execute_no_extension
|
||||||
a = quick_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end
|
a = util_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end
|
||||||
|
|
||||||
ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb'
|
ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb'
|
||||||
write_file ext_path do |io|
|
write_file ext_path do |io|
|
||||||
|
@ -172,7 +172,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_with_extension_with_build_args
|
def test_execute_with_extension_with_build_args
|
||||||
a = quick_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end
|
a = util_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end
|
||||||
|
|
||||||
ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb'
|
ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb'
|
||||||
write_file ext_path do |io|
|
write_file ext_path do |io|
|
||||||
|
@ -205,8 +205,8 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_many
|
def test_execute_many
|
||||||
a = quick_spec 'a'
|
a = util_spec 'a'
|
||||||
b = quick_spec 'b'
|
b = util_spec 'b'
|
||||||
|
|
||||||
install_gem a
|
install_gem a
|
||||||
install_gem b
|
install_gem b
|
||||||
|
@ -226,14 +226,14 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_many_multi_repo
|
def test_execute_many_multi_repo
|
||||||
a = quick_spec 'a'
|
a = util_spec 'a'
|
||||||
install_gem a
|
install_gem a
|
||||||
|
|
||||||
Gem.clear_paths
|
Gem.clear_paths
|
||||||
gemhome2 = File.join @tempdir, 'gemhome2'
|
gemhome2 = File.join @tempdir, 'gemhome2'
|
||||||
Gem.paths = { "GEM_PATH" => [gemhome2, @gemhome], "GEM_HOME" => gemhome2 }
|
Gem.paths = { "GEM_PATH" => [gemhome2, @gemhome], "GEM_HOME" => gemhome2 }
|
||||||
|
|
||||||
b = quick_spec 'b'
|
b = util_spec 'b'
|
||||||
install_gem b
|
install_gem b
|
||||||
|
|
||||||
@cmd.options[:args] = %w[a b]
|
@cmd.options[:args] = %w[a b]
|
||||||
|
@ -256,24 +256,14 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_missing_cache_gem
|
def test_execute_missing_cache_gem
|
||||||
a_2 = quick_spec 'a', 2
|
specs = spec_fetcher do |fetcher|
|
||||||
a_3 = quick_spec 'a', 3
|
fetcher.gem 'a', 1
|
||||||
|
fetcher.gem 'a', 2
|
||||||
install_gem a_2
|
fetcher.gem 'a', 3
|
||||||
install_gem a_3
|
fetcher.gem 'a', '3.a'
|
||||||
|
|
||||||
a_2_data = nil
|
|
||||||
open File.join(@gemhome, 'cache', a_2.file_name), 'rb' do |fp|
|
|
||||||
a_2_data = fp.read
|
|
||||||
end
|
end
|
||||||
|
|
||||||
util_setup_fake_fetcher
|
FileUtils.rm specs['a-2'].cache_file
|
||||||
util_setup_spec_fetcher a_2
|
|
||||||
|
|
||||||
url = "http://gems.example.com/gems/#{a_2.file_name}"
|
|
||||||
Gem::RemoteFetcher.fetcher.data[url] = a_2_data
|
|
||||||
|
|
||||||
FileUtils.rm a_2.cache_file
|
|
||||||
|
|
||||||
@cmd.options[:args] = %w[a]
|
@cmd.options[:args] = %w[a]
|
||||||
|
|
||||||
|
@ -310,7 +300,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_only_executables
|
def test_execute_only_executables
|
||||||
a = quick_spec 'a' do |s|
|
a = util_spec 'a' do |s|
|
||||||
s.executables = %w[foo]
|
s.executables = %w[foo]
|
||||||
s.files = %w[bin/foo lib/a.rb]
|
s.files = %w[bin/foo lib/a.rb]
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,9 +8,11 @@ class TestGemCommandsQueryCommand < Gem::TestCase
|
||||||
|
|
||||||
@cmd = Gem::Commands::QueryCommand.new
|
@cmd = Gem::Commands::QueryCommand.new
|
||||||
|
|
||||||
util_setup_fake_fetcher
|
@specs = spec_fetcher do |fetcher|
|
||||||
util_clear_gems
|
fetcher.spec 'a', 1
|
||||||
util_setup_spec_fetcher @a1, @a2, @pl1, @a3a
|
fetcher.spec 'a', 2
|
||||||
|
fetcher.spec 'a', '3.a'
|
||||||
|
end
|
||||||
|
|
||||||
@fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do
|
@fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do
|
||||||
raise Gem::RemoteFetcher::FetchError
|
raise Gem::RemoteFetcher::FetchError
|
||||||
|
@ -18,6 +20,10 @@ class TestGemCommandsQueryCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute
|
def test_execute
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.handle_options %w[-r]
|
@cmd.handle_options %w[-r]
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
|
@ -37,13 +43,18 @@ pl (1 i386-linux)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_platform
|
def test_execute_platform
|
||||||
@a1r = @a1.dup
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.clear
|
||||||
|
|
||||||
@a1.platform = 'x86-linux'
|
fetcher.spec 'a', 1
|
||||||
@a2.platform = 'universal-darwin'
|
fetcher.spec 'a', 1 do |s|
|
||||||
|
s.platform = 'x86-linux'
|
||||||
|
end
|
||||||
|
|
||||||
util_clear_gems
|
fetcher.spec 'a', 2 do |s|
|
||||||
util_setup_spec_fetcher @a1, @a1r, @a2, @b2, @pl1
|
s.platform = 'universal-darwin'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.handle_options %w[-r -a]
|
@cmd.handle_options %w[-r -a]
|
||||||
|
|
||||||
|
@ -56,8 +67,6 @@ pl (1 i386-linux)
|
||||||
*** REMOTE GEMS ***
|
*** REMOTE GEMS ***
|
||||||
|
|
||||||
a (2 universal-darwin, 1 ruby x86-linux)
|
a (2 universal-darwin, 1 ruby x86-linux)
|
||||||
b (2)
|
|
||||||
pl (1 i386-linux)
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
assert_equal expected, @ui.output
|
assert_equal expected, @ui.output
|
||||||
|
@ -65,6 +74,10 @@ pl (1 i386-linux)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_all
|
def test_execute_all
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.handle_options %w[-r --all]
|
@cmd.handle_options %w[-r --all]
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
|
@ -84,6 +97,10 @@ pl (1 i386-linux)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_all_prerelease
|
def test_execute_all_prerelease
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.handle_options %w[-r --all --prerelease]
|
@cmd.handle_options %w[-r --all --prerelease]
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
|
@ -103,12 +120,15 @@ pl (1 i386-linux)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_details
|
def test_execute_details
|
||||||
@a2.summary = 'This is a lot of text. ' * 4
|
spec_fetcher do |fetcher|
|
||||||
@a2.authors = ['Abraham Lincoln', 'Hirohito']
|
fetcher.spec 'a', 2 do |s|
|
||||||
@a2.homepage = 'http://a.example.com/'
|
s.summary = 'This is a lot of text. ' * 4
|
||||||
|
s.authors = ['Abraham Lincoln', 'Hirohito']
|
||||||
|
s.homepage = 'http://a.example.com/'
|
||||||
|
end
|
||||||
|
|
||||||
util_clear_gems
|
fetcher.legacy_platform
|
||||||
util_setup_spec_fetcher @a1, @a2, @pl1
|
end
|
||||||
|
|
||||||
@cmd.handle_options %w[-r -d]
|
@cmd.handle_options %w[-r -d]
|
||||||
|
|
||||||
|
@ -140,15 +160,22 @@ pl (1)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_details_platform
|
def test_execute_details_platform
|
||||||
@a1.platform = 'x86-linux'
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.clear
|
||||||
|
|
||||||
@a2.summary = 'This is a lot of text. ' * 4
|
fetcher.spec 'a', 1 do |s|
|
||||||
@a2.authors = ['Abraham Lincoln', 'Hirohito']
|
s.platform = 'x86-linux'
|
||||||
@a2.homepage = 'http://a.example.com/'
|
end
|
||||||
@a2.platform = 'universal-darwin'
|
|
||||||
|
|
||||||
util_clear_gems
|
fetcher.spec 'a', 2 do |s|
|
||||||
util_setup_spec_fetcher @a1, @a2, @pl1
|
s.summary = 'This is a lot of text. ' * 4
|
||||||
|
s.authors = ['Abraham Lincoln', 'Hirohito']
|
||||||
|
s.homepage = 'http://a.example.com/'
|
||||||
|
s.platform = 'universal-darwin'
|
||||||
|
end
|
||||||
|
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.handle_options %w[-r -d]
|
@cmd.handle_options %w[-r -d]
|
||||||
|
|
||||||
|
@ -282,6 +309,10 @@ pl (1)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_local
|
def test_execute_local
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:domain] = :local
|
@cmd.options[:domain] = :local
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
|
@ -301,6 +332,10 @@ pl (1 i386-linux)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_local_notty
|
def test_execute_local_notty
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.handle_options %w[]
|
@cmd.handle_options %w[]
|
||||||
|
|
||||||
@ui.outs.tty = false
|
@ui.outs.tty = false
|
||||||
|
@ -319,6 +354,10 @@ pl (1 i386-linux)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_local_quiet
|
def test_execute_local_quiet
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:domain] = :local
|
@cmd.options[:domain] = :local
|
||||||
Gem.configuration.verbose = false
|
Gem.configuration.verbose = false
|
||||||
|
|
||||||
|
@ -336,6 +375,10 @@ pl (1 i386-linux)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_no_versions
|
def test_execute_no_versions
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.handle_options %w[-r --no-versions]
|
@cmd.handle_options %w[-r --no-versions]
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
|
@ -355,6 +398,10 @@ pl
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_notty
|
def test_execute_notty
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.handle_options %w[-r]
|
@cmd.handle_options %w[-r]
|
||||||
|
|
||||||
@ui.outs.tty = false
|
@ui.outs.tty = false
|
||||||
|
@ -391,6 +438,10 @@ a (3.a)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_prerelease_local
|
def test_execute_prerelease_local
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.handle_options %w[-l --prerelease]
|
@cmd.handle_options %w[-l --prerelease]
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
|
@ -410,6 +461,10 @@ pl (1 i386-linux)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_remote
|
def test_execute_remote
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:domain] = :remote
|
@cmd.options[:domain] = :remote
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
|
@ -429,6 +484,10 @@ pl (1 i386-linux)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_remote_notty
|
def test_execute_remote_notty
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.handle_options %w[]
|
@cmd.handle_options %w[]
|
||||||
|
|
||||||
@ui.outs.tty = false
|
@ui.outs.tty = false
|
||||||
|
@ -447,6 +506,10 @@ pl (1 i386-linux)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_remote_quiet
|
def test_execute_remote_quiet
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:domain] = :remote
|
@cmd.options[:domain] = :remote
|
||||||
Gem.configuration.verbose = false
|
Gem.configuration.verbose = false
|
||||||
|
|
||||||
|
@ -464,15 +527,22 @@ pl (1 i386-linux)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_local_details
|
def test_execute_local_details
|
||||||
@a1.platform = 'x86-linux'
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.clear
|
||||||
|
|
||||||
@a2.summary = 'This is a lot of text. ' * 4
|
fetcher.spec 'a', 1 do |s|
|
||||||
@a2.authors = ['Abraham Lincoln', 'Hirohito']
|
s.platform = 'x86-linux'
|
||||||
@a2.homepage = 'http://a.example.com/'
|
end
|
||||||
@a2.platform = 'universal-darwin'
|
|
||||||
|
|
||||||
util_clear_gems
|
fetcher.spec 'a', 2 do |s|
|
||||||
util_setup_spec_fetcher @a1, @a2, @pl1
|
s.summary = 'This is a lot of text. ' * 4
|
||||||
|
s.authors = ['Abraham Lincoln', 'Hirohito']
|
||||||
|
s.homepage = 'http://a.example.com/'
|
||||||
|
s.platform = 'universal-darwin'
|
||||||
|
end
|
||||||
|
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.handle_options %w[-l -d]
|
@cmd.handle_options %w[-l -d]
|
||||||
|
|
||||||
|
@ -486,6 +556,7 @@ pl (1 i386-linux)
|
||||||
str.gsub!(/at: [^\n]*/, "at: -")
|
str.gsub!(/at: [^\n]*/, "at: -")
|
||||||
|
|
||||||
expected = <<-EOF
|
expected = <<-EOF
|
||||||
|
|
||||||
*** LOCAL GEMS ***
|
*** LOCAL GEMS ***
|
||||||
|
|
||||||
a (2, 1)
|
a (2, 1)
|
||||||
|
@ -500,7 +571,7 @@ a (2, 1)
|
||||||
This is a lot of text. This is a lot of text. This is a lot of text.
|
This is a lot of text. This is a lot of text. This is a lot of text.
|
||||||
This is a lot of text.
|
This is a lot of text.
|
||||||
|
|
||||||
pl \(1\)
|
pl (1)
|
||||||
Platform: i386-linux
|
Platform: i386-linux
|
||||||
Author: A User
|
Author: A User
|
||||||
Homepage: http://example.com
|
Homepage: http://example.com
|
||||||
|
@ -509,13 +580,18 @@ pl \(1\)
|
||||||
this is a summary
|
this is a summary
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
assert_match expected, @ui.output
|
assert_equal expected, @ui.output
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_default_details
|
def test_execute_default_details
|
||||||
default_gem_dir = Gem::Specification.default_specifications_dir
|
spec_fetcher do |fetcher|
|
||||||
@a1.loaded_from =
|
fetcher.clear
|
||||||
File.join default_gem_dir, @a1.spec_name
|
|
||||||
|
fetcher.spec 'a', 2
|
||||||
|
end
|
||||||
|
|
||||||
|
a1 = new_default_spec 'a', 1
|
||||||
|
install_default_specs a1
|
||||||
|
|
||||||
@cmd.handle_options %w[-l -d]
|
@cmd.handle_options %w[-l -d]
|
||||||
|
|
||||||
|
@ -527,20 +603,11 @@ pl \(1\)
|
||||||
|
|
||||||
*** LOCAL GEMS ***
|
*** LOCAL GEMS ***
|
||||||
|
|
||||||
a (3.a, 2, 1)
|
a (2, 1)
|
||||||
Author: A User
|
Author: A User
|
||||||
Homepage: http://example.com
|
Homepage: http://example.com
|
||||||
Installed at (3.a): #{@gemhome}
|
Installed at (2): #{@gemhome}
|
||||||
(2): #{@gemhome}
|
(1, default): #{a1.base_dir}
|
||||||
(1, default): #{@a1.base_dir}
|
|
||||||
|
|
||||||
this is a summary
|
|
||||||
|
|
||||||
pl \(1\)
|
|
||||||
Platform: i386-linux
|
|
||||||
Author: A User
|
|
||||||
Homepage: http://example.com
|
|
||||||
Installed at: #{@gemhome}
|
|
||||||
|
|
||||||
this is a summary
|
this is a summary
|
||||||
EOF
|
EOF
|
||||||
|
@ -549,15 +616,18 @@ pl \(1\)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_make_entry
|
def test_make_entry
|
||||||
@fetcher.data.delete \
|
a_2_name = @specs['a-2'].original_name
|
||||||
"#{@gem_repo}quick/Marshal.#{Gem.marshal_version}/#{@a2.original_name}.gemspec.rz"
|
|
||||||
|
|
||||||
|
@fetcher.data.delete \
|
||||||
|
"#{@gem_repo}quick/Marshal.#{Gem.marshal_version}/#{a_2_name}.gemspec.rz"
|
||||||
|
|
||||||
|
a2 = @specs['a-2']
|
||||||
entry_tuples = [
|
entry_tuples = [
|
||||||
[Gem::NameTuple.new(@a2.name, @a2.version, @a2.platform),
|
[Gem::NameTuple.new(a2.name, a2.version, a2.platform),
|
||||||
Gem.sources.first],
|
Gem.sources.first],
|
||||||
]
|
]
|
||||||
|
|
||||||
platforms = { @a2.version => [@a2.platform] }
|
platforms = { a2.version => [a2.platform] }
|
||||||
|
|
||||||
entry = @cmd.send :make_entry, entry_tuples, platforms
|
entry = @cmd.send :make_entry, entry_tuples, platforms
|
||||||
|
|
||||||
|
@ -566,6 +636,10 @@ pl \(1\)
|
||||||
|
|
||||||
# Test for multiple args handling!
|
# Test for multiple args handling!
|
||||||
def test_execute_multiple_args
|
def test_execute_multiple_args
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.handle_options %w[a pl]
|
@cmd.handle_options %w[a pl]
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
|
|
|
@ -6,7 +6,7 @@ class TestGemCommandsSourcesCommand < Gem::TestCase
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
|
|
||||||
util_setup_fake_fetcher
|
spec_fetcher
|
||||||
|
|
||||||
@cmd = Gem::Commands::SourcesCommand.new
|
@cmd = Gem::Commands::SourcesCommand.new
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ class TestGemCommandsSourcesCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute
|
def test_execute
|
||||||
util_setup_spec_fetcher
|
|
||||||
@cmd.handle_options []
|
@cmd.handle_options []
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
|
@ -36,9 +35,9 @@ class TestGemCommandsSourcesCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_add
|
def test_execute_add
|
||||||
util_setup_fake_fetcher
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
install_specs @a1
|
end
|
||||||
|
|
||||||
specs = Gem::Specification.map { |spec|
|
specs = Gem::Specification.map { |spec|
|
||||||
[spec.name, spec.version, spec.original_platform]
|
[spec.name, spec.version, spec.original_platform]
|
||||||
|
@ -54,8 +53,6 @@ class TestGemCommandsSourcesCommand < Gem::TestCase
|
||||||
|
|
||||||
@cmd.handle_options %W[--add #{@new_repo}]
|
@cmd.handle_options %W[--add #{@new_repo}]
|
||||||
|
|
||||||
util_setup_spec_fetcher
|
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
@ -71,19 +68,13 @@ class TestGemCommandsSourcesCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_add_nonexistent_source
|
def test_execute_add_nonexistent_source
|
||||||
util_setup_fake_fetcher
|
|
||||||
|
|
||||||
uri = "http://beta-gems.example.com/specs.#{@marshal_version}.gz"
|
uri = "http://beta-gems.example.com/specs.#{@marshal_version}.gz"
|
||||||
@fetcher.data[uri] = proc do
|
@fetcher.data[uri] = proc do
|
||||||
raise Gem::RemoteFetcher::FetchError.new('it died', uri)
|
raise Gem::RemoteFetcher::FetchError.new('it died', uri)
|
||||||
end
|
end
|
||||||
|
|
||||||
Gem::RemoteFetcher.fetcher = @fetcher
|
|
||||||
|
|
||||||
@cmd.handle_options %w[--add http://beta-gems.example.com]
|
@cmd.handle_options %w[--add http://beta-gems.example.com]
|
||||||
|
|
||||||
util_setup_spec_fetcher
|
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
assert_raises Gem::MockGemUi::TermError do
|
assert_raises Gem::MockGemUi::TermError do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
|
@ -102,8 +93,6 @@ Error fetching http://beta-gems.example.com:
|
||||||
def test_execute_add_redundant_source
|
def test_execute_add_redundant_source
|
||||||
@cmd.handle_options %W[--add #{@gem_repo}]
|
@cmd.handle_options %W[--add #{@gem_repo}]
|
||||||
|
|
||||||
util_setup_spec_fetcher
|
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
@ -120,9 +109,10 @@ source #{@gem_repo} already present in the cache
|
||||||
|
|
||||||
def test_execute_add_http_rubygems_org
|
def test_execute_add_http_rubygems_org
|
||||||
http_rubygems_org = 'http://rubygems.org'
|
http_rubygems_org = 'http://rubygems.org'
|
||||||
util_setup_fake_fetcher
|
|
||||||
|
|
||||||
install_specs @a1
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
|
end
|
||||||
|
|
||||||
specs = Gem::Specification.map { |spec|
|
specs = Gem::Specification.map { |spec|
|
||||||
[spec.name, spec.version, spec.original_platform]
|
[spec.name, spec.version, spec.original_platform]
|
||||||
|
@ -138,8 +128,6 @@ source #{@gem_repo} already present in the cache
|
||||||
|
|
||||||
@cmd.handle_options %W[--add #{http_rubygems_org}]
|
@cmd.handle_options %W[--add #{http_rubygems_org}]
|
||||||
|
|
||||||
util_setup_spec_fetcher
|
|
||||||
|
|
||||||
ui = Gem::MockGemUi.new "n"
|
ui = Gem::MockGemUi.new "n"
|
||||||
|
|
||||||
use_ui ui do
|
use_ui ui do
|
||||||
|
@ -160,8 +148,6 @@ source #{@gem_repo} already present in the cache
|
||||||
def test_execute_add_bad_uri
|
def test_execute_add_bad_uri
|
||||||
@cmd.handle_options %w[--add beta-gems.example.com]
|
@cmd.handle_options %w[--add beta-gems.example.com]
|
||||||
|
|
||||||
util_setup_spec_fetcher
|
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
assert_raises Gem::MockGemUi::TermError do
|
assert_raises Gem::MockGemUi::TermError do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
|
@ -181,8 +167,6 @@ beta-gems.example.com is not a URI
|
||||||
def test_execute_clear_all
|
def test_execute_clear_all
|
||||||
@cmd.handle_options %w[--clear-all]
|
@cmd.handle_options %w[--clear-all]
|
||||||
|
|
||||||
util_setup_spec_fetcher
|
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
@ -218,8 +202,6 @@ beta-gems.example.com is not a URI
|
||||||
def test_execute_remove
|
def test_execute_remove
|
||||||
@cmd.handle_options %W[--remove #{@gem_repo}]
|
@cmd.handle_options %W[--remove #{@gem_repo}]
|
||||||
|
|
||||||
util_setup_spec_fetcher
|
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
@ -233,8 +215,6 @@ beta-gems.example.com is not a URI
|
||||||
def test_execute_remove_no_network
|
def test_execute_remove_no_network
|
||||||
@cmd.handle_options %W[--remove #{@gem_repo}]
|
@cmd.handle_options %W[--remove #{@gem_repo}]
|
||||||
|
|
||||||
util_setup_fake_fetcher
|
|
||||||
|
|
||||||
@fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do
|
@fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do
|
||||||
raise Gem::RemoteFetcher::FetchError
|
raise Gem::RemoteFetcher::FetchError
|
||||||
end
|
end
|
||||||
|
@ -252,22 +232,9 @@ beta-gems.example.com is not a URI
|
||||||
def test_execute_update
|
def test_execute_update
|
||||||
@cmd.handle_options %w[--update]
|
@cmd.handle_options %w[--update]
|
||||||
|
|
||||||
util_setup_fake_fetcher
|
spec_fetcher do |fetcher|
|
||||||
util_setup_spec_fetcher @a1
|
fetcher.gem 'a', 1
|
||||||
|
end
|
||||||
specs = Gem::Specification.map { |spec|
|
|
||||||
[spec.name, spec.version, spec.original_platform]
|
|
||||||
}
|
|
||||||
|
|
||||||
@fetcher.data["#{@gem_repo}specs.#{Gem.marshal_version}.gz"] =
|
|
||||||
util_gzip Marshal.dump(specs)
|
|
||||||
|
|
||||||
latest_specs = Gem::Specification.latest_specs.map { |spec|
|
|
||||||
[spec.name, spec.version, spec.original_platform]
|
|
||||||
}
|
|
||||||
|
|
||||||
@fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] =
|
|
||||||
util_gzip Marshal.dump(latest_specs)
|
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
|
|
|
@ -10,7 +10,7 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute
|
def test_execute
|
||||||
foo = quick_spec 'foo'
|
foo = util_spec 'foo'
|
||||||
|
|
||||||
install_specs foo
|
install_specs foo
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_all
|
def test_execute_all
|
||||||
quick_spec 'foo', '0.0.1'
|
util_spec 'foo', '0.0.1'
|
||||||
quick_spec 'foo', '0.0.2'
|
util_spec 'foo', '0.0.2'
|
||||||
|
|
||||||
@cmd.options[:args] = %w[foo]
|
@cmd.options[:args] = %w[foo]
|
||||||
@cmd.options[:all] = true
|
@cmd.options[:all] = true
|
||||||
|
@ -44,8 +44,8 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_all_conflicts_with_version
|
def test_execute_all_conflicts_with_version
|
||||||
quick_spec 'foo', '0.0.1'
|
util_spec 'foo', '0.0.1'
|
||||||
quick_spec 'foo', '0.0.2'
|
util_spec 'foo', '0.0.2'
|
||||||
|
|
||||||
@cmd.options[:args] = %w[foo]
|
@cmd.options[:args] = %w[foo]
|
||||||
@cmd.options[:all] = true
|
@cmd.options[:all] = true
|
||||||
|
@ -89,8 +89,8 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_exact_match
|
def test_execute_exact_match
|
||||||
quick_spec 'foo'
|
util_spec 'foo'
|
||||||
quick_spec 'foo_bar'
|
util_spec 'foo_bar'
|
||||||
|
|
||||||
@cmd.options[:args] = %w[foo]
|
@cmd.options[:args] = %w[foo]
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_file
|
def test_execute_file
|
||||||
foo = quick_spec 'foo' do |s|
|
foo = util_spec 'foo' do |s|
|
||||||
s.files = %w[lib/code.rb]
|
s.files = %w[lib/code.rb]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -188,10 +188,8 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
|
||||||
|
|
||||||
def test_execute_remote_without_prerelease
|
def test_execute_remote_without_prerelease
|
||||||
spec_fetcher do |fetcher|
|
spec_fetcher do |fetcher|
|
||||||
foo = fetcher.spec 'foo', '2.0.0'
|
fetcher.spec 'foo', '2.0.0'
|
||||||
foo_pre = fetcher.spec 'foo', '2.0.1.pre'
|
fetcher.spec 'foo', '2.0.1.pre'
|
||||||
|
|
||||||
install_specs foo, foo_pre
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@cmd.options[:args] = %w[foo]
|
@cmd.options[:args] = %w[foo]
|
||||||
|
@ -211,10 +209,8 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
|
||||||
|
|
||||||
def test_execute_remote_with_prerelease
|
def test_execute_remote_with_prerelease
|
||||||
spec_fetcher do |fetcher|
|
spec_fetcher do |fetcher|
|
||||||
foo = fetcher.spec 'foo', '2.0.0'
|
fetcher.spec 'foo', '2.0.0'
|
||||||
foo_pre = fetcher.spec 'foo', '2.0.1.pre'
|
fetcher.spec 'foo', '2.0.1.pre'
|
||||||
|
|
||||||
install_specs foo, foo_pre
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@cmd.options[:args] = %w[foo]
|
@cmd.options[:args] = %w[foo]
|
||||||
|
@ -234,7 +230,7 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_ruby
|
def test_execute_ruby
|
||||||
foo = quick_spec 'foo'
|
foo = util_spec 'foo'
|
||||||
|
|
||||||
install_specs foo
|
install_specs foo
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,11 @@ class TestGemCommandsStaleCommand < Gem::TestCase
|
||||||
|
|
||||||
def test_execute_sorts
|
def test_execute_sorts
|
||||||
files = %w[lib/foo_bar.rb Rakefile]
|
files = %w[lib/foo_bar.rb Rakefile]
|
||||||
foo_bar = quick_spec 'foo_bar' do |gem|
|
foo_bar = util_spec 'foo_bar' do |gem|
|
||||||
gem.files = files
|
gem.files = files
|
||||||
end
|
end
|
||||||
|
|
||||||
bar_baz = quick_spec 'bar_baz' do |gem|
|
bar_baz = util_spec 'bar_baz' do |gem|
|
||||||
gem.files = files
|
gem.files = files
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
|
||||||
|
|
||||||
gemhome2 = "#{@gemhome}2"
|
gemhome2 = "#{@gemhome}2"
|
||||||
|
|
||||||
a_4 = quick_spec 'a', 4
|
a_4 = util_spec 'a', 4
|
||||||
install_gem a_4, :install_dir => gemhome2
|
install_gem a_4, :install_dir => gemhome2
|
||||||
|
|
||||||
Gem::Specification.dirs = [@gemhome, gemhome2]
|
Gem::Specification.dirs = [@gemhome, gemhome2]
|
||||||
|
@ -126,7 +126,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_prerelease
|
def test_execute_prerelease
|
||||||
@spec = quick_spec "pre", "2.b"
|
@spec = util_spec "pre", "2.b"
|
||||||
@gem = File.join @tempdir, @spec.file_name
|
@gem = File.join @tempdir, @spec.file_name
|
||||||
FileUtils.touch @gem
|
FileUtils.touch @gem
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
|
||||||
|
|
||||||
gemhome2 = "#{@gemhome}2"
|
gemhome2 = "#{@gemhome}2"
|
||||||
|
|
||||||
a_4 = quick_spec 'a', 4
|
a_4 = util_spec 'a', 4
|
||||||
install_gem a_4, :install_dir => gemhome2
|
install_gem a_4, :install_dir => gemhome2
|
||||||
|
|
||||||
Gem::Specification.dirs = [@gemhome, gemhome2]
|
Gem::Specification.dirs = [@gemhome, gemhome2]
|
||||||
|
|
|
@ -22,31 +22,22 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_path
|
def test_get_path
|
||||||
util_setup_fake_fetcher
|
specs = spec_fetcher do |fetcher|
|
||||||
util_clear_gems
|
fetcher.gem 'a', 1
|
||||||
util_setup_spec_fetcher @a1
|
|
||||||
|
|
||||||
a1_data = nil
|
|
||||||
|
|
||||||
open @a1.cache_file, 'rb' do |fp|
|
|
||||||
a1_data = fp.read
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Gem::RemoteFetcher.fetcher.data['http://gems.example.com/gems/a-1.gem'] =
|
dep = Gem::Dependency.new 'a', 1
|
||||||
a1_data
|
|
||||||
|
|
||||||
dep = Gem::Dependency.new(@a1.name, @a1.version)
|
|
||||||
assert_equal(
|
assert_equal(
|
||||||
@cmd.get_path(dep),
|
@cmd.get_path(dep),
|
||||||
@a1.cache_file,
|
specs['a-1'].cache_file,
|
||||||
'fetches a-1 and returns the cache path'
|
'fetches a-1 and returns the cache path'
|
||||||
)
|
)
|
||||||
|
|
||||||
FileUtils.rm @a1.cache_file
|
FileUtils.rm specs['a-1'].cache_file
|
||||||
|
|
||||||
assert_equal(
|
assert_equal(
|
||||||
@cmd.get_path(dep),
|
@cmd.get_path(dep),
|
||||||
@a1.cache_file,
|
specs['a-1'].cache_file,
|
||||||
'when removed from cache, refetches a-1'
|
'when removed from cache, refetches a-1'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -67,8 +58,9 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_gem_path
|
def test_execute_gem_path
|
||||||
util_setup_fake_fetcher
|
spec_fetcher do |fetcher|
|
||||||
util_setup_spec_fetcher
|
fetcher.gem 'a', '3.a'
|
||||||
|
end
|
||||||
|
|
||||||
Gem.clear_paths
|
Gem.clear_paths
|
||||||
|
|
||||||
|
@ -88,8 +80,7 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_gem_path_missing
|
def test_execute_gem_path_missing
|
||||||
util_setup_fake_fetcher
|
spec_fetcher
|
||||||
util_setup_spec_fetcher
|
|
||||||
|
|
||||||
Gem.clear_paths
|
Gem.clear_paths
|
||||||
|
|
||||||
|
@ -109,18 +100,13 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_remote
|
def test_execute_remote
|
||||||
util_setup_fake_fetcher
|
spec_fetcher do |fetcher|
|
||||||
util_setup_spec_fetcher @a1, @a2
|
fetcher.spec 'a', 1
|
||||||
util_clear_gems
|
fetcher.gem 'a', 2
|
||||||
|
|
||||||
a2_data = nil
|
fetcher.clear
|
||||||
open @a2.cache_file, 'rb' do |fp|
|
|
||||||
a2_data = fp.read
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Gem::RemoteFetcher.fetcher.data['http://gems.example.com/gems/a-2.gem'] =
|
|
||||||
a2_data
|
|
||||||
|
|
||||||
Gem.configuration.verbose = :really
|
Gem.configuration.verbose = :really
|
||||||
@cmd.options[:args] = %w[a]
|
@cmd.options[:args] = %w[a]
|
||||||
|
|
||||||
|
@ -186,8 +172,8 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_exact_match
|
def test_execute_exact_match
|
||||||
foo_spec = quick_spec 'foo'
|
foo_spec = util_spec 'foo'
|
||||||
foo_bar_spec = quick_spec 'foo_bar'
|
foo_bar_spec = util_spec 'foo_bar'
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
Dir.chdir @tempdir do
|
Dir.chdir @tempdir do
|
||||||
|
|
|
@ -17,26 +17,27 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
||||||
|
|
||||||
@cmd.options[:document] = []
|
@cmd.options[:document] = []
|
||||||
|
|
||||||
util_setup_fake_fetcher(true)
|
@specs = spec_fetcher do |fetcher|
|
||||||
util_clear_gems
|
fetcher.gem 'a', 1
|
||||||
util_setup_spec_fetcher @a1, @a2, @a3a
|
fetcher.gem 'a', 2
|
||||||
|
fetcher.gem 'a', '3.a'
|
||||||
|
|
||||||
@a1_path = @a1.cache_file
|
fetcher.clear
|
||||||
@a2_path = @a2.cache_file
|
end
|
||||||
@a3a_path = @a3a.cache_file
|
|
||||||
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{File.basename @a1_path}"] =
|
@a1_path = @specs['a-1'].cache_file
|
||||||
read_binary @a1_path
|
@a2_path = @specs['a-1'].cache_file
|
||||||
@fetcher.data["#{@gem_repo}gems/#{File.basename @a2_path}"] =
|
@a3a_path = @specs['a-3.a'].cache_file
|
||||||
read_binary @a2_path
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{File.basename @a3a_path}"] =
|
|
||||||
read_binary @a3a_path
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute
|
def test_execute
|
||||||
util_clear_gems
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.gem 'a', 2
|
||||||
|
|
||||||
Gem::Installer.new(@a1_path).install
|
fetcher.clear
|
||||||
|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:args] = []
|
@cmd.options[:args] = []
|
||||||
|
|
||||||
|
@ -46,48 +47,17 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
||||||
|
|
||||||
out = @ui.output.split "\n"
|
out = @ui.output.split "\n"
|
||||||
assert_equal "Updating installed gems", out.shift
|
assert_equal "Updating installed gems", out.shift
|
||||||
assert_equal "Updating #{@a2.name}", out.shift
|
assert_equal "Updating a", out.shift
|
||||||
assert_equal "Gems updated: #{@a2.name}", out.shift
|
assert_equal "Gems updated: a", out.shift
|
||||||
assert_empty out
|
assert_empty out
|
||||||
end
|
end
|
||||||
|
|
||||||
def util_setup_rubygem version
|
|
||||||
gem = quick_spec('rubygems-update', version.to_s) do |s|
|
|
||||||
s.files = %w[setup.rb]
|
|
||||||
end
|
|
||||||
write_file File.join(*%W[gems #{gem.original_name} setup.rb])
|
|
||||||
util_build_gem gem
|
|
||||||
util_setup_spec_fetcher gem
|
|
||||||
gem
|
|
||||||
end
|
|
||||||
|
|
||||||
def util_setup_rubygem8
|
|
||||||
@rubygem8 = util_setup_rubygem 8
|
|
||||||
end
|
|
||||||
|
|
||||||
def util_setup_rubygem9
|
|
||||||
@rubygem9 = util_setup_rubygem 9
|
|
||||||
end
|
|
||||||
|
|
||||||
def util_setup_rubygem_current
|
|
||||||
@rubygem_current = util_setup_rubygem Gem::VERSION
|
|
||||||
end
|
|
||||||
|
|
||||||
def util_add_to_fetcher *specs
|
|
||||||
specs.each do |spec|
|
|
||||||
gem_file = spec.cache_file
|
|
||||||
file_name = File.basename gem_file
|
|
||||||
|
|
||||||
@fetcher.data["http://gems.example.com/gems/#{file_name}"] =
|
|
||||||
Gem.read_binary gem_file
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_execute_system
|
def test_execute_system
|
||||||
util_clear_gems
|
spec_fetcher do |fetcher|
|
||||||
util_setup_rubygem9
|
fetcher.gem 'rubygems-update', 9 do |s| s.files = %w[setup.rb] end
|
||||||
util_setup_spec_fetcher @rubygem9
|
|
||||||
util_add_to_fetcher @rubygem9
|
fetcher.clear
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:args] = []
|
@cmd.options[:args] = []
|
||||||
@cmd.options[:system] = true
|
@cmd.options[:system] = true
|
||||||
|
@ -105,10 +75,13 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_system_at_latest
|
def test_execute_system_at_latest
|
||||||
util_clear_gems
|
spec_fetcher do |fetcher|
|
||||||
util_setup_rubygem_current
|
fetcher.gem 'rubygems-update', Gem::VERSION do |s|
|
||||||
util_setup_spec_fetcher @rubygem_current
|
s.files = %w[setup.rb]
|
||||||
util_add_to_fetcher @rubygem_current
|
end
|
||||||
|
|
||||||
|
fetcher.clear
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:args] = []
|
@cmd.options[:args] = []
|
||||||
@cmd.options[:system] = true
|
@cmd.options[:system] = true
|
||||||
|
@ -125,11 +98,12 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_system_multiple
|
def test_execute_system_multiple
|
||||||
util_clear_gems
|
spec_fetcher do |fetcher|
|
||||||
util_setup_rubygem9
|
fetcher.gem 'rubygems-update', 8 do |s| s.files = %w[setup.rb] end
|
||||||
util_setup_rubygem8
|
fetcher.gem 'rubygems-update', 9 do |s| s.files = %w[setup.rb] end
|
||||||
util_setup_spec_fetcher @rubygem8, @rubygem9
|
|
||||||
util_add_to_fetcher @rubygem8, @rubygem9
|
fetcher.clear
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:args] = []
|
@cmd.options[:args] = []
|
||||||
@cmd.options[:system] = true
|
@cmd.options[:system] = true
|
||||||
|
@ -147,11 +121,12 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_system_specific
|
def test_execute_system_specific
|
||||||
util_clear_gems
|
spec_fetcher do |fetcher|
|
||||||
util_setup_rubygem9
|
fetcher.gem 'rubygems-update', 8 do |s| s.files = %w[setup.rb] end
|
||||||
util_setup_rubygem8
|
fetcher.gem 'rubygems-update', 9 do |s| s.files = %w[setup.rb] end
|
||||||
util_setup_spec_fetcher @rubygem8, @rubygem9
|
|
||||||
util_add_to_fetcher @rubygem8, @rubygem9
|
fetcher.clear
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:args] = []
|
@cmd.options[:args] = []
|
||||||
@cmd.options[:system] = "8"
|
@cmd.options[:system] = "8"
|
||||||
|
@ -169,11 +144,12 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_system_specifically_to_latest_version
|
def test_execute_system_specifically_to_latest_version
|
||||||
util_clear_gems
|
spec_fetcher do |fetcher|
|
||||||
util_setup_rubygem9
|
fetcher.gem 'rubygems-update', 8 do |s| s.files = %w[setup.rb] end
|
||||||
util_setup_rubygem8
|
fetcher.gem 'rubygems-update', 9 do |s| s.files = %w[setup.rb] end
|
||||||
util_setup_spec_fetcher @rubygem8, @rubygem9
|
|
||||||
util_add_to_fetcher @rubygem8, @rubygem9
|
fetcher.clear
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:args] = []
|
@cmd.options[:args] = []
|
||||||
@cmd.options[:system] = "9"
|
@cmd.options[:system] = "9"
|
||||||
|
@ -212,37 +188,17 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
||||||
# a2 -> c2
|
# a2 -> c2
|
||||||
|
|
||||||
def test_execute_dependencies
|
def test_execute_dependencies
|
||||||
@a1.add_dependency 'c', '1.2'
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.gem 'a', 2, 'b' => 2, 'c' => 2
|
||||||
|
fetcher.gem 'b', 2
|
||||||
|
fetcher.gem 'c', 2
|
||||||
|
|
||||||
@c2 = quick_spec 'c', '2' do |s|
|
fetcher.clear
|
||||||
s.files = %w[lib/code.rb]
|
|
||||||
s.require_paths = %w[lib]
|
fetcher.spec 'a', 1, 'c' => '1.2'
|
||||||
|
fetcher.spec 'c', '1.2'
|
||||||
end
|
end
|
||||||
|
|
||||||
@a2.add_dependency 'c', '2'
|
|
||||||
@a2.add_dependency 'b', '2'
|
|
||||||
|
|
||||||
@b2_path = @b2.cache_file
|
|
||||||
@c1_2_path = @c1_2.cache_file
|
|
||||||
@c2_path = @c2.cache_file
|
|
||||||
|
|
||||||
install_specs @a1, @a2, @b2, @c1_2, @c2
|
|
||||||
|
|
||||||
util_build_gem @a1
|
|
||||||
util_build_gem @a2
|
|
||||||
util_build_gem @c2
|
|
||||||
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] = read_binary @a1_path
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] = read_binary @a2_path
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@b2.file_name}"] = read_binary @b2_path
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@c1_2.file_name}"] = read_binary @c1_2_path
|
|
||||||
@fetcher.data["#{@gem_repo}gems/#{@c2.file_name}"] = read_binary @c2_path
|
|
||||||
|
|
||||||
util_setup_spec_fetcher @a1, @a2, @b2, @c1_2, @c2
|
|
||||||
|
|
||||||
Gem::Installer.new(@c1_2_path).install
|
|
||||||
Gem::Installer.new(@a1_path).install
|
|
||||||
|
|
||||||
Gem::Specification.reset
|
Gem::Specification.reset
|
||||||
|
|
||||||
@cmd.options[:args] = []
|
@cmd.options[:args] = []
|
||||||
|
@ -253,23 +209,27 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
||||||
|
|
||||||
out = @ui.output.split "\n"
|
out = @ui.output.split "\n"
|
||||||
assert_equal "Updating installed gems", out.shift
|
assert_equal "Updating installed gems", out.shift
|
||||||
assert_equal "Updating #{@a2.name}", out.shift
|
assert_equal "Updating a", out.shift
|
||||||
assert_equal "Gems updated: #{@a2.name} #{@b2.name} #{@c2.name}",
|
assert_equal "Gems updated: a b c",
|
||||||
out.shift
|
out.shift
|
||||||
|
|
||||||
assert_empty out
|
assert_empty out
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_rdoc
|
def test_execute_rdoc
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.gem 'a', 2
|
||||||
|
|
||||||
|
fetcher.clear
|
||||||
|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
|
end
|
||||||
|
|
||||||
Gem.done_installing(&Gem::RDoc.method(:generation_hook))
|
Gem.done_installing(&Gem::RDoc.method(:generation_hook))
|
||||||
|
|
||||||
@cmd.options[:document] = %w[rdoc ri]
|
@cmd.options[:document] = %w[rdoc ri]
|
||||||
|
|
||||||
util_clear_gems
|
@cmd.options[:args] = %w[a]
|
||||||
|
|
||||||
Gem::Installer.new(@a1_path).install
|
|
||||||
|
|
||||||
@cmd.options[:args] = [@a1.name]
|
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
|
@ -277,16 +237,22 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
||||||
|
|
||||||
wait_for_child_process_to_exit
|
wait_for_child_process_to_exit
|
||||||
|
|
||||||
assert_path_exists File.join(@a2.doc_dir, 'ri')
|
a2 = @specs['a-2']
|
||||||
assert_path_exists File.join(@a2.doc_dir, 'rdoc')
|
|
||||||
|
assert_path_exists File.join(a2.doc_dir, 'ri')
|
||||||
|
assert_path_exists File.join(a2.doc_dir, 'rdoc')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_named
|
def test_execute_named
|
||||||
util_clear_gems
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.gem 'a', 2
|
||||||
|
|
||||||
Gem::Installer.new(@a1_path).install
|
fetcher.clear
|
||||||
|
|
||||||
@cmd.options[:args] = [@a1.name]
|
fetcher.spec 'a', 1
|
||||||
|
end
|
||||||
|
|
||||||
|
@cmd.options[:args] = %w[a]
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
|
@ -294,18 +260,18 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
||||||
|
|
||||||
out = @ui.output.split "\n"
|
out = @ui.output.split "\n"
|
||||||
assert_equal "Updating installed gems", out.shift
|
assert_equal "Updating installed gems", out.shift
|
||||||
assert_equal "Updating #{@a2.name}", out.shift
|
assert_equal "Updating a", out.shift
|
||||||
assert_equal "Gems updated: #{@a2.name}", out.shift
|
assert_equal "Gems updated: a", out.shift
|
||||||
|
|
||||||
assert_empty out
|
assert_empty out
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_named_up_to_date
|
def test_execute_named_up_to_date
|
||||||
util_clear_gems
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'a', 2
|
||||||
|
end
|
||||||
|
|
||||||
Gem::Installer.new(@a2_path).install
|
@cmd.options[:args] = %w[a]
|
||||||
|
|
||||||
@cmd.options[:args] = [@a2.name]
|
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
|
@ -319,11 +285,15 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_named_up_to_date_prerelease
|
def test_execute_named_up_to_date_prerelease
|
||||||
util_clear_gems
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.gem 'a', '3.a'
|
||||||
|
|
||||||
Gem::Installer.new(@a2_path).install
|
fetcher.clear
|
||||||
|
|
||||||
@cmd.options[:args] = [@a2.name]
|
fetcher.gem 'a', 2
|
||||||
|
end
|
||||||
|
|
||||||
|
@cmd.options[:args] = %w[a]
|
||||||
@cmd.options[:prerelease] = true
|
@cmd.options[:prerelease] = true
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
|
@ -332,16 +302,16 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
||||||
|
|
||||||
out = @ui.output.split "\n"
|
out = @ui.output.split "\n"
|
||||||
assert_equal "Updating installed gems", out.shift
|
assert_equal "Updating installed gems", out.shift
|
||||||
assert_equal "Updating #{@a3a.name}", out.shift
|
assert_equal "Updating a", out.shift
|
||||||
assert_equal "Gems updated: #{@a3a.name}", out.shift
|
assert_equal "Gems updated: a", out.shift
|
||||||
|
|
||||||
assert_empty out
|
assert_empty out
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_up_to_date
|
def test_execute_up_to_date
|
||||||
util_clear_gems
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.gem 'a', 2
|
||||||
Gem::Installer.new(@a2_path).install
|
end
|
||||||
|
|
||||||
@cmd.options[:args] = []
|
@cmd.options[:args] = []
|
||||||
|
|
||||||
|
@ -357,9 +327,13 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_user_install
|
def test_execute_user_install
|
||||||
util_clear_gems
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.gem 'a', 2
|
||||||
|
|
||||||
Gem::Installer.new(@a1_path).install
|
fetcher.clear
|
||||||
|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.handle_options %w[--user-install]
|
@cmd.handle_options %w[--user-install]
|
||||||
|
|
||||||
|
@ -374,37 +348,51 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fetch_remote_gems
|
def test_fetch_remote_gems
|
||||||
|
specs = spec_fetcher do |fetcher|
|
||||||
|
fetcher.gem 'a', 1
|
||||||
|
fetcher.gem 'a', 2
|
||||||
|
end
|
||||||
|
|
||||||
expected = [
|
expected = [
|
||||||
[Gem::NameTuple.new('a', v(2), Gem::Platform::RUBY),
|
[Gem::NameTuple.new('a', v(2), Gem::Platform::RUBY),
|
||||||
Gem::Source.new(@gem_repo)],
|
Gem::Source.new(@gem_repo)],
|
||||||
]
|
]
|
||||||
|
|
||||||
assert_equal expected, @cmd.fetch_remote_gems(@a1)
|
assert_equal expected, @cmd.fetch_remote_gems(specs['a-1'])
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fetch_remote_gems_error
|
def test_fetch_remote_gems_error
|
||||||
Gem.sources.replace %w[http://nonexistent.example]
|
Gem.sources.replace %w[http://nonexistent.example]
|
||||||
|
|
||||||
assert_raises Gem::RemoteFetcher::FetchError do
|
assert_raises Gem::RemoteFetcher::FetchError do
|
||||||
@cmd.fetch_remote_gems @a1
|
@cmd.fetch_remote_gems @specs['a-1']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fetch_remote_gems_mismatch
|
def test_fetch_remote_gems_mismatch
|
||||||
platform = Gem::Platform.new 'x86-freebsd9'
|
platform = Gem::Platform.new 'x86-freebsd9'
|
||||||
a2_p = quick_spec 'a', 2 do |s| s.platform = platform end
|
|
||||||
|
|
||||||
util_setup_spec_fetcher @a2, a2_p
|
specs = spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
|
fetcher.spec 'a', 2
|
||||||
|
fetcher.spec 'a', 2 do |s| s.platform = platform end
|
||||||
|
end
|
||||||
|
|
||||||
expected = [
|
expected = [
|
||||||
[Gem::NameTuple.new('a', v(2), Gem::Platform::RUBY),
|
[Gem::NameTuple.new('a', v(2), Gem::Platform::RUBY),
|
||||||
Gem::Source.new(@gem_repo)],
|
Gem::Source.new(@gem_repo)],
|
||||||
]
|
]
|
||||||
|
|
||||||
assert_equal expected, @cmd.fetch_remote_gems(@a1)
|
assert_equal expected, @cmd.fetch_remote_gems(specs['a-1'])
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fetch_remote_gems_prerelease
|
def test_fetch_remote_gems_prerelease
|
||||||
|
specs = spec_fetcher do |fetcher|
|
||||||
|
fetcher.gem 'a', 1
|
||||||
|
fetcher.gem 'a', 2
|
||||||
|
fetcher.gem 'a', '3.a'
|
||||||
|
end
|
||||||
|
|
||||||
@cmd.options[:prerelease] = true
|
@cmd.options[:prerelease] = true
|
||||||
|
|
||||||
expected = [
|
expected = [
|
||||||
|
@ -414,7 +402,7 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
||||||
Gem::Source.new(@gem_repo)],
|
Gem::Source.new(@gem_repo)],
|
||||||
]
|
]
|
||||||
|
|
||||||
assert_equal expected, @cmd.fetch_remote_gems(@a1)
|
assert_equal expected, @cmd.fetch_remote_gems(specs['a-1'])
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_handle_options_system
|
def test_handle_options_system
|
||||||
|
|
|
@ -68,7 +68,7 @@ class TestGemCommandsWhichCommand < Gem::TestCase
|
||||||
|
|
||||||
def util_foo_bar
|
def util_foo_bar
|
||||||
files = %w[lib/foo_bar.rb lib/directory/baz.rb Rakefile]
|
files = %w[lib/foo_bar.rb lib/directory/baz.rb Rakefile]
|
||||||
@foo_bar = quick_spec 'foo_bar' do |gem|
|
@foo_bar = util_spec 'foo_bar' do |gem|
|
||||||
gem.files = files
|
gem.files = files
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,17 +11,17 @@ class TestGemDependencyList < Gem::TestCase
|
||||||
@deplist = Gem::DependencyList.new
|
@deplist = Gem::DependencyList.new
|
||||||
|
|
||||||
# TODO: switch to new_spec
|
# TODO: switch to new_spec
|
||||||
@a1 = quick_spec 'a', '1'
|
@a1 = util_spec 'a', '1'
|
||||||
@a2 = quick_spec 'a', '2'
|
@a2 = util_spec 'a', '2'
|
||||||
@a3 = quick_spec 'a', '3'
|
@a3 = util_spec 'a', '3'
|
||||||
|
|
||||||
@b1 = quick_spec 'b', '1' do |s| s.add_dependency 'a', '>= 1' end
|
@b1 = util_spec 'b', '1' do |s| s.add_dependency 'a', '>= 1' end
|
||||||
@b2 = quick_spec 'b', '2' do |s| s.add_dependency 'a', '>= 1' end
|
@b2 = util_spec 'b', '2' do |s| s.add_dependency 'a', '>= 1' end
|
||||||
|
|
||||||
@c1 = quick_spec 'c', '1' do |s| s.add_dependency 'b', '>= 1' end
|
@c1 = util_spec 'c', '1' do |s| s.add_dependency 'b', '>= 1' end
|
||||||
@c2 = quick_spec 'c', '2'
|
@c2 = util_spec 'c', '2'
|
||||||
|
|
||||||
@d1 = quick_spec 'd', '1' do |s| s.add_dependency 'c', '>= 1' end
|
@d1 = util_spec 'd', '1' do |s| s.add_dependency 'c', '>= 1' end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_active_count
|
def test_active_count
|
||||||
|
@ -57,9 +57,9 @@ class TestGemDependencyList < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_dependency_order_development
|
def test_dependency_order_development
|
||||||
e1 = quick_spec 'e', '1'
|
e1 = util_spec 'e', '1'
|
||||||
f1 = quick_spec 'f', '1'
|
f1 = util_spec 'f', '1'
|
||||||
g1 = quick_spec 'g', '1'
|
g1 = util_spec 'g', '1'
|
||||||
|
|
||||||
@a1.add_dependency 'e'
|
@a1.add_dependency 'e'
|
||||||
@a1.add_dependency 'f'
|
@a1.add_dependency 'f'
|
||||||
|
@ -85,7 +85,7 @@ class TestGemDependencyList < Gem::TestCase
|
||||||
|
|
||||||
def test_dependency_order_diamond
|
def test_dependency_order_diamond
|
||||||
util_diamond
|
util_diamond
|
||||||
e1 = quick_spec 'e', '1'
|
e1 = util_spec 'e', '1'
|
||||||
@deplist.add e1
|
@deplist.add e1
|
||||||
@a1.add_dependency 'e', '>= 1'
|
@a1.add_dependency 'e', '>= 1'
|
||||||
|
|
||||||
|
@ -161,13 +161,13 @@ class TestGemDependencyList < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_ok_eh_mismatch
|
def test_ok_eh_mismatch
|
||||||
a1 = quick_spec 'a', '1'
|
a1 = util_spec 'a', '1'
|
||||||
a2 = quick_spec 'a', '2'
|
a2 = util_spec 'a', '2'
|
||||||
|
|
||||||
b = quick_spec 'b', '1' do |s| s.add_dependency 'a', '= 1' end
|
b = util_spec 'b', '1' do |s| s.add_dependency 'a', '= 1' end
|
||||||
c = quick_spec 'c', '1' do |s| s.add_dependency 'a', '= 2' end
|
c = util_spec 'c', '1' do |s| s.add_dependency 'a', '= 2' end
|
||||||
|
|
||||||
d = quick_spec 'd', '1' do |s|
|
d = util_spec 'd', '1' do |s|
|
||||||
s.add_dependency 'b'
|
s.add_dependency 'b'
|
||||||
s.add_dependency 'c'
|
s.add_dependency 'c'
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,7 @@ class TestGemDependencyResolutionError < Gem::TestCase
|
||||||
|
|
||||||
@DR = Gem::DependencyResolver
|
@DR = Gem::DependencyResolver
|
||||||
|
|
||||||
@spec = quick_spec 'a', 2
|
@spec = util_spec 'a', 2
|
||||||
|
|
||||||
@a1_req = @DR::DependencyRequest.new dep('a', '= 1'), nil
|
@a1_req = @DR::DependencyRequest.new dep('a', '= 1'), nil
|
||||||
@a2_req = @DR::DependencyRequest.new dep('a', '= 2'), nil
|
@a2_req = @DR::DependencyRequest.new dep('a', '= 2'), nil
|
||||||
|
|
|
@ -510,9 +510,9 @@ class TestGemDependencyResolver < Gem::TestCase
|
||||||
def test_select_local_platforms
|
def test_select_local_platforms
|
||||||
r = Gem::DependencyResolver.new nil, nil
|
r = Gem::DependencyResolver.new nil, nil
|
||||||
|
|
||||||
a1 = quick_spec 'a', 1
|
a1 = util_spec 'a', 1
|
||||||
a1_p1 = quick_spec 'a', 1 do |s| s.platform = Gem::Platform.local end
|
a1_p1 = util_spec 'a', 1 do |s| s.platform = Gem::Platform.local end
|
||||||
a1_p2 = quick_spec 'a', 1 do |s| s.platform = 'unknown' end
|
a1_p2 = util_spec 'a', 1 do |s| s.platform = 'unknown' end
|
||||||
|
|
||||||
selected = r.select_local_platforms [a1, a1_p1, a1_p2]
|
selected = r.select_local_platforms [a1, a1_p1, a1_p2]
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ class TestGemDependencyResolverDependencyConflict < Gem::TestCase
|
||||||
def test_explanation_user_request
|
def test_explanation_user_request
|
||||||
@DR = Gem::DependencyResolver
|
@DR = Gem::DependencyResolver
|
||||||
|
|
||||||
spec = quick_spec 'a', 2
|
spec = util_spec 'a', 2
|
||||||
|
|
||||||
a1_req = @DR::DependencyRequest.new dep('a', '= 1'), nil
|
a1_req = @DR::DependencyRequest.new dep('a', '= 1'), nil
|
||||||
a2_req = @DR::DependencyRequest.new dep('a', '= 2'), nil
|
a2_req = @DR::DependencyRequest.new dep('a', '= 2'), nil
|
||||||
|
|
|
@ -31,11 +31,9 @@ class TestGemDependencyResolverIndexSpecification < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_spec
|
def test_spec
|
||||||
a_2_p = nil
|
specs = spec_fetcher do |fetcher|
|
||||||
|
|
||||||
spec_fetcher do |fetcher|
|
|
||||||
fetcher.spec 'a', 2
|
fetcher.spec 'a', 2
|
||||||
a_2_p = fetcher.spec 'a', 2 do |s| s.platform = Gem::Platform.local end
|
fetcher.spec 'a', 2 do |s| s.platform = Gem::Platform.local end
|
||||||
end
|
end
|
||||||
|
|
||||||
source = Gem::Source.new @gem_repo
|
source = Gem::Source.new @gem_repo
|
||||||
|
@ -47,11 +45,11 @@ class TestGemDependencyResolverIndexSpecification < Gem::TestCase
|
||||||
|
|
||||||
spec = i_spec.spec
|
spec = i_spec.spec
|
||||||
|
|
||||||
assert_equal a_2_p.full_name, spec.full_name
|
assert_equal specs["a-2-#{Gem::Platform.local}"].full_name, spec.full_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_spec_local
|
def test_spec_local
|
||||||
a_2_p = quick_spec 'a', 2 do |s| s.platform = Gem::Platform.local end
|
a_2_p = util_spec 'a', 2 do |s| s.platform = Gem::Platform.local end
|
||||||
Gem::Package.build a_2_p
|
Gem::Package.build a_2_p
|
||||||
|
|
||||||
source = Gem::Source::Local.new
|
source = Gem::Source::Local.new
|
||||||
|
|
|
@ -6,7 +6,7 @@ class TestGemDependencyResolverInstalledSpecification < Gem::TestCase
|
||||||
def test_initialize
|
def test_initialize
|
||||||
set = Gem::DependencyResolver::CurrentSet.new
|
set = Gem::DependencyResolver::CurrentSet.new
|
||||||
|
|
||||||
source_spec = quick_spec 'a'
|
source_spec = util_spec 'a'
|
||||||
|
|
||||||
spec = Gem::DependencyResolver::InstalledSpecification.new set, source_spec
|
spec = Gem::DependencyResolver::InstalledSpecification.new set, source_spec
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,9 @@ require 'rubygems/dependency_resolver'
|
||||||
class TestGemDependencyResolverInstallerSet < Gem::TestCase
|
class TestGemDependencyResolverInstallerSet < Gem::TestCase
|
||||||
|
|
||||||
def test_load_spec
|
def test_load_spec
|
||||||
a_2_p = nil
|
specs = spec_fetcher do |fetcher|
|
||||||
|
|
||||||
spec_fetcher do |fetcher|
|
|
||||||
fetcher.spec 'a', 2
|
fetcher.spec 'a', 2
|
||||||
a_2_p = fetcher.spec 'a', 2 do |s| s.platform = Gem::Platform.local end
|
fetcher.spec 'a', 2 do |s| s.platform = Gem::Platform.local end
|
||||||
end
|
end
|
||||||
|
|
||||||
source = Gem::Source.new @gem_repo
|
source = Gem::Source.new @gem_repo
|
||||||
|
@ -18,7 +16,7 @@ class TestGemDependencyResolverInstallerSet < Gem::TestCase
|
||||||
|
|
||||||
spec = set.load_spec 'a', version, Gem::Platform.local, source
|
spec = set.load_spec 'a', version, Gem::Platform.local, source
|
||||||
|
|
||||||
assert_equal a_2_p.full_name, spec.full_name
|
assert_equal specs["a-2-#{Gem::Platform.local}"].full_name, spec.full_name
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -157,7 +157,7 @@ This directory does not appear to be a RubyGems repository, skipping
|
||||||
|
|
||||||
refute doctor.gem_repository?, 'no gems installed'
|
refute doctor.gem_repository?, 'no gems installed'
|
||||||
|
|
||||||
quick_spec 'a'
|
util_spec 'a'
|
||||||
|
|
||||||
doctor = Gem::Doctor.new @gemhome
|
doctor = Gem::Doctor.new @gemhome
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ class TestGemExtBuilder < Gem::TestCase
|
||||||
|
|
||||||
@orig_DESTDIR = ENV['DESTDIR']
|
@orig_DESTDIR = ENV['DESTDIR']
|
||||||
|
|
||||||
@spec = quick_spec 'a'
|
@spec = util_spec 'a'
|
||||||
|
|
||||||
@builder = Gem::Ext::Builder.new @spec, ''
|
@builder = Gem::Ext::Builder.new @spec, ''
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,15 +13,15 @@ class TestGemIndexer < Gem::TestCase
|
||||||
util_clear_gems
|
util_clear_gems
|
||||||
util_make_gems
|
util_make_gems
|
||||||
|
|
||||||
@d2_0 = quick_spec 'd', '2.0' do |s|
|
@d2_0 = util_spec 'd', '2.0' do |s|
|
||||||
s.date = Gem::Specification::TODAY - 86400 * 3
|
s.date = Gem::Specification::TODAY - 86400 * 3
|
||||||
end
|
end
|
||||||
util_build_gem @d2_0
|
util_build_gem @d2_0
|
||||||
|
|
||||||
@d2_0_a = quick_spec 'd', '2.0.a'
|
@d2_0_a = util_spec 'd', '2.0.a'
|
||||||
util_build_gem @d2_0_a
|
util_build_gem @d2_0_a
|
||||||
|
|
||||||
@d2_0_b = quick_spec 'd', '2.0.b'
|
@d2_0_b = util_spec 'd', '2.0.b'
|
||||||
util_build_gem @d2_0_b
|
util_build_gem @d2_0_b
|
||||||
|
|
||||||
@default = new_default_spec 'default', 2
|
@default = new_default_spec 'default', 2
|
||||||
|
@ -292,7 +292,7 @@ class TestGemIndexer < Gem::TestCase
|
||||||
def with_system_gems
|
def with_system_gems
|
||||||
Gem::Specification.reset
|
Gem::Specification.reset
|
||||||
|
|
||||||
sys_gem = quick_spec 'systemgem', '1.0'
|
sys_gem = util_spec 'systemgem', '1.0'
|
||||||
util_build_gem sys_gem
|
util_build_gem sys_gem
|
||||||
Gem::Specification.add_spec sys_gem
|
Gem::Specification.add_spec sys_gem
|
||||||
yield
|
yield
|
||||||
|
@ -311,11 +311,11 @@ class TestGemIndexer < Gem::TestCase
|
||||||
assert File.directory?(quickdir)
|
assert File.directory?(quickdir)
|
||||||
assert File.directory?(marshal_quickdir)
|
assert File.directory?(marshal_quickdir)
|
||||||
|
|
||||||
@d2_1 = quick_spec 'd', '2.1'
|
@d2_1 = util_spec 'd', '2.1'
|
||||||
util_build_gem @d2_1
|
util_build_gem @d2_1
|
||||||
@d2_1_tuple = [@d2_1.name, @d2_1.version, @d2_1.original_platform]
|
@d2_1_tuple = [@d2_1.name, @d2_1.version, @d2_1.original_platform]
|
||||||
|
|
||||||
@d2_1_a = quick_spec 'd', '2.2.a'
|
@d2_1_a = util_spec 'd', '2.2.a'
|
||||||
util_build_gem @d2_1_a
|
util_build_gem @d2_1_a
|
||||||
@d2_1_a_tuple = [@d2_1_a.name, @d2_1_a.version, @d2_1_a.original_platform]
|
@d2_1_a_tuple = [@d2_1_a.name, @d2_1_a.version, @d2_1_a.original_platform]
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,7 @@ gem 'other', version
|
||||||
end unless Gem.win_platform?
|
end unless Gem.win_platform?
|
||||||
|
|
||||||
def test_ensure_dependency
|
def test_ensure_dependency
|
||||||
quick_spec 'a'
|
util_spec 'a'
|
||||||
|
|
||||||
dep = Gem::Dependency.new 'a', '>= 2'
|
dep = Gem::Dependency.new 'a', '>= 2'
|
||||||
assert @installer.ensure_dependency(@spec, dep)
|
assert @installer.ensure_dependency(@spec, dep)
|
||||||
|
@ -606,7 +606,7 @@ gem 'other', version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_initialize
|
def test_initialize
|
||||||
spec = quick_spec 'a' do |s| s.platform = Gem::Platform.new 'mswin32' end
|
spec = util_spec 'a' do |s| s.platform = Gem::Platform.new 'mswin32' end
|
||||||
gem = File.join @tempdir, spec.file_name
|
gem = File.join @tempdir, spec.file_name
|
||||||
|
|
||||||
Dir.mkdir util_inst_bindir
|
Dir.mkdir util_inst_bindir
|
||||||
|
@ -1044,7 +1044,7 @@ gem 'other', version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_installation_satisfies_dependency_eh
|
def test_installation_satisfies_dependency_eh
|
||||||
quick_spec 'a'
|
util_spec 'a'
|
||||||
|
|
||||||
dep = Gem::Dependency.new 'a', '>= 2'
|
dep = Gem::Dependency.new 'a', '>= 2'
|
||||||
assert @installer.installation_satisfies_dependency?(dep)
|
assert @installer.installation_satisfies_dependency?(dep)
|
||||||
|
@ -1113,7 +1113,7 @@ gem 'other', version
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_pre_install_checks_wrong_rubygems_version
|
def test_pre_install_checks_wrong_rubygems_version
|
||||||
spec = quick_spec 'old_rubygems_required', '1' do |s|
|
spec = util_spec 'old_rubygems_required', '1' do |s|
|
||||||
s.required_rubygems_version = '< 0'
|
s.required_rubygems_version = '< 0'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1400,7 +1400,7 @@ gem 'other', version
|
||||||
end
|
end
|
||||||
|
|
||||||
def old_ruby_required
|
def old_ruby_required
|
||||||
spec = quick_spec 'old_ruby_required', '1' do |s|
|
spec = util_spec 'old_ruby_required', '1' do |s|
|
||||||
s.required_ruby_version = '= 1.4.6'
|
s.required_ruby_version = '= 1.4.6'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1410,7 +1410,7 @@ gem 'other', version
|
||||||
end
|
end
|
||||||
|
|
||||||
def util_execless
|
def util_execless
|
||||||
@spec = quick_spec 'z'
|
@spec = util_spec 'z'
|
||||||
util_build_gem @spec
|
util_build_gem @spec
|
||||||
|
|
||||||
@installer = util_installer @spec, @gemhome
|
@installer = util_installer @spec, @gemhome
|
||||||
|
|
|
@ -40,7 +40,7 @@ class TestGemLocalRemoteOptions < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_clear_sources_option_idiot_proof
|
def test_clear_sources_option_idiot_proof
|
||||||
util_setup_fake_fetcher
|
spec_fetcher
|
||||||
|
|
||||||
@cmd.add_local_remote_options
|
@cmd.add_local_remote_options
|
||||||
@cmd.handle_options %W[--clear-sources]
|
@cmd.handle_options %W[--clear-sources]
|
||||||
|
|
|
@ -9,7 +9,7 @@ class TestGemRDoc < Gem::TestCase
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
|
|
||||||
@a = quick_spec 'a' do |s|
|
@a = util_spec 'a' do |s|
|
||||||
s.rdoc_options = %w[--main MyTitle]
|
s.rdoc_options = %w[--main MyTitle]
|
||||||
s.extra_rdoc_files = %w[README]
|
s.extra_rdoc_files = %w[README]
|
||||||
end
|
end
|
||||||
|
|
|
@ -160,6 +160,37 @@ class TestGemRequestSet < Gem::TestCase
|
||||||
assert_equal %w!c-2 b-2 a-2!, names
|
assert_equal %w!c-2 b-2 a-2!, names
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_install
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.gem "a", "1", "b" => "= 1"
|
||||||
|
fetcher.gem "b", "1"
|
||||||
|
|
||||||
|
fetcher.clear
|
||||||
|
end
|
||||||
|
|
||||||
|
rs = Gem::RequestSet.new
|
||||||
|
rs.gem 'a'
|
||||||
|
|
||||||
|
rs.resolve
|
||||||
|
|
||||||
|
reqs = []
|
||||||
|
installers = []
|
||||||
|
|
||||||
|
installed = rs.install({}) do |req, installer|
|
||||||
|
reqs << req
|
||||||
|
installers << installer
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal %w[b-1 a-1], reqs.map { |req| req.full_name }
|
||||||
|
assert_equal %w[b-1 a-1],
|
||||||
|
installers.map { |installer| installer.spec.full_name }
|
||||||
|
|
||||||
|
assert_path_exists File.join @gemhome, 'specifications', 'a-1.gemspec'
|
||||||
|
assert_path_exists File.join @gemhome, 'specifications', 'b-1.gemspec'
|
||||||
|
|
||||||
|
assert_equal %w[b-1 a-1], installed.map { |s| s.full_name }
|
||||||
|
end
|
||||||
|
|
||||||
def test_install_into
|
def test_install_into
|
||||||
spec_fetcher do |fetcher|
|
spec_fetcher do |fetcher|
|
||||||
fetcher.gem "a", "1", "b" => "= 1"
|
fetcher.gem "a", "1", "b" => "= 1"
|
||||||
|
@ -173,8 +204,8 @@ class TestGemRequestSet < Gem::TestCase
|
||||||
|
|
||||||
installed = rs.install_into @tempdir
|
installed = rs.install_into @tempdir
|
||||||
|
|
||||||
assert File.exists?(File.join(@tempdir, "specifications", "a-1.gemspec"))
|
assert_path_exists File.join @tempdir, 'specifications', 'a-1.gemspec'
|
||||||
assert File.exists?(File.join(@tempdir, "specifications", "b-1.gemspec"))
|
assert_path_exists File.join @tempdir, 'specifications', 'b-1.gemspec'
|
||||||
|
|
||||||
assert_equal %w!b-1 a-1!, installed.map { |s| s.full_name }
|
assert_equal %w!b-1 a-1!, installed.map { |s| s.full_name }
|
||||||
end
|
end
|
||||||
|
|
|
@ -89,11 +89,15 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_gem_platforms
|
def test_gem_platforms
|
||||||
|
win_platform, Gem.win_platform = Gem.win_platform?, false
|
||||||
|
|
||||||
with_engine_version 'ruby', '2.0.0' do
|
with_engine_version 'ruby', '2.0.0' do
|
||||||
@gda.gem 'a', :platforms => :ruby
|
@gda.gem 'a', :platforms => :ruby
|
||||||
|
|
||||||
refute_empty @set.dependencies
|
refute_empty @set.dependencies
|
||||||
end
|
end
|
||||||
|
ensure
|
||||||
|
Gem.win_platform = win_platform
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_gem_platforms_bundler_ruby
|
def test_gem_platforms_bundler_ruby
|
||||||
|
@ -145,6 +149,8 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_gem_platforms_maglev
|
def test_gem_platforms_maglev
|
||||||
|
win_platform, Gem.win_platform = Gem.win_platform?, false
|
||||||
|
|
||||||
with_engine_version 'maglev', '1.0.0' do
|
with_engine_version 'maglev', '1.0.0' do
|
||||||
set = Gem::RequestSet.new
|
set = Gem::RequestSet.new
|
||||||
gda = @GDA.new set, 'gem.deps.rb'
|
gda = @GDA.new set, 'gem.deps.rb'
|
||||||
|
@ -158,6 +164,8 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
|
||||||
|
|
||||||
refute_empty set.dependencies
|
refute_empty set.dependencies
|
||||||
end
|
end
|
||||||
|
ensure
|
||||||
|
Gem.win_platform = win_platform
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_gem_platforms_multiple
|
def test_gem_platforms_multiple
|
||||||
|
@ -308,19 +316,35 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_platform_mswin
|
def test_platform_mswin
|
||||||
|
win_platform, Gem.win_platform = Gem.win_platform?, false
|
||||||
|
|
||||||
@gda.platform :mswin do
|
@gda.platform :mswin do
|
||||||
@gda.gem 'a'
|
@gda.gem 'a'
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_empty @set.dependencies
|
assert_empty @set.dependencies
|
||||||
|
|
||||||
|
Gem.win_platform = true
|
||||||
|
|
||||||
|
@gda.platform :mswin do
|
||||||
|
@gda.gem 'a'
|
||||||
|
end
|
||||||
|
|
||||||
|
refute_empty @set.dependencies
|
||||||
|
ensure
|
||||||
|
Gem.win_platform = win_platform
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_platform_ruby
|
def test_platform_ruby
|
||||||
|
win_platform, Gem.win_platform = Gem.win_platform?, false
|
||||||
|
|
||||||
@gda.platform :ruby do
|
@gda.platform :ruby do
|
||||||
@gda.gem 'a'
|
@gda.gem 'a'
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal [dep('a')], @set.dependencies
|
assert_equal [dep('a')], @set.dependencies
|
||||||
|
ensure
|
||||||
|
Gem.win_platform = win_platform
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_platforms
|
def test_platforms
|
||||||
|
|
|
@ -89,7 +89,7 @@ class TestGemServer < Gem::TestCase
|
||||||
data = StringIO.new "GET /latest_specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
|
data = StringIO.new "GET /latest_specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
|
||||||
dir = "#{@gemhome}2"
|
dir = "#{@gemhome}2"
|
||||||
|
|
||||||
spec = quick_spec 'z', 9
|
spec = util_spec 'z', 9
|
||||||
|
|
||||||
specs_dir = File.join dir, 'specifications'
|
specs_dir = File.join dir, 'specifications'
|
||||||
FileUtils.mkdir_p specs_dir
|
FileUtils.mkdir_p specs_dir
|
||||||
|
@ -156,7 +156,7 @@ class TestGemServer < Gem::TestCase
|
||||||
|
|
||||||
assert_equal 404, @res.status
|
assert_equal 404, @res.status
|
||||||
|
|
||||||
spec = quick_spec 'z', 9
|
spec = util_spec 'z', 9
|
||||||
|
|
||||||
specs_dir = File.join dir, 'specifications'
|
specs_dir = File.join dir, 'specifications'
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ class TestGemServer < Gem::TestCase
|
||||||
data = StringIO.new "GET / HTTP/1.0\r\n\r\n"
|
data = StringIO.new "GET / HTTP/1.0\r\n\r\n"
|
||||||
dir = "#{@gemhome}2"
|
dir = "#{@gemhome}2"
|
||||||
|
|
||||||
spec = quick_spec 'z', 9
|
spec = util_spec 'z', 9
|
||||||
|
|
||||||
specs_dir = File.join dir, 'specifications'
|
specs_dir = File.join dir, 'specifications'
|
||||||
FileUtils.mkdir_p specs_dir
|
FileUtils.mkdir_p specs_dir
|
||||||
|
@ -287,7 +287,7 @@ class TestGemServer < Gem::TestCase
|
||||||
data = StringIO.new "GET /specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
|
data = StringIO.new "GET /specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
|
||||||
dir = "#{@gemhome}2"
|
dir = "#{@gemhome}2"
|
||||||
|
|
||||||
spec = quick_spec 'z', 9
|
spec = util_spec 'z', 9
|
||||||
|
|
||||||
specs_dir = File.join dir, 'specifications'
|
specs_dir = File.join dir, 'specifications'
|
||||||
FileUtils.mkdir_p specs_dir
|
FileUtils.mkdir_p specs_dir
|
||||||
|
|
|
@ -10,43 +10,14 @@ class TestGemSource < Gem::TestCase
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
|
|
||||||
util_setup_fake_fetcher
|
@specs = spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'a', '1.a'
|
||||||
@a_pre = new_spec 'a', '1.a'
|
fetcher.gem 'a', 1
|
||||||
|
fetcher.spec 'a', 2
|
||||||
install_specs @a_pre
|
fetcher.spec 'b', 2
|
||||||
|
end
|
||||||
|
|
||||||
@source = Gem::Source.new(@gem_repo)
|
@source = Gem::Source.new(@gem_repo)
|
||||||
|
|
||||||
Gem::Specification.remove_spec @b2
|
|
||||||
|
|
||||||
all = Gem::Specification.map { |spec|
|
|
||||||
Gem::NameTuple.new(spec.name, spec.version, spec.original_platform)
|
|
||||||
}.sort
|
|
||||||
|
|
||||||
@prerelease_specs, @specs = all.partition { |g| g.prerelease? }
|
|
||||||
|
|
||||||
# TODO: couldn't all of this come from the fake spec fetcher?
|
|
||||||
@latest_specs = Gem::Specification.latest_specs.sort.map { |spec|
|
|
||||||
Gem::NameTuple.new(spec.name, spec.version, spec.original_platform)
|
|
||||||
}
|
|
||||||
|
|
||||||
v = Gem.marshal_version
|
|
||||||
s_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@specs)))
|
|
||||||
l_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@latest_specs)))
|
|
||||||
p_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@prerelease_specs)))
|
|
||||||
@fetcher.data["#{@gem_repo}specs.#{v}.gz"] = s_zip
|
|
||||||
@fetcher.data["#{@gem_repo}latest_specs.#{v}.gz"] = l_zip
|
|
||||||
@fetcher.data["#{@gem_repo}prerelease_specs.#{v}.gz"] = p_zip
|
|
||||||
|
|
||||||
@released = Gem::NameTuple.from_list \
|
|
||||||
[["a", Gem::Version.new("1"), "ruby"],
|
|
||||||
["a", Gem::Version.new("2"), "ruby"],
|
|
||||||
["a_evil", Gem::Version.new("9"), "ruby"],
|
|
||||||
["c", Gem::Version.new("1.2"), "ruby"],
|
|
||||||
['dep_x', Gem::Version.new(1), 'ruby'],
|
|
||||||
["pl", Gem::Version.new("1"), "i386-linux"],
|
|
||||||
['x', Gem::Version.new(1), 'ruby']]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_api_uri
|
def test_api_uri
|
||||||
|
@ -83,59 +54,60 @@ class TestGemSource < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fetch_spec
|
def test_fetch_spec
|
||||||
spec_uri = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a1.spec_name}"
|
a1 = @specs['a-1']
|
||||||
@fetcher.data["#{spec_uri}.rz"] = util_zip(Marshal.dump(@a1))
|
|
||||||
|
spec_uri = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{a1.spec_name}"
|
||||||
|
|
||||||
spec = @source.fetch_spec tuple('a', Gem::Version.new(1), 'ruby')
|
spec = @source.fetch_spec tuple('a', Gem::Version.new(1), 'ruby')
|
||||||
assert_equal @a1.full_name, spec.full_name
|
assert_equal a1.full_name, spec.full_name
|
||||||
|
|
||||||
cache_dir = @source.cache_dir URI.parse(spec_uri)
|
cache_dir = @source.cache_dir URI.parse(spec_uri)
|
||||||
|
|
||||||
cache_file = File.join cache_dir, @a1.spec_name
|
cache_file = File.join cache_dir, a1.spec_name
|
||||||
|
|
||||||
assert File.exist?(cache_file)
|
assert File.exist?(cache_file)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fetch_spec_cached
|
def test_fetch_spec_cached
|
||||||
spec_uri = "#{@gem_repo}/#{Gem::MARSHAL_SPEC_DIR}#{@a1.spec_name}"
|
a1 = @specs['a-1']
|
||||||
|
|
||||||
|
spec_uri = "#{@gem_repo}/#{Gem::MARSHAL_SPEC_DIR}#{a1.spec_name}"
|
||||||
@fetcher.data["#{spec_uri}.rz"] = nil
|
@fetcher.data["#{spec_uri}.rz"] = nil
|
||||||
|
|
||||||
cache_dir = @source.cache_dir URI.parse(spec_uri)
|
cache_dir = @source.cache_dir URI.parse(spec_uri)
|
||||||
FileUtils.mkdir_p cache_dir
|
FileUtils.mkdir_p cache_dir
|
||||||
|
|
||||||
cache_file = File.join cache_dir, @a1.spec_name
|
cache_file = File.join cache_dir, a1.spec_name
|
||||||
|
|
||||||
open cache_file, 'wb' do |io|
|
open cache_file, 'wb' do |io|
|
||||||
Marshal.dump @a1, io
|
Marshal.dump a1, io
|
||||||
end
|
end
|
||||||
|
|
||||||
spec = @source.fetch_spec tuple('a', Gem::Version.new(1), 'ruby')
|
spec = @source.fetch_spec tuple('a', Gem::Version.new(1), 'ruby')
|
||||||
assert_equal @a1.full_name, spec.full_name
|
assert_equal a1.full_name, spec.full_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fetch_spec_platform
|
def test_fetch_spec_platform
|
||||||
@fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@pl1.original_name}.gemspec.rz"] =
|
specs = spec_fetcher do |fetcher|
|
||||||
util_zip(Marshal.dump(@pl1))
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
spec = @source.fetch_spec tuple('pl', Gem::Version.new(1), 'i386-linux')
|
spec = @source.fetch_spec tuple('pl', Gem::Version.new(1), 'i386-linux')
|
||||||
|
|
||||||
assert_equal @pl1.full_name, spec.full_name
|
assert_equal specs['pl-1-x86-linux'].full_name, spec.full_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fetch_spec_platform_ruby
|
def test_fetch_spec_platform_ruby
|
||||||
@fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a1.spec_name}.rz"] =
|
|
||||||
util_zip(Marshal.dump(@a1))
|
|
||||||
|
|
||||||
spec = @source.fetch_spec tuple('a', Gem::Version.new(1), nil)
|
spec = @source.fetch_spec tuple('a', Gem::Version.new(1), nil)
|
||||||
assert_equal @a1.full_name, spec.full_name
|
assert_equal @specs['a-1'].full_name, spec.full_name
|
||||||
|
|
||||||
spec = @source.fetch_spec tuple('a', Gem::Version.new(1), '')
|
spec = @source.fetch_spec tuple('a', Gem::Version.new(1), '')
|
||||||
assert_equal @a1.full_name, spec.full_name
|
assert_equal @specs['a-1'].full_name, spec.full_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_load_specs
|
def test_load_specs
|
||||||
expected = @released
|
released = @source.load_specs(:released).map { |spec| spec.full_name }
|
||||||
assert_equal expected, @source.load_specs(:released)
|
assert_equal %W[a-2 a-1 b-2], released
|
||||||
|
|
||||||
cache_dir = File.join Gem.spec_cache_dir, 'gems.example.com%80'
|
cache_dir = File.join Gem.spec_cache_dir, 'gems.example.com%80'
|
||||||
assert File.exist?(cache_dir), "#{cache_dir} does not exist"
|
assert File.exist?(cache_dir), "#{cache_dir} does not exist"
|
||||||
|
@ -145,12 +117,14 @@ class TestGemSource < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_load_specs_cached
|
def test_load_specs_cached
|
||||||
|
latest_specs = @source.load_specs :latest
|
||||||
|
|
||||||
# Make sure the cached version is actually different:
|
# Make sure the cached version is actually different:
|
||||||
@latest_specs << Gem::NameTuple.new('cached', Gem::Version.new('1.0.0'), 'ruby')
|
latest_specs << Gem::NameTuple.new('cached', Gem::Version.new('1.0.0'), 'ruby')
|
||||||
|
|
||||||
@fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] = nil
|
@fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] = nil
|
||||||
@fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}"] =
|
@fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}"] =
|
||||||
' ' * Marshal.dump(@latest_specs).length
|
' ' * Marshal.dump(latest_specs).length
|
||||||
|
|
||||||
cache_dir = File.join Gem.spec_cache_dir, 'gems.example.com%80'
|
cache_dir = File.join Gem.spec_cache_dir, 'gems.example.com%80'
|
||||||
|
|
||||||
|
@ -159,20 +133,22 @@ class TestGemSource < Gem::TestCase
|
||||||
cache_file = File.join cache_dir, "latest_specs.#{Gem.marshal_version}"
|
cache_file = File.join cache_dir, "latest_specs.#{Gem.marshal_version}"
|
||||||
|
|
||||||
open cache_file, 'wb' do |io|
|
open cache_file, 'wb' do |io|
|
||||||
Marshal.dump @latest_specs, io
|
Marshal.dump latest_specs, io
|
||||||
end
|
end
|
||||||
|
|
||||||
latest_specs = @source.load_specs :latest
|
cached_specs = @source.load_specs :latest
|
||||||
|
|
||||||
assert_equal @latest_specs, latest_specs
|
assert_equal latest_specs, cached_specs
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_load_specs_cached_empty
|
def test_load_specs_cached_empty
|
||||||
|
latest_specs = @source.load_specs :latest
|
||||||
|
|
||||||
# Make sure the cached version is actually different:
|
# Make sure the cached version is actually different:
|
||||||
@latest_specs << Gem::NameTuple.new('fixed', Gem::Version.new('1.0.0'), 'ruby')
|
latest_specs << Gem::NameTuple.new('fixed', Gem::Version.new('1.0.0'), 'ruby')
|
||||||
# Setup valid data on the 'remote'
|
# Setup valid data on the 'remote'
|
||||||
@fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] =
|
@fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] =
|
||||||
util_gzip(Marshal.dump(@latest_specs))
|
util_gzip(Marshal.dump(latest_specs))
|
||||||
|
|
||||||
cache_dir = File.join Gem.spec_cache_dir, 'gems.example.com%80'
|
cache_dir = File.join Gem.spec_cache_dir, 'gems.example.com%80'
|
||||||
|
|
||||||
|
@ -182,12 +158,12 @@ class TestGemSource < Gem::TestCase
|
||||||
|
|
||||||
open cache_file, 'wb' do |io|
|
open cache_file, 'wb' do |io|
|
||||||
# Setup invalid data in the cache:
|
# Setup invalid data in the cache:
|
||||||
io.write Marshal.dump(@latest_specs)[0, 10]
|
io.write Marshal.dump(latest_specs)[0, 10]
|
||||||
end
|
end
|
||||||
|
|
||||||
latest_specs = @source.load_specs :latest
|
fixed_specs = @source.load_specs :latest
|
||||||
|
|
||||||
assert_equal @latest_specs, latest_specs
|
assert_equal latest_specs, fixed_specs
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_load_specs_from_unavailable_uri
|
def test_load_specs_from_unavailable_uri
|
||||||
|
@ -200,7 +176,7 @@ class TestGemSource < Gem::TestCase
|
||||||
|
|
||||||
def test_spaceship
|
def test_spaceship
|
||||||
remote = @source
|
remote = @source
|
||||||
specific = Gem::Source::SpecificFile.new(@a1.cache_file)
|
specific = Gem::Source::SpecificFile.new @specs['a-1'].cache_file
|
||||||
installed = Gem::Source::Installed.new
|
installed = Gem::Source::Installed.new
|
||||||
local = Gem::Source::Local.new
|
local = Gem::Source::Local.new
|
||||||
|
|
||||||
|
|
|
@ -13,43 +13,7 @@ class TestGemSpecFetcher < Gem::TestCase
|
||||||
@uri = URI.parse @gem_repo
|
@uri = URI.parse @gem_repo
|
||||||
@source = Gem::Source.new(@uri)
|
@source = Gem::Source.new(@uri)
|
||||||
|
|
||||||
util_setup_fake_fetcher
|
|
||||||
|
|
||||||
@a_pre = new_spec 'a', '1.a'
|
|
||||||
|
|
||||||
install_specs @a_pre
|
|
||||||
|
|
||||||
Gem::Specification.remove_spec @b2
|
|
||||||
|
|
||||||
all = Gem::Specification.map { |spec|
|
|
||||||
Gem::NameTuple.new(spec.name, spec.version, spec.original_platform)
|
|
||||||
}.sort
|
|
||||||
|
|
||||||
@prerelease_specs, @specs = all.partition { |g| g.prerelease? }
|
|
||||||
|
|
||||||
# TODO: couldn't all of this come from the fake spec fetcher?
|
|
||||||
@latest_specs = Gem::Specification.latest_specs.sort.map { |spec|
|
|
||||||
Gem::NameTuple.new(spec.name, spec.version, spec.original_platform)
|
|
||||||
}
|
|
||||||
|
|
||||||
v = Gem.marshal_version
|
|
||||||
s_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@specs)))
|
|
||||||
l_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@latest_specs)))
|
|
||||||
p_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@prerelease_specs)))
|
|
||||||
@fetcher.data["#{@gem_repo}specs.#{v}.gz"] = s_zip
|
|
||||||
@fetcher.data["#{@gem_repo}latest_specs.#{v}.gz"] = l_zip
|
|
||||||
@fetcher.data["#{@gem_repo}prerelease_specs.#{v}.gz"] = p_zip
|
|
||||||
|
|
||||||
@sf = Gem::SpecFetcher.new
|
@sf = Gem::SpecFetcher.new
|
||||||
|
|
||||||
@released = Gem::NameTuple.from_list \
|
|
||||||
[["a", Gem::Version.new("1"), "ruby"],
|
|
||||||
["a", Gem::Version.new("2"), "ruby"],
|
|
||||||
["a_evil", Gem::Version.new("9"), "ruby"],
|
|
||||||
["c", Gem::Version.new("1.2"), "ruby"],
|
|
||||||
['dep_x', Gem::Version.new(1), 'ruby'],
|
|
||||||
["pl", Gem::Version.new("1"), "i386-linux"],
|
|
||||||
['x', Gem::Version.new(1), 'ruby']]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_initialize
|
def test_initialize
|
||||||
|
@ -86,11 +50,12 @@ class TestGemSpecFetcher < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_spec_for_dependency_all
|
def test_spec_for_dependency_all
|
||||||
d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}"
|
spec_fetcher do |fetcher|
|
||||||
@fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1))
|
fetcher.spec 'a', 1
|
||||||
@fetcher.data["#{d}#{@a2.spec_name}.rz"] = util_zip(Marshal.dump(@a2))
|
fetcher.spec 'a', '2.a'
|
||||||
@fetcher.data["#{d}#{@a_pre.spec_name}.rz"] = util_zip(Marshal.dump(@a_pre))
|
fetcher.spec 'a', 2
|
||||||
@fetcher.data["#{d}#{@a3a.spec_name}.rz"] = util_zip(Marshal.dump(@a3a))
|
fetcher.spec 'a', '3.a'
|
||||||
|
end
|
||||||
|
|
||||||
dep = Gem::Dependency.new 'a', ">= 1"
|
dep = Gem::Dependency.new 'a', ">= 1"
|
||||||
|
|
||||||
|
@ -100,7 +65,7 @@ class TestGemSpecFetcher < Gem::TestCase
|
||||||
[spec.full_name, source_uri]
|
[spec.full_name, source_uri]
|
||||||
end
|
end
|
||||||
|
|
||||||
expected = [[@a1.full_name, @source], [@a2.full_name, @source]]
|
expected = [['a-1', @source], ['a-2', @source]]
|
||||||
|
|
||||||
assert_equal expected, spec_names
|
assert_equal expected, spec_names
|
||||||
|
|
||||||
|
@ -108,10 +73,11 @@ class TestGemSpecFetcher < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_spec_for_dependency_latest
|
def test_spec_for_dependency_latest
|
||||||
d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}"
|
spec_fetcher do |fetcher|
|
||||||
@fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1))
|
fetcher.spec 'a', 1
|
||||||
@fetcher.data["#{d}#{@a2.spec_name}.rz"] = util_zip(Marshal.dump(@a2))
|
fetcher.spec 'a', 2
|
||||||
@fetcher.data["#{d}#{@a_pre.spec_name}.rz"] = util_zip(Marshal.dump(@a_pre))
|
fetcher.spec 'a', '3.a'
|
||||||
|
end
|
||||||
|
|
||||||
dep = Gem::Dependency.new 'a'
|
dep = Gem::Dependency.new 'a'
|
||||||
specs_and_sources, _ = @sf.spec_for_dependency dep
|
specs_and_sources, _ = @sf.spec_for_dependency dep
|
||||||
|
@ -120,14 +86,15 @@ class TestGemSpecFetcher < Gem::TestCase
|
||||||
[spec.full_name, source_uri]
|
[spec.full_name, source_uri]
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal [[@a2.full_name, Gem::Source.new(@gem_repo)]], spec_names
|
assert_equal [['a-2', Gem::Source.new(@gem_repo)]],
|
||||||
|
spec_names
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_spec_for_dependency_prerelease
|
def test_spec_for_dependency_prerelease
|
||||||
d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}"
|
spec_fetcher do |fetcher|
|
||||||
@fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1))
|
fetcher.spec 'a', '1.a'
|
||||||
@fetcher.data["#{d}#{@a2.spec_name}.rz"] = util_zip(Marshal.dump(@a2))
|
fetcher.spec 'a', 1
|
||||||
@fetcher.data["#{d}#{@a_pre.spec_name}.rz"] = util_zip(Marshal.dump(@a_pre))
|
end
|
||||||
|
|
||||||
specs_and_sources, _ = @sf.spec_for_dependency dep('a', '1.a')
|
specs_and_sources, _ = @sf.spec_for_dependency dep('a', '1.a')
|
||||||
|
|
||||||
|
@ -135,14 +102,15 @@ class TestGemSpecFetcher < Gem::TestCase
|
||||||
[spec.full_name, source_uri]
|
[spec.full_name, source_uri]
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal [[@a_pre.full_name, Gem::Source.new(@gem_repo)]], spec_names
|
assert_equal [['a-1.a', Gem::Source.new(@gem_repo)]], spec_names
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_spec_for_dependency_platform
|
def test_spec_for_dependency_platform
|
||||||
util_set_arch 'i386-linux'
|
util_set_arch 'i386-linux'
|
||||||
|
|
||||||
@fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@pl1.original_name}.gemspec.rz"] =
|
spec_fetcher do |fetcher|
|
||||||
util_zip(Marshal.dump(@pl1))
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
dep = Gem::Dependency.new 'pl', 1
|
dep = Gem::Dependency.new 'pl', 1
|
||||||
specs_and_sources, _ = @sf.spec_for_dependency dep
|
specs_and_sources, _ = @sf.spec_for_dependency dep
|
||||||
|
@ -151,14 +119,16 @@ class TestGemSpecFetcher < Gem::TestCase
|
||||||
[spec.full_name, source_uri]
|
[spec.full_name, source_uri]
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal [[@pl1.full_name, Gem::Source.new(@gem_repo)]], spec_names
|
assert_equal [['pl-1-x86-linux', Gem::Source.new(@gem_repo)]],
|
||||||
|
spec_names
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_spec_for_dependency_mismatched_platform
|
def test_spec_for_dependency_mismatched_platform
|
||||||
util_set_arch 'hrpa-989'
|
util_set_arch 'hrpa-989'
|
||||||
|
|
||||||
@fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@pl1.original_name}.gemspec.rz"] =
|
spec_fetcher do |fetcher|
|
||||||
util_zip(Marshal.dump(@pl1))
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
dep = Gem::Dependency.new 'pl', 1
|
dep = Gem::Dependency.new 'pl', 1
|
||||||
specs_and_sources, errors = @sf.spec_for_dependency dep
|
specs_and_sources, errors = @sf.spec_for_dependency dep
|
||||||
|
@ -179,11 +149,12 @@ class TestGemSpecFetcher < Gem::TestCase
|
||||||
|
|
||||||
Gem.sources.replace [src]
|
Gem.sources.replace [src]
|
||||||
|
|
||||||
d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}"
|
spec_fetcher do |fetcher|
|
||||||
@fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1))
|
fetcher.spec 'a', 1
|
||||||
@fetcher.data["#{d}#{@a2.spec_name}.rz"] = util_zip(Marshal.dump(@a2))
|
fetcher.spec 'a', '2.a'
|
||||||
@fetcher.data["#{d}#{@a_pre.spec_name}.rz"] = util_zip(Marshal.dump(@a_pre))
|
fetcher.spec 'a', 2
|
||||||
@fetcher.data["#{d}#{@a3a.spec_name}.rz"] = util_zip(Marshal.dump(@a3a))
|
fetcher.spec 'a', '3.a'
|
||||||
|
end
|
||||||
|
|
||||||
dep = Gem::Dependency.new 'a', ">= 1"
|
dep = Gem::Dependency.new 'a', ">= 1"
|
||||||
|
|
||||||
|
@ -198,31 +169,70 @@ class TestGemSpecFetcher < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_available_specs_latest
|
def test_available_specs_latest
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
|
fetcher.spec 'a', 2
|
||||||
|
fetcher.spec 'a', '3.a'
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
specs, _ = @sf.available_specs(:latest)
|
specs, _ = @sf.available_specs(:latest)
|
||||||
|
|
||||||
assert_equal [@source], specs.keys
|
assert_equal [@source], specs.keys
|
||||||
assert_equal @latest_specs, specs[@source]
|
|
||||||
|
expected = Gem::NameTuple.from_list \
|
||||||
|
[['a', v(2), Gem::Platform::RUBY],
|
||||||
|
['pl', v(1), 'i386-linux']]
|
||||||
|
|
||||||
|
assert_equal expected, specs[@source]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_available_specs_released
|
def test_available_specs_released
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
specs, _ = @sf.available_specs(:released)
|
specs, _ = @sf.available_specs(:released)
|
||||||
|
|
||||||
assert_equal [@source], specs.keys
|
assert_equal [@source], specs.keys
|
||||||
|
|
||||||
assert_equal @released, specs[@source]
|
expected = Gem::NameTuple.from_list \
|
||||||
|
[['a', v(1), Gem::Platform::RUBY],
|
||||||
|
['pl', v(1), 'i386-linux']]
|
||||||
|
|
||||||
|
assert_equal expected, specs[@source]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_available_specs_complete
|
def test_available_specs_complete
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
|
fetcher.spec 'a', '2.a'
|
||||||
|
fetcher.spec 'b', 2
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
specs, _ = @sf.available_specs(:complete)
|
specs, _ = @sf.available_specs(:complete)
|
||||||
|
|
||||||
assert_equal [@source], specs.keys
|
assert_equal [@source], specs.keys
|
||||||
|
|
||||||
expected = (@prerelease_specs + @released).sort
|
expected = Gem::NameTuple.from_list \
|
||||||
|
[['a', v(1), Gem::Platform::RUBY],
|
||||||
|
['a', v('2.a'), Gem::Platform::RUBY],
|
||||||
|
['b', v(2), Gem::Platform::RUBY],
|
||||||
|
['pl', v(1), 'i386-linux']]
|
||||||
|
|
||||||
assert_equal expected, specs[@source]
|
assert_equal expected, specs[@source]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_available_specs_complete_handles_no_prerelease
|
def test_available_specs_complete_handles_no_prerelease
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
|
fetcher.spec 'a', '2.a'
|
||||||
|
fetcher.spec 'b', 2
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
v = Gem.marshal_version
|
v = Gem.marshal_version
|
||||||
@fetcher.data.delete "#{@gem_repo}prerelease_specs.#{v}.gz"
|
@fetcher.data.delete "#{@gem_repo}prerelease_specs.#{v}.gz"
|
||||||
|
|
||||||
|
@ -230,10 +240,19 @@ class TestGemSpecFetcher < Gem::TestCase
|
||||||
|
|
||||||
assert_equal [@source], specs.keys
|
assert_equal [@source], specs.keys
|
||||||
|
|
||||||
assert_equal @released, specs[@source]
|
expected = Gem::NameTuple.from_list \
|
||||||
|
[['a', v(1), Gem::Platform::RUBY],
|
||||||
|
['b', v(2), Gem::Platform::RUBY],
|
||||||
|
['pl', v(1), 'i386-linux']]
|
||||||
|
|
||||||
|
assert_equal expected, specs[@source]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_available_specs_cache
|
def test_available_specs_cache
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
|
end
|
||||||
|
|
||||||
specs, _ = @sf.available_specs(:latest)
|
specs, _ = @sf.available_specs(:latest)
|
||||||
|
|
||||||
refute specs[@source].empty?
|
refute specs[@source].empty?
|
||||||
|
@ -246,6 +265,13 @@ class TestGemSpecFetcher < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_available_specs_cache_released
|
def test_available_specs_cache_released
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
|
fetcher.spec 'a', '2.a'
|
||||||
|
fetcher.spec 'b', 2
|
||||||
|
fetcher.legacy_platform
|
||||||
|
end
|
||||||
|
|
||||||
specs, _ = @sf.available_specs(:released)
|
specs, _ = @sf.available_specs(:released)
|
||||||
|
|
||||||
refute specs[@source].empty?
|
refute specs[@source].empty?
|
||||||
|
@ -258,9 +284,17 @@ class TestGemSpecFetcher < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_available_specs_prerelease
|
def test_available_specs_prerelease
|
||||||
|
spec_fetcher do |fetcher|
|
||||||
|
fetcher.spec 'a', 1
|
||||||
|
fetcher.spec 'a', '2.a'
|
||||||
|
end
|
||||||
|
|
||||||
specs, _ = @sf.available_specs(:prerelease)
|
specs, _ = @sf.available_specs(:prerelease)
|
||||||
|
|
||||||
assert_equal @prerelease_specs, specs[@source]
|
expected = Gem::NameTuple.from_list \
|
||||||
|
[['a', v('2.a'), Gem::Platform::RUBY]]
|
||||||
|
|
||||||
|
assert_equal expected, specs[@source]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_available_specs_with_bad_source
|
def test_available_specs_with_bad_source
|
||||||
|
|
|
@ -41,7 +41,7 @@ end
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
def make_spec_c1
|
def make_spec_c1
|
||||||
@c1 = quick_spec 'a', '1' do |s|
|
@c1 = util_spec 'a', '1' do |s|
|
||||||
s.executable = 'exec'
|
s.executable = 'exec'
|
||||||
s.extensions << 'ext/a/extconf.rb'
|
s.extensions << 'ext/a/extconf.rb'
|
||||||
s.test_file = 'test/suite.rb'
|
s.test_file = 'test/suite.rb'
|
||||||
|
@ -59,7 +59,7 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
def ext_spec
|
def ext_spec
|
||||||
@ext = quick_spec 'ext', '1' do |s|
|
@ext = util_spec 'ext', '1' do |s|
|
||||||
s.executable = 'exec'
|
s.executable = 'exec'
|
||||||
s.test_file = 'test/suite.rb'
|
s.test_file = 'test/suite.rb'
|
||||||
s.extensions = %w[ext/extconf.rb]
|
s.extensions = %w[ext/extconf.rb]
|
||||||
|
@ -74,7 +74,7 @@ end
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
|
|
||||||
@a1 = quick_spec 'a', '1' do |s|
|
@a1 = util_spec 'a', '1' do |s|
|
||||||
s.executable = 'exec'
|
s.executable = 'exec'
|
||||||
s.test_file = 'test/suite.rb'
|
s.test_file = 'test/suite.rb'
|
||||||
s.requirements << 'A working computer'
|
s.requirements << 'A working computer'
|
||||||
|
@ -85,11 +85,11 @@ end
|
||||||
s.files = %w[lib/code.rb]
|
s.files = %w[lib/code.rb]
|
||||||
end
|
end
|
||||||
|
|
||||||
@a2 = quick_spec 'a', '2' do |s|
|
@a2 = util_spec 'a', '2' do |s|
|
||||||
s.files = %w[lib/code.rb]
|
s.files = %w[lib/code.rb]
|
||||||
end
|
end
|
||||||
|
|
||||||
@a3 = quick_spec 'a', '3' do |s|
|
@a3 = util_spec 'a', '3' do |s|
|
||||||
s.metadata['allowed_push_host'] = "https://privategemserver.com"
|
s.metadata['allowed_push_host'] = "https://privategemserver.com"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -840,37 +840,34 @@ dependencies: []
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_outdated
|
def test_self_outdated
|
||||||
util_clear_gems
|
spec_fetcher do |fetcher|
|
||||||
util_setup_fake_fetcher true
|
fetcher.spec 'a', 4
|
||||||
|
|
||||||
a4 = quick_gem @a1.name, '4'
|
fetcher.clear
|
||||||
util_build_gem a4
|
|
||||||
util_setup_spec_fetcher @a1, @a2, @a3a, a4
|
|
||||||
|
|
||||||
Gem::Specification.remove_spec @a1
|
fetcher.spec 'a', 3
|
||||||
Gem::Specification.remove_spec @a2
|
end
|
||||||
Gem::Specification.remove_spec a4
|
|
||||||
|
|
||||||
assert_equal %w[a], Gem::Specification.outdated
|
assert_equal %w[a], Gem::Specification.outdated
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_outdated_and_latest_remotes
|
def test_self_outdated_and_latest_remotes
|
||||||
util_clear_gems
|
specs = spec_fetcher do |fetcher|
|
||||||
util_setup_fake_fetcher true
|
fetcher.spec 'a', 4
|
||||||
|
fetcher.spec 'b', 3
|
||||||
|
|
||||||
a4 = quick_gem @a1.name, '4'
|
fetcher.clear
|
||||||
util_build_gem a4
|
|
||||||
b3 = quick_gem @b2.name, '3'
|
|
||||||
util_build_gem b3
|
|
||||||
util_setup_spec_fetcher @a1, @a2, @a3a, a4, @b2, b3
|
|
||||||
|
|
||||||
Gem::Specification.remove_spec @a1
|
fetcher.spec 'a', '3.a'
|
||||||
Gem::Specification.remove_spec @a2
|
fetcher.spec 'b', 2
|
||||||
Gem::Specification.remove_spec a4
|
end
|
||||||
Gem::Specification.remove_spec b3
|
|
||||||
|
|
||||||
assert_equal [[@a3a, a4.version], [@b2, b3.version]],
|
expected = [
|
||||||
Gem::Specification.outdated_and_latest_version.to_a
|
[specs['a-3.a'], v(4)],
|
||||||
|
[specs['b-2'], v(3)],
|
||||||
|
]
|
||||||
|
|
||||||
|
assert_equal expected, Gem::Specification.outdated_and_latest_version.to_a
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_remove_spec
|
def test_self_remove_spec
|
||||||
|
@ -1062,7 +1059,7 @@ dependencies: []
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_add_dependency_with_type
|
def test_add_dependency_with_type
|
||||||
gem = quick_spec "awesome", "1.0" do |awesome|
|
gem = util_spec "awesome", "1.0" do |awesome|
|
||||||
awesome.add_dependency true
|
awesome.add_dependency true
|
||||||
awesome.add_dependency :gem_name
|
awesome.add_dependency :gem_name
|
||||||
end
|
end
|
||||||
|
@ -1071,7 +1068,7 @@ dependencies: []
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_add_dependency_with_type_explicit
|
def test_add_dependency_with_type_explicit
|
||||||
gem = quick_spec "awesome", "1.0" do |awesome|
|
gem = util_spec "awesome", "1.0" do |awesome|
|
||||||
awesome.add_development_dependency "monkey"
|
awesome.add_development_dependency "monkey"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1370,7 +1367,7 @@ dependencies: []
|
||||||
|
|
||||||
assert_empty @gem.dependent_gems
|
assert_empty @gem.dependent_gems
|
||||||
|
|
||||||
bonobo = quick_spec 'bonobo'
|
bonobo = util_spec 'bonobo'
|
||||||
|
|
||||||
expected = [
|
expected = [
|
||||||
[@gem, @bonobo, [bonobo]],
|
[@gem, @bonobo, [bonobo]],
|
||||||
|
@ -1719,7 +1716,7 @@ dependencies: []
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_prerelease_spec_adds_required_rubygems_version
|
def test_prerelease_spec_adds_required_rubygems_version
|
||||||
@prerelease = quick_spec('tardis', '2.2.0.a')
|
@prerelease = util_spec('tardis', '2.2.0.a')
|
||||||
refute @prerelease.required_rubygems_version.satisfied_by?(Gem::Version.new('1.3.1'))
|
refute @prerelease.required_rubygems_version.satisfied_by?(Gem::Version.new('1.3.1'))
|
||||||
assert @prerelease.required_rubygems_version.satisfied_by?(Gem::Version.new('1.4.0'))
|
assert @prerelease.required_rubygems_version.satisfied_by?(Gem::Version.new('1.4.0'))
|
||||||
end
|
end
|
||||||
|
@ -2649,48 +2646,30 @@ WARNING: licenses is empty. Use a license abbreviation from:
|
||||||
# KEEP a-3-x86-other_platform-1
|
# KEEP a-3-x86-other_platform-1
|
||||||
|
|
||||||
def test_latest_specs
|
def test_latest_specs
|
||||||
util_clear_gems
|
spec_fetcher do |fetcher|
|
||||||
util_setup_fake_fetcher
|
fetcher.spec 'a', 1 do |s|
|
||||||
|
s.platform = Gem::Platform.new 'x86-my_platform1'
|
||||||
|
end
|
||||||
|
|
||||||
quick_spec 'p', '1'
|
fetcher.spec 'a', 2
|
||||||
|
|
||||||
p1_curr = quick_spec 'p', '1' do |spec|
|
fetcher.spec 'a', 2 do |s|
|
||||||
spec.platform = Gem::Platform::CURRENT
|
s.platform = Gem::Platform.new 'x86-my_platform1'
|
||||||
|
end
|
||||||
|
|
||||||
|
fetcher.spec 'a', 2 do |s|
|
||||||
|
s.platform = Gem::Platform.new 'x86-other_platform1'
|
||||||
|
end
|
||||||
|
|
||||||
|
fetcher.spec 'a', 3 do |s|
|
||||||
|
s.platform = Gem::Platform.new 'x86-other_platform1'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
quick_spec @a1.name, @a1.version do |s|
|
|
||||||
s.platform = Gem::Platform.new 'x86-my_platform1'
|
|
||||||
end
|
|
||||||
|
|
||||||
quick_spec @a1.name, @a1.version do |s|
|
|
||||||
s.platform = Gem::Platform.new 'x86-third_platform1'
|
|
||||||
end
|
|
||||||
|
|
||||||
quick_spec @a2.name, @a2.version do |s|
|
|
||||||
s.platform = Gem::Platform.new 'x86-my_platform1'
|
|
||||||
end
|
|
||||||
|
|
||||||
quick_spec @a2.name, @a2.version do |s|
|
|
||||||
s.platform = Gem::Platform.new 'x86-other_platform1'
|
|
||||||
end
|
|
||||||
|
|
||||||
quick_spec @a2.name, @a2.version.bump do |s|
|
|
||||||
s.platform = Gem::Platform.new 'x86-other_platform1'
|
|
||||||
end
|
|
||||||
|
|
||||||
Gem::Specification.remove_spec @b2
|
|
||||||
Gem::Specification.remove_spec @pl1
|
|
||||||
|
|
||||||
expected = %W[
|
expected = %W[
|
||||||
a-2
|
a-2
|
||||||
a-2-x86-my_platform-1
|
a-2-x86-my_platform-1
|
||||||
a-3-x86-other_platform-1
|
a-3-x86-other_platform-1
|
||||||
a_evil-9
|
|
||||||
c-1.2
|
|
||||||
dep_x-1
|
|
||||||
p-1
|
|
||||||
#{p1_curr.full_name}
|
|
||||||
x-1
|
|
||||||
]
|
]
|
||||||
|
|
||||||
latest_specs = Gem::Specification.latest_specs.map(&:full_name).sort
|
latest_specs = Gem::Specification.latest_specs.map(&:full_name).sort
|
||||||
|
@ -2857,7 +2836,7 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
def util_setup_deps
|
def util_setup_deps
|
||||||
@gem = quick_spec "awesome", "1.0" do |awesome|
|
@gem = util_spec "awesome", "1.0" do |awesome|
|
||||||
awesome.add_runtime_dependency "bonobo", []
|
awesome.add_runtime_dependency "bonobo", []
|
||||||
awesome.add_development_dependency "monkey", []
|
awesome.add_development_dependency "monkey", []
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,7 +27,7 @@ class TestGemUninstaller < Gem::InstallerTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_ask_if_ok
|
def test_ask_if_ok
|
||||||
c = quick_spec 'c'
|
c = util_spec 'c'
|
||||||
|
|
||||||
uninstaller = Gem::Uninstaller.new nil
|
uninstaller = Gem::Uninstaller.new nil
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue