summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
-rw-r--r--test/rubygems/test_gem.rb182
-rw-r--r--test/rubygems/test_gem_available_set.rb19
-rw-r--r--test/rubygems/test_gem_command.rb55
-rw-r--r--test/rubygems/test_gem_commands_cert_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_contents_command.rb49
-rw-r--r--test/rubygems/test_gem_commands_environment_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_help_command.rb7
-rw-r--r--test/rubygems/test_gem_commands_install_command.rb107
-rw-r--r--test/rubygems/test_gem_commands_open_command.rb46
-rw-r--r--test/rubygems/test_gem_commands_setup_command.rb9
-rw-r--r--test/rubygems/test_gem_commands_uninstall_command.rb36
-rw-r--r--test/rubygems/test_gem_commands_update_command.rb63
-rw-r--r--test/rubygems/test_gem_commands_yank_command.rb4
-rw-r--r--test/rubygems/test_gem_config_file.rb26
-rw-r--r--test/rubygems/test_gem_dependency.rb138
-rw-r--r--test/rubygems/test_gem_dependency_installer.rb238
-rw-r--r--test/rubygems/test_gem_ext_builder.rb13
-rw-r--r--test/rubygems/test_gem_ext_ext_conf_builder.rb4
-rw-r--r--test/rubygems/test_gem_gemcutter_utilities.rb9
-rw-r--r--test/rubygems/test_gem_impossible_dependencies_error.rb32
-rw-r--r--test/rubygems/test_gem_install_update_options.rb34
-rw-r--r--test/rubygems/test_gem_installer.rb83
-rw-r--r--test/rubygems/test_gem_local_remote_options.rb13
-rw-r--r--test/rubygems/test_gem_name_tuple.rb7
-rw-r--r--test/rubygems/test_gem_package.rb19
-rw-r--r--test/rubygems/test_gem_remote_fetcher.rb66
-rw-r--r--test/rubygems/test_gem_request.rb136
-rw-r--r--test/rubygems/test_gem_request_connection_pools.rb120
-rw-r--r--test/rubygems/test_gem_request_set.rb246
-rw-r--r--test/rubygems/test_gem_request_set_gem_dependency_api.rb182
-rw-r--r--test/rubygems/test_gem_request_set_lockfile.rb383
-rw-r--r--test/rubygems/test_gem_requirement.rb13
-rw-r--r--test/rubygems/test_gem_resolver.rb132
-rw-r--r--test/rubygems/test_gem_resolver_activation_request.rb10
-rw-r--r--test/rubygems/test_gem_resolver_api_set.rb4
-rw-r--r--test/rubygems/test_gem_resolver_api_specification.rb40
-rw-r--r--test/rubygems/test_gem_resolver_best_set.rb57
-rw-r--r--test/rubygems/test_gem_resolver_composed_set.rb27
-rw-r--r--test/rubygems/test_gem_resolver_conflict.rb32
-rw-r--r--test/rubygems/test_gem_resolver_dependency_request.rb64
-rw-r--r--test/rubygems/test_gem_resolver_git_set.rb26
-rw-r--r--test/rubygems/test_gem_resolver_git_specification.rb12
-rw-r--r--test/rubygems/test_gem_resolver_index_set.rb30
-rw-r--r--test/rubygems/test_gem_resolver_installer_set.rb155
-rw-r--r--test/rubygems/test_gem_resolver_lock_set.rb18
-rw-r--r--test/rubygems/test_gem_resolver_lock_specification.rb13
-rw-r--r--test/rubygems/test_gem_resolver_specification.rb32
-rw-r--r--test/rubygems/test_gem_resolver_vendor_set.rb18
-rw-r--r--test/rubygems/test_gem_security_policy.rb4
-rw-r--r--test/rubygems/test_gem_server.rb73
-rw-r--r--test/rubygems/test_gem_source.rb18
-rw-r--r--test/rubygems/test_gem_source_git.rb27
-rw-r--r--test/rubygems/test_gem_source_installed.rb8
-rw-r--r--test/rubygems/test_gem_source_lock.rb4
-rw-r--r--test/rubygems/test_gem_source_specific_file.rb4
-rw-r--r--test/rubygems/test_gem_source_vendor.rb4
-rw-r--r--test/rubygems/test_gem_specification.rb152
-rw-r--r--test/rubygems/test_gem_stub_specification.rb94
-rw-r--r--test/rubygems/test_gem_uninstaller.rb23
-rw-r--r--test/rubygems/test_gem_unsatisfiable_dependency_error.rb32
-rw-r--r--test/rubygems/test_kernel.rb6
-rw-r--r--test/rubygems/test_require.rb60
62 files changed, 3133 insertions, 387 deletions
@@ -75,6 +75,21 @@ class TestGem < Gem::TestCase
end
end
def test_require_missing
save_loaded_features do
assert_raises ::LoadError do
@@ -216,6 +231,58 @@ class TestGem < Gem::TestCase
end
end
def test_self_default_sources
assert_equal %w[https://rubygems.org/], Gem.default_sources
end
@@ -816,6 +883,23 @@ class TestGem < Gem::TestCase
assert_match %r%Could not find 'b' %, e.message
end
def test_self_use_paths
util_ensure_gem_dirs
@@ -951,6 +1035,30 @@ class TestGem < Gem::TestCase
end
end
def test_load_plugins
skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7"
plugin_path = File.join "lib", "rubygems_plugin.rb"
@@ -1251,13 +1359,28 @@ class TestGem < Gem::TestCase
end
def test_use_gemdeps
rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], nil
spec = util_spec 'a', 1
refute spec.activated?
- open 'Gemfile', 'w' do |io|
io.write 'gem "a"'
end
@@ -1268,6 +1391,29 @@ class TestGem < Gem::TestCase
ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
end
def test_use_gemdeps_automatic
skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7"
rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-'
@@ -1287,6 +1433,17 @@ class TestGem < Gem::TestCase
ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
end
def test_use_gemdeps_disabled
rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], ''
@@ -1294,7 +1451,7 @@ class TestGem < Gem::TestCase
refute spec.activated?
- open 'Gemfile', 'w' do |io|
io.write 'gem "a"'
end
@@ -1305,6 +1462,27 @@ class TestGem < Gem::TestCase
ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
end
def test_use_gemdeps_specific
skip 'Insecure operation - read' if RUBY_VERSION <= "1.8.7"
rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], 'x'
@@ -3,6 +3,7 @@ require 'rubygems/available_set'
require 'rubygems/security'
class TestGemAvailableSet < Gem::TestCase
def setup
super
@@ -23,22 +24,24 @@ class TestGemAvailableSet < Gem::TestCase
end
def test_find_all
- a1, a1_gem = util_gem 'a', 1
- source = Gem::Source::SpecificFile.new a1_gem
set = Gem::AvailableSet.new
- set.add a1, source
dep = Gem::Resolver::DependencyRequest.new dep('a'), nil
- specs = set.find_all dep
-
- spec = specs.first
- assert_kind_of Gem::Resolver::LocalSpecification, spec
- assert_equal 'a-1', spec.full_name
end
def test_match_platform
@@ -184,5 +184,60 @@ class TestGemCommand < Gem::TestCase
assert_equal ['-h', 'command'], args
end
end
@@ -179,6 +179,7 @@ Added '/CN=alternate/DC=example'
assert_empty @ui.error
assert_path_exists File.join(@tempdir, 'gem-public_cert.pem')
end
def test_execute_build_encrypted_key
@@ -9,8 +9,8 @@ class TestGemCommandsContentsCommand < Gem::TestCase
@cmd = Gem::Commands::ContentsCommand.new
end
- def gem name
- spec = quick_gem name do |gem|
gem.files = %W[lib/#{name}.rb Rakefile]
end
write_file File.join(*%W[gems #{spec.full_name} lib #{name}.rb])
@@ -135,6 +135,40 @@ class TestGemCommandsContentsCommand < Gem::TestCase
assert_equal "", @ui.error
end
def test_execute_no_prefix
@cmd.options[:args] = %w[foo]
@cmd.options[:prefix] = false
@@ -183,13 +217,22 @@ lib/foo.rb
assert @cmd.options[:prefix]
assert_empty @cmd.options[:specdirs]
assert_nil @cmd.options[:version]
- @cmd.send :handle_options, %w[-l -s foo --version 0.0.2 --no-prefix]
assert @cmd.options[:lib_only]
refute @cmd.options[:prefix]
assert_equal %w[foo], @cmd.options[:specdirs]
assert_equal Gem::Requirement.new('0.0.2'), @cmd.options[:version]
end
end
@@ -28,6 +28,7 @@ class TestGemCommandsEnvironmentCommand < Gem::TestCase
assert_match %r|RUBYGEMS PREFIX: |, @ui.output
assert_match %r|RUBY EXECUTABLE:.*#{RbConfig::CONFIG['ruby_install_name']}|,
@ui.output
assert_match %r|EXECUTABLE DIRECTORY:|, @ui.output
assert_match %r|RUBYGEMS PLATFORMS:|, @ui.output
assert_match %r|- #{Gem::Platform.local}|, @ui.output
@@ -22,6 +22,13 @@ class TestGemCommandsHelpCommand < Gem::TestCase
end
end
def test_gem_help_platforms
util_gem 'platforms' do |out, err|
assert_match(/x86-freebsd/, out)
@@ -24,6 +24,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase
Gem::Command.build_args = @orig_args
File.unlink @gemdeps if File.file? @gemdeps
end
def test_execute_exclude_prerelease
@@ -194,6 +195,32 @@ class TestGemCommandsInstallCommand < Gem::TestCase
assert_match(%r!Unable to download data from http://not-there.nothing!, errs.shift)
end
def test_execute_nonexistent_with_hint
misspelled = "nonexistent_with_hint"
correctly_spelled = "non_existent_with_hint"
@@ -238,7 +265,10 @@ ERROR: Possible alternatives: non_existent_with_hint
assert_equal 2, e.exit_code
end
- expected = ["ERROR: Could not find a valid gem 'non-existent_with-hint' (>= 0) in any repository", "ERROR: Possible alternatives: nonexistent-with_hint"]
output = @ui.error.split "\n"
@@ -535,6 +565,11 @@ ERROR: Possible alternatives: non_existent_with_hint
end
def test_install_gem_ignore_dependencies_both
spec = quick_spec 'a', 2
util_build_gem spec
@@ -546,6 +581,8 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.install_gem 'a', '>= 0'
assert_equal %w[a-2], @cmd.installed_specs.map { |s| s.full_name }
end
def test_install_gem_ignore_dependencies_remote
@@ -622,8 +659,8 @@ ERROR: Possible alternatives: non_existent_with_hint
end
assert_equal 2, e.exit_code
- assert_match %r!Could not find a valid gem 'blah' \(>= 0\)!, @ui.error
- assert_match %r!Unable to download data from http://not-there\.nothing!, @ui.error
end
def test_show_source_problems_even_on_success
@@ -648,7 +685,7 @@ ERROR: Possible alternatives: non_existent_with_hint
e = @ui.error
- x = "WARNING: Unable to pull data from 'http://nonexistent.example': no data for http://nonexistent.example/latest_specs.4.8.gz (http://nonexistent.example/latest_specs.4.8.gz)\n"
assert_equal x, e
end
@@ -672,6 +709,56 @@ ERROR: Possible alternatives: non_existent_with_hint
assert_equal %w[], @cmd.installed_specs.map { |spec| spec.full_name }
assert_match "Using a (2)", @ui.output
end
def test_execute_installs_from_a_gemdeps
@@ -885,6 +972,18 @@ ERROR: Possible alternatives: non_existent_with_hint
assert_equal 'gem.deps.rb', @cmd.options[:gemdeps]
end
def test_handle_options_without
@cmd.handle_options %w[--without test]
@@ -0,0 +1,46 @@
@@ -111,6 +111,12 @@ class TestGemCommandsSetupCommand < Gem::TestCase
end
expected = <<-EXPECTED
=== 2.0.2 / 2013-03-06
* Bug fixes:
@@ -118,6 +124,9 @@ class TestGemCommandsSetupCommand < Gem::TestCase
EXPECTED
assert_equal expected, @ui.output
ensure
capture_io do
@@ -239,6 +239,42 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
assert_equal nil, @cmd.options[:install_dir]
assert_equal true, @cmd.options[:user_install]
assert_equal Gem::Requirement.default, @cmd.options[:version]
end
end
@@ -52,6 +52,30 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
assert_empty out
end
def test_execute_system
spec_fetcher do |fetcher|
fetcher.gem 'rubygems-update', 9 do |s| s.files = %w[setup.rb] end
@@ -266,6 +290,30 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
assert_empty out
end
def test_execute_named_up_to_date
spec_fetcher do |fetcher|
fetcher.spec 'a', 2
@@ -437,6 +485,21 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
assert_equal expected, @cmd.options
end
def test_update_rubygems_arguments
@cmd.options[:system] = true
@@ -18,7 +18,7 @@ class TestGemCommandsYankCommand < Gem::TestCase
@cmd.handle_options %w[a --version 1.0 --platform x86-darwin -k KEY]
assert_equal %w[a], @cmd.options[:args]
- assert_equal 'KEY', @cmd.options[:key]
assert_nil @cmd.options[:platform]
assert_equal req('= 1.0'), @cmd.options[:version]
end
@@ -61,7 +61,7 @@ class TestGemCommandsYankCommand < Gem::TestCase
@cmd.options[:args] = %w[a]
@cmd.options[:version] = req('= 1.0')
- @cmd.options[:key] = 'KEY'
use_ui @ui do
@cmd.execute
@@ -234,16 +234,19 @@ if you believe they were disclosed to a third party.
end
def test_handle_arguments_debug
- old_dollar_DEBUG = $DEBUG
assert_equal false, $DEBUG
args = %w[--debug]
- @cfg.handle_arguments args
assert_equal true, $DEBUG
ensure
- $DEBUG = old_dollar_DEBUG
end
def test_handle_arguments_override
@@ -377,6 +380,9 @@ if you believe they were disclosed to a third party.
fp.puts ":verbose: false"
fp.puts ":sources:"
fp.puts " - http://more-gems.example.com"
fp.puts "install: --wrappers"
end
@@ -399,6 +405,10 @@ if you believe they were disclosed to a third party.
assert_equal false, @cfg.update_sources, 'update_sources'
assert_equal false, @cfg.verbose, 'verbose'
assert_equal '--wrappers --no-rdoc', @cfg[:install], 'install'
assert_equal %w[http://even-more-gems.example.com], Gem.sources
@@ -409,11 +419,13 @@ if you believe they were disclosed to a third party.
fp.puts "some-non-yaml-hash-string"
end
- # Avoid writing stuff to output when running tests
- Gem::ConfigFile.class_eval { def warn(args); end }
- # This should not raise exception
- util_config_file
end
def test_load_ssl_verify_mode_from_config
@@ -2,6 +2,7 @@ require 'rubygems/test_case'
require 'rubygems/dependency'
class TestGemDependency < Gem::TestCase
def test_initialize
d = dep "pkg", "> 1.0"
@@ -28,6 +29,16 @@ class TestGemDependency < Gem::TestCase
assert_equal req(">= 0"), d.requirement
end
def test_initialize_type
assert_equal :runtime, dep("pkg").type
assert_equal :development, dep("pkg", [], :development).type
@@ -115,6 +126,106 @@ class TestGemDependency < Gem::TestCase
refute_equal dep("pkg", :development), dep("pkg", :runtime), "type"
end
def test_merge
a1 = dep 'a', '~> 1.0'
a2 = dep 'a', '= 1.0'
@@ -182,6 +293,29 @@ class TestGemDependency < Gem::TestCase
assert dep('a', '= 1').specific?
end
def test_to_specs_suggests_other_versions
a = util_spec 'a', '1.0', 'b' => '>= 1.0'
@@ -197,7 +331,7 @@ class TestGemDependency < Gem::TestCase
dep.to_specs
end
- assert_equal "Could not find 'a' (= 2.0) - did find: [a-1.0]", e.message
end
def test_to_specs_indicates_total_gem_set_size
@@ -215,7 +349,7 @@ class TestGemDependency < Gem::TestCase
dep.to_specs
end
- assert_equal "Could not find 'b' (= 2.0) among 1 total gem(s)", e.message
end
@@ -126,6 +126,27 @@ class TestGemDependencyInstaller < Gem::TestCase
assert_equal [p1a], inst.installed_gems
end
def test_install_when_only_prerelease
p1a, gem = util_gem 'p', '1.a'
@@ -138,7 +159,9 @@ class TestGemDependencyInstaller < Gem::TestCase
dep = Gem::Dependency.new "p"
inst = Gem::DependencyInstaller.new
- inst.install dep
assert_equal %w[], Gem::Specification.map(&:full_name)
assert_equal [], inst.installed_gems
@@ -291,7 +314,7 @@ class TestGemDependencyInstaller < Gem::TestCase
Gem.done_installing do |installer, specs|
done_installing_ran = true
- assert_equal inst, installer
assert_equal [@a1, @b1], specs
end
@@ -455,6 +478,20 @@ class TestGemDependencyInstaller < Gem::TestCase
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
end
def test_install_local_dependency
util_setup_gems
@@ -538,6 +575,23 @@ class TestGemDependencyInstaller < Gem::TestCase
assert_equal %w[a-1 e-1], inst.installed_gems.map { |s| s.full_name }
end
def test_install_env_shebang
util_setup_gems
@@ -682,7 +736,7 @@ class TestGemDependencyInstaller < Gem::TestCase
inst.install 'b'
end
- expected = "Unable to resolve dependency: 'b (= 1)' requires 'a (>= 0)'"
assert_equal expected, e.message
end
@@ -796,10 +850,10 @@ class TestGemDependencyInstaller < Gem::TestCase
s.platform = Gem::Platform.new %w[cpu other_platform 1]
end
- util_clear_gems
-
si = util_setup_spec_fetcher @a1, a2_o
@fetcher.data['http://gems.example.com/gems/yaml'] = si.to_yaml
a1_data = nil
@@ -1043,165 +1097,6 @@ class TestGemDependencyInstaller < Gem::TestCase
assert_kind_of Gem::SourceFetchProblem, installer.errors.first
end
- def assert_resolve expected, *specs
- util_clear_gems
- util_setup_spec_fetcher(*specs)
- Gem::Specification.reset
-
- inst = Gem::DependencyInstaller.new
- inst.find_spec_by_name_and_version specs.first.name
- inst.gather_dependencies
-
- actual = inst.gems_to_install.map { |s| s.full_name }
- assert_equal expected, actual
- end
-
- def assert_resolve_pre expected, *specs
- util_clear_gems
-
- util_setup_spec_fetcher(*specs)
- Gem::Specification.reset
-
- spec = specs.first
-
- inst = Gem::DependencyInstaller.new :prerelease => true
- inst.find_spec_by_name_and_version spec.name, spec.version
- inst.gather_dependencies
-
- actual = inst.gems_to_install.map { |s| s.full_name }
- assert_equal expected, actual
- end
-
- def test_gather_dependencies
- util_setup_gems
- util_reset_gems
-
- inst = Gem::DependencyInstaller.new
- inst.find_spec_by_name_and_version 'b'
- inst.gather_dependencies
-
- assert_equal %w[a-1 b-1], inst.gems_to_install.map { |s| s.full_name }
- end
-
- ##
- # [A1] depends on
- # [B] > 0 (satisfied by 2.0)
- # [B1] depends on
- # [C] > 0 (satisfied by 1.0)
- # [B2] depends on nothing!
- # [C1] depends on nothing
-
- def test_gather_dependencies_dropped
- a1, = util_spec 'a', '1', 'b' => nil
- b1, = util_spec 'b', '1', 'c' => nil
- b2, = util_spec 'b', '2'
- c1, = util_spec 'c', '1'
-
- assert_resolve %w[b-2 a-1], a1, b1, b2, c1
- end
-
- ##
- # [A] depends on
- # [B] >= 1.0 (satisfied by 1.1) depends on
- # [Z]
- # [C] >= 1.0 depends on
- # [B] = 1.0
- #
- # and should backtrack to resolve using b-1.0, pruning Z from the
- # resolve.
-
- def test_gather_dependencies_raggi_the_edgecase_generator
- a, _ = util_spec 'a', '1.0', 'b' => '>= 1.0', 'c' => '>= 1.0'
- b1, _ = util_spec 'b', '1.0'
- b2, _ = util_spec 'b', '1.1', 'z' => '>= 1.0'
- c, _ = util_spec 'c', '1.0', 'b' => '= 1.0'
-
- assert_resolve %w[b-1.0 c-1.0 a-1.0], a, b1, b2, c
- end
-
- ##
- # [A] depends on
- # [B] >= 1.0 (satisfied by 2.0)
- # [C] = 1.0 depends on
- # [B] ~> 1.0
- #
- # and should resolve using b-1.0
-
- def test_gather_dependencies_over
- a, _ = util_spec 'a', '1.0', 'b' => '>= 1.0', 'c' => '= 1.0'
- b1, _ = util_spec 'b', '1.0'
- b2, _ = util_spec 'b', '2.0'
- c, _ = util_spec 'c', '1.0', 'b' => '~> 1.0'
-
- assert_resolve %w[b-1.0 c-1.0 a-1.0], a, b1, b2, c
- end
-
- ##
- # [A] depends on
- # [B] ~> 1.0 (satisfied by 1.1)
- # [C] = 1.0 depends on
- # [B] = 1.0
- #
- # and should resolve using b-1.0
- #
- # TODO: this is not under, but over... under would require depth
- # first resolve through a dependency that is later pruned.
-
- def test_gather_dependencies_under
- a, _ = util_spec 'a', '1.0', 'b' => '~> 1.0', 'c' => '= 1.0'
- b10, _ = util_spec 'b', '1.0'
- b11, _ = util_spec 'b', '1.1'
- c, _ = util_spec 'c', '1.0', 'b' => '= 1.0'
-
- assert_resolve %w[b-1.0 c-1.0 a-1.0], a, b10, b11, c
- end
-
- # under
- #
- # [A] depends on
- # [B] ~> 1.0 (satisfied by 1.0)
- # [C] = 1.0 depends on
- # [B] = 2.0
-
- def test_gather_dependencies_divergent
- a, _ = util_spec 'a', '1.0', 'b' => '~> 1.0', 'c' => '= 1.0'
- b1, _ = util_spec 'b', '1.0'
- b2, _ = util_spec 'b', '2.0'
- c, _ = util_spec 'c', '1.0', 'b' => '= 2.0'
-
- assert_raises Gem::DependencyError do
- assert_resolve :ignored, a, b1, b2, c
- end
- end
-
- def test_gather_dependencies_platform_alternate
- util_setup_wxyz
- util_set_arch 'cpu-my_platform1'
-
- assert_resolve %w[x-1-cpu-my_platform-1 w-1], @w1, @x1_m
- end
-
- def test_gather_dependencies_platform_bump
- util_setup_wxyz
-
- assert_resolve %w[y-1 z-1], @z1, @y1
- end
-
- def test_gather_dependencies_prerelease
- util_setup_gems
- util_setup_c1_pre
-
- assert_resolve_pre %w[a-1.a b-1 c-1.a], @c1_pre, @a1_pre, @b1
- end
-
- def test_gather_dependencies_old_required
- util_setup_d
- e1, = util_spec 'e', '1', 'd' => '= 1'
- util_clear_gems
-
- assert_resolve %w[d-1 e-1], e1, @d1, @d2
- end
-
def test_resolve_dependencies
util_setup_gems
@@ -1232,6 +1127,21 @@ class TestGemDependencyInstaller < Gem::TestCase
assert_equal %w[b-1], requests
end
def util_write_a1_bin
write_file File.join('gems', 'a-1', 'bin', 'a_bin') do |fp|
fp.puts "#!/usr/bin/ruby"
@@ -132,6 +132,17 @@ install:
assert_path_exists File.join @spec.gem_dir, 'lib', 'a', 'b.rb'
end
def test_build_extensions_install_ext_only
class << Gem
alias orig_install_extension_in_lib install_extension_in_lib
@@ -226,7 +237,7 @@ install:
gem_make_out = File.join @spec.extension_dir, 'gem_make.out'
- assert_match %r%#{Regexp.escape Gem.ruby} extconf\.rb%,
File.read(gem_make_out)
assert_match %r%: No such file%,
File.read(gem_make_out)
@@ -33,7 +33,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase
assert_same result, output
end
- assert_match(/^#{Gem.ruby} extconf.rb/, output[0])
assert_equal "creating Makefile\n", output[1]
assert_contains_make_command 'clean', output[2]
assert_contains_make_command '', output[4]
@@ -106,7 +106,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase
assert_equal 'extconf failed, exit code 1', error.message
- assert_equal("#{Gem.ruby} extconf.rb", output[0])
assert_path_exists File.join @dest_path, 'mkmf.log'
end
@@ -148,6 +148,15 @@ class TestGemGemcutterUtilities < Gem::TestCase
assert_equal "", @sign_in_ui.output
end
def test_sign_in_with_other_credentials_doesnt_overwrite_other_keys
api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
other_api_key = 'f46dbb18bb6a9c97cdc61b5b85c186a17403cdcbf'
@@ -28,14 +28,30 @@ class TestGemImpossibleDependenciesError < Gem::TestCase
expected = <<-EXPECTED
rye-0.9.8 requires net-ssh (>= 2.0.13) but it conflicted:
- Activated net-ssh-2.6.5 via:
- net-ssh-2.6.5 (>= 2.0.13), rye-0.9.8 (= 0.9.8)
- instead of (~> 2.2.2) via:
- net-ssh-2.6.5 (>= 2.0.13), rye-0.9.8 (= 0.9.8)
- Activated net-ssh-2.2.2 via:
- net-ssh-2.2.2 (>= 2.0.13), rye-0.9.8 (= 0.9.8)
- instead of (>= 2.6.5) via:
- net-ssh-2.2.2 (>= 2.0.13), rye-0.9.8 (= 0.9.8)
EXPECTED
assert_equal expected, error.message
@@ -17,6 +17,7 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
def test_add_install_update_options
args = %w[
--document
--format-exec
--ignore-dependencies
--rdoc
@@ -25,6 +26,7 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
-f
-i /install_to
-w
]
args.concat %w[-P HighSecurity] if defined?(OpenSSL::SSL)
@@ -32,6 +34,12 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
assert @cmd.handles?(args)
end
def test_doc
@cmd.handle_options %w[--doc]
@@ -147,4 +155,30 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
ensure
FileUtils.chmod 0755, @gemhome
end
end
@@ -188,6 +188,56 @@ gem 'other', version
assert_match %r|generated by RubyGems|, wrapper
end unless Gem.win_platform?
def test_ensure_dependency
util_spec 'a'
@@ -574,6 +624,9 @@ gem 'other', version
def test_generate_bin_symlink_win32
old_win_platform = Gem.win_platform?
Gem.win_platform = true
@installer.wrappers = false
util_make_exec
@installer.gem_dir = util_gem_dir
@@ -592,6 +645,8 @@ gem 'other', version
wrapper = File.read installed_exec
assert_match(/generated by RubyGems/, wrapper)
ensure
Gem.win_platform = old_win_platform
end
@@ -1053,7 +1108,7 @@ gem 'other', version
path = File.join(@gemhome, 'gems', 'a-2', 'gem_make.out')
- if File.exists?(path)
puts File.read(path)
puts '-' * 78
end
@@ -1071,6 +1126,16 @@ gem 'other', version
refute @installer.installation_satisfies_dependency?(dep)
end
def test_pre_install_checks_dependencies
@spec.add_dependency 'b', '> 5'
util_setup_gem
@@ -1157,6 +1222,22 @@ gem 'other', version
assert_equal "#!#{Gem.ruby}", shebang
end
def test_shebang_arguments
util_make_exec @spec, "#!/usr/bin/ruby -ws"
@@ -90,6 +90,19 @@ class TestGemLocalRemoteOptions < Gem::TestCase
assert_equal original_sources, Gem.sources
end
def test_update_sources_option
@cmd.add_update_sources_option
@@ -33,5 +33,12 @@ class TestGemNameTuple < Gem::TestCase
assert_equal "a-0.gemspec", n.spec_name
end
end
@@ -638,7 +638,7 @@ class TestGemPackage < Gem::Package::TarTestCase
e.message
io
end
- tf.close!
end
def test_verify_empty
@@ -780,6 +780,23 @@ class TestGemPackage < Gem::Package::TarTestCase
assert_equal @spec, package.spec
end
def util_tar
tar_io = StringIO.new
@@ -244,6 +244,36 @@ gems:
assert File.exist?(a1_cache_gem)
end
def test_download_cached
FileUtils.mv @a1_gem, @cache_dir
@@ -557,6 +587,40 @@ gems:
assert_equal "too many redirects (#{url})", e.message
end
def test_observe_no_proxy_env_single_host
use_ui @ui do
ENV["http_proxy"] = @proxy_uri
@@ -711,6 +775,8 @@ gems:
@proxy_server ||= start_server(PROXY_DATA)
@enable_yaml = true
@enable_zip = false
end
def stop_servers
@@ -11,6 +11,10 @@ class TestGemRequest < Gem::TestCase
PUBLIC_CERT_FILE = cert_path 'public'
SSL_CERT = load_cert 'ssl'
def setup
@proxies = %w[http_proxy HTTP_PROXY http_proxy_user HTTP_PROXY_USER http_proxy_pass HTTP_PROXY_PASS no_proxy NO_PROXY]
@old_proxies = @proxies.map {|k| ENV[k] }
@@ -21,7 +25,7 @@ class TestGemRequest < Gem::TestCase
@proxy_uri = "http://localhost:1234"
@uri = URI('http://example')
- @request = Gem::Request.new @uri, nil, nil, nil
end
def teardown
@@ -33,7 +37,7 @@ class TestGemRequest < Gem::TestCase
def test_initialize_proxy
proxy_uri = 'http://proxy.example.com'
- request = Gem::Request.new @uri, nil, nil, proxy_uri
assert_equal proxy_uri, request.proxy_uri.to_s
end
@@ -41,7 +45,7 @@ class TestGemRequest < Gem::TestCase
def test_initialize_proxy_URI
proxy_uri = 'http://proxy.example.com'
- request = Gem::Request.new @uri, nil, nil, URI(proxy_uri)
assert_equal proxy_uri, request.proxy_uri.to_s
end
@@ -51,7 +55,7 @@ class TestGemRequest < Gem::TestCase
ENV['http_proxy_user'] = 'foo'
ENV['http_proxy_pass'] = 'bar'
- request = Gem::Request.new @uri, nil, nil, nil
proxy = request.proxy_uri
@@ -62,7 +66,7 @@ class TestGemRequest < Gem::TestCase
def test_initialize_proxy_ENV_https
ENV['https_proxy'] = @proxy_uri
- request = Gem::Request.new URI('https://example'), nil, nil, nil
proxy = request.proxy_uri
@@ -72,13 +76,13 @@ class TestGemRequest < Gem::TestCase
def test_configure_connection_for_https
connection = Net::HTTP.new 'localhost', 443
- request = Gem::Request.new URI('https://example'), nil, nil, nil
-
- def request.add_rubygems_trusted_certs store
- store.add_cert TestGemRequest::PUBLIC_CERT
- end
- request.configure_connection_for_https connection
cert_store = connection.cert_store
@@ -91,13 +95,13 @@ class TestGemRequest < Gem::TestCase
connection = Net::HTTP.new 'localhost', 443
- request = Gem::Request.new URI('https://example'), nil, nil, nil
- def request.add_rubygems_trusted_certs store
- store.add_cert TestGemRequest::PUBLIC_CERT
- end
-
- request.configure_connection_for_https connection
cert_store = connection.cert_store
@@ -109,16 +113,18 @@ class TestGemRequest < Gem::TestCase
def test_get_proxy_from_env_fallback
ENV['http_proxy'] = @proxy_uri
-
- proxy = @request.get_proxy_from_env 'https'
assert_equal URI(@proxy_uri), proxy
end
def test_get_proxy_from_env_https
ENV['https_proxy'] = @proxy_uri
- proxy = @request.get_proxy_from_env 'https'
assert_equal URI(@proxy_uri), proxy
end
@@ -127,8 +133,9 @@ class TestGemRequest < Gem::TestCase
ENV['http_proxy'] = @proxy_uri
ENV['http_proxy_user'] = 'foo\user'
ENV['http_proxy_pass'] = 'my bar'
- proxy = @request.get_proxy_from_env
assert_equal 'foo\user', Gem::UriFormatter.new(proxy.user).unescape
assert_equal 'my bar', Gem::UriFormatter.new(proxy.password).unescape
@@ -138,8 +145,9 @@ class TestGemRequest < Gem::TestCase
ENV['http_proxy'] = @proxy_uri
ENV['http_proxy_user'] = 'foo@user'
ENV['http_proxy_pass'] = 'my@bar'
- proxy = @request.get_proxy_from_env
assert_equal 'foo%40user', proxy.user
assert_equal 'my%40bar', proxy.password
@@ -147,23 +155,26 @@ class TestGemRequest < Gem::TestCase
def test_get_proxy_from_env_normalize
ENV['HTTP_PROXY'] = 'fakeurl:12345'
- assert_equal 'http://fakeurl:12345', @request.get_proxy_from_env.to_s
end
def test_get_proxy_from_env_empty
ENV['HTTP_PROXY'] = ''
ENV.delete 'http_proxy'
- assert_nil @request.get_proxy_from_env
end
def test_fetch
uri = URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}"
- @request = Gem::Request.new(uri, Net::HTTP::Get, nil, nil)
- util_stub_connection_for :body => :junk, :code => 200
- response = @request.fetch
assert_equal 200, response.code
assert_equal :junk, response.body
@@ -171,34 +182,34 @@ class TestGemRequest < Gem::TestCase
def test_fetch_basic_auth
uri = URI.parse "https://user:[email protected]/specs.#{Gem.marshal_version}"
- @request = Gem::Request.new(uri, Net::HTTP::Get, nil, nil)
- conn = util_stub_connection_for :body => :junk, :code => 200
-
- @request.fetch
auth_header = conn.payload['Authorization']
-
assert_equal "Basic #{Base64.encode64('user:pass')}".strip, auth_header
end
def test_fetch_basic_auth_encoded
uri = URI.parse "https://user:%7BDEScede%[email protected]/specs.#{Gem.marshal_version}"
- @request = Gem::Request.new(uri, Net::HTTP::Get, nil, nil)
- conn = util_stub_connection_for :body => :junk, :code => 200
-
- @request.fetch
auth_header = conn.payload['Authorization']
-
assert_equal "Basic #{Base64.encode64('user:{DEScede}pass')}".strip, auth_header
end
def test_fetch_head
uri = URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}"
- @request = Gem::Request.new(uri, Net::HTTP::Get, nil, nil)
- util_stub_connection_for :body => '', :code => 200
-
- response = @request.fetch
assert_equal 200, response.code
assert_equal '', response.body
@@ -207,10 +218,10 @@ class TestGemRequest < Gem::TestCase
def test_fetch_unmodified
uri = URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}"
t = Time.utc(2013, 1, 2, 3, 4, 5)
- @request = Gem::Request.new(uri, Net::HTTP::Get, t, nil)
- conn = util_stub_connection_for :body => '', :code => 304
-
- response = @request.fetch
assert_equal 304, response.code
assert_equal '', response.body
@@ -221,7 +232,7 @@ class TestGemRequest < Gem::TestCase
end
def test_user_agent
- ua = Gem::Request.new(@uri, nil, nil, nil).user_agent
assert_match %r%^RubyGems/\S+ \S+ Ruby/\S+ \(.*?\)%, ua
assert_match %r%RubyGems/#{Regexp.escape Gem::VERSION}%, ua
@@ -236,7 +247,7 @@ class TestGemRequest < Gem::TestCase
Object.send :remove_const, :RUBY_ENGINE if defined?(RUBY_ENGINE)
Object.send :const_set, :RUBY_ENGINE, 'vroom'
- ua = Gem::Request.new(@uri, nil, nil, nil).user_agent
assert_match %r%\) vroom%, ua
ensure
@@ -249,7 +260,7 @@ class TestGemRequest < Gem::TestCase
Object.send :remove_const, :RUBY_ENGINE if defined?(RUBY_ENGINE)
Object.send :const_set, :RUBY_ENGINE, 'ruby'
- ua = Gem::Request.new(@uri, nil, nil, nil).user_agent
assert_match %r%\)%, ua
ensure
@@ -262,7 +273,7 @@ class TestGemRequest < Gem::TestCase
Object.send :remove_const, :RUBY_LEVEL
Object.send :const_set, :RUBY_LEVEL, 5
- ua = Gem::Request.new(@uri, nil, nil, nil).user_agent
assert_match %r% level 5\)%, ua
ensure
@@ -277,7 +288,7 @@ class TestGemRequest < Gem::TestCase
Object.send :remove_const, :RUBY_REVISION if defined?(RUBY_REVISION)
Object.send :const_set, :RUBY_REVISION, 6
- ua = Gem::Request.new(@uri, nil, nil, nil).user_agent
assert_match %r% revision 6\)%, ua
assert_match %r%Ruby/#{Regexp.escape RUBY_VERSION}dev%, ua
@@ -292,7 +303,7 @@ class TestGemRequest < Gem::TestCase
Object.send :const_set, :RUBY_LEVEL, -1
Object.send :remove_const, :RUBY_REVISION if defined?(RUBY_REVISION)
- ua = Gem::Request.new(@uri, nil, nil, nil).user_agent
assert_match %r%\(#{Regexp.escape RUBY_RELEASE_DATE}\)%, ua
ensure
@@ -318,21 +329,24 @@ class TestGemRequest < Gem::TestCase
@orig_RUBY_REVISION = RUBY_REVISION if defined? RUBY_REVISION
end
- def util_stub_connection_for hash
- def @request.connection= conn
- @conn = conn
- end
-
- def @request.connection_for uri
- @conn
- end
-
- @request.connection = Conn.new OpenStruct.new(hash)
end
class Conn
attr_accessor :payload
def initialize(response)
@response = response
self.payload = nil
@@ -0,0 +1,120 @@
@@ -42,6 +42,12 @@ class TestGemRequestSet < Gem::TestCase
fetcher.gem 'a', 2
end
rs = Gem::RequestSet.new
installed = []
@@ -61,6 +67,29 @@ class TestGemRequestSet < Gem::TestCase
assert_path_exists 'gem.deps.rb.lock'
assert rs.remote
end
def test_install_from_gemdeps_install_dir
@@ -153,6 +182,30 @@ DEPENDENCIES
assert_path_exists File.join @gemhome, 'specifications', 'b-1.gemspec'
end
def test_load_gemdeps
rs = Gem::RequestSet.new
@@ -160,10 +213,12 @@ DEPENDENCIES
io.puts 'gem "a"'
io.flush
- rs.load_gemdeps io.path
io
end
- tf.close!
assert_equal [dep('a')], rs.dependencies
@@ -171,6 +226,24 @@ DEPENDENCIES
assert rs.vendor_set
end
def test_load_gemdeps_without_groups
rs = Gem::RequestSet.new
@@ -181,7 +254,7 @@ DEPENDENCIES
rs.load_gemdeps io.path, [:test]
io
end
- tf.close!
assert_empty rs.dependencies
end
@@ -193,12 +266,69 @@ DEPENDENCIES
rs = Gem::RequestSet.new
rs.gem "a"
res = rs.resolve StaticSet.new([a, b])
assert_equal 2, res.size
names = res.map { |s| s.full_name }.sort
assert_equal ["a-2", "b-2"], names
end
def test_resolve_git
@@ -216,7 +346,7 @@ DEPENDENCIES
rs.load_gemdeps io.path
io
end
- tf.close!
res = rs.resolve
assert_equal 1, res.size
@@ -280,7 +410,7 @@ DEPENDENCIES
rs.load_gemdeps io.path
io
end
- tf.close!
res = rs.resolve
assert_equal 2, res.size
@@ -308,6 +438,12 @@ DEPENDENCIES
end
def test_install
spec_fetcher do |fetcher|
fetcher.gem "a", "1", "b" => "= 1"
fetcher.gem "b", "1"
@@ -336,6 +472,8 @@ DEPENDENCIES
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
@@ -358,4 +496,102 @@ DEPENDENCIES
assert_equal %w!b-1 a-1!, installed.map { |s| s.full_name }
end
end
@@ -68,6 +68,22 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_equal [dep('a')], @set.dependencies
assert_equal %w[a], @gda.requires['a']
end
def test_gem_git
@@ -76,6 +92,36 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_equal [dep('a')], @set.dependencies
assert_equal %w[git/a master], @git_set.repositories['a']
end
def test_gem_git_branch
@@ -127,6 +173,23 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_equal %w[git://.com/example/repository.git master],
@git_set.repositories['a']
end
def test_gem_group
@@ -141,6 +204,10 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
@gda.gem 'a', :group => :test
assert_empty @set.dependencies
end
def test_gem_groups
@@ -159,6 +226,10 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
loaded = @vendor_set.load_spec(name, version, Gem::Platform::RUBY, nil)
assert_equal "#{name}-#{version}", loaded.full_name
end
def test_gem_platforms
@@ -254,6 +325,18 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
Gem.win_platform = win_platform
end
def test_gem_platforms_version
with_engine_version 'ruby', '2.0.0' do
@gda.gem 'a', :platforms => :ruby_18
@@ -270,7 +353,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_equal 'unknown platform :unknown', e.message
end
- def test_gem_require
@gda.gem 'a', :require => %w[b c]
@gda.gem 'd', :require => 'e'
@@ -280,7 +363,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_equal %w[e], @gda.requires['d']
end
- def test_gem_require_false
@gda.gem 'a', :require => false
assert_equal [dep('a')], @set.dependencies
@@ -288,7 +371,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_empty @gda.requires
end
- def test_gem_require_without_group
@gda.without_groups << :test
@gda.gem 'a', :group => :test
@@ -302,12 +385,20 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
@gda.gem 'a', '~> 1.0'
assert_equal [dep('a', '~> 1.0')], @set.dependencies
end
def test_gem_requirements
@gda.gem 'b', '~> 1.0', '>= 1.0.2'
assert_equal [dep('b', '~> 1.0', '>= 1.0.2')], @set.dependencies
end
def test_gem_requirements_options
@@ -483,6 +574,16 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_equal %w[git://example/repo.git master], @git_set.repositories['b']
end
def test_group
@gda.group :test do
@gda.gem 'a'
@@ -504,12 +605,12 @@ end
gda = @GDA.new @set, io.path
- gda.load
assert_equal [dep('a'), dep('b')], @set.dependencies
io
end
- tf.close!
end
def test_name_typo
@@ -538,18 +639,42 @@ end
end
def test_platform_mswin
win_platform, Gem.win_platform = Gem.win_platform?, false
- @gda.platform :mswin do
- @gda.gem 'a'
end
assert_empty @set.dependencies
- Gem.win_platform = true
- @gda.platform :mswin do
- @gda.gem 'a'
end
refute_empty @set.dependencies
@@ -570,30 +695,27 @@ end
end
def test_platforms
- win_platform, Gem.win_platform = Gem.win_platform?, false
- @gda.platforms :ruby do
- @gda.gem 'a'
- end
- assert_equal [dep('a')], @set.dependencies
- @gda.platforms :mswin do
- @gda.gem 'b'
end
- assert_equal [dep('a')], @set.dependencies
-
- Gem.win_platform = true
- @gda.platforms :mswin do
- @gda.gem 'c'
end
-
- assert_equal [dep('a'), dep('c')], @set.dependencies
-
- ensure
- Gem.win_platform = win_platform
end
def test_ruby
@@ -647,6 +769,12 @@ end
assert_equal "Your Ruby version is #{RUBY_VERSION}, but your gem.deps.rb requires 1.8.0", e.message
end
def test_source
sources = Gem.sources
@@ -38,6 +38,127 @@ class TestGemRequestSetLockfile < Gem::TestCase
end
end
def test_get
@lockfile.instance_variable_set :@tokens, [:token]
@@ -142,7 +263,106 @@ DEPENDENCIES
assert_equal %w[a-2], lockfile_set.specs.map { |tuple| tuple.full_name }
end
def test_parse_GIT
write_lockfile <<-LOCKFILE
GIT
remote: git://example/a.git
@@ -150,6 +370,7 @@ GIT
specs:
a (2)
b (>= 3)
DEPENDENCIES
a!
@@ -173,7 +394,126 @@ DEPENDENCIES
assert_equal %w[a-2], git_set.specs.values.map { |s| s.full_name }
- assert_equal [dep('b', '>= 3')], git_set.specs.values.first.dependencies
end
def test_parse_PATH
@@ -184,6 +524,7 @@ PATH
remote: #{directory}
specs:
a (1)
DEPENDENCIES
a!
@@ -206,6 +547,28 @@ DEPENDENCIES
assert vendor_set, 'could not find a VendorSet'
assert_equal %w[a-1], vendor_set.specs.values.map { |s| s.full_name }
end
def test_parse_gem_specs_dependency
@@ -853,5 +1216,23 @@ DEPENDENCIES
refute_empty File.read gem_deps_lock_file
end
end
@@ -207,6 +207,14 @@ class TestGemRequirement < Gem::TestCase
end
end
def test_satisfied_by_eh_good
assert_satisfied_by "0.2.33", "= 0.2.33"
assert_satisfied_by "0.2.34", "> 0.2.33"
@@ -277,6 +285,11 @@ class TestGemRequirement < Gem::TestCase
refute_satisfied_by "1.1.pre", "~> 1.1"
refute_satisfied_by "2.0.a", "~> 1.0"
refute_satisfied_by "2.0.a", "~> 2.0"
end
def test_satisfied_by_eh_multiple
@@ -13,6 +13,12 @@ class TestGemResolver < Gem::TestCase
end
def set(*specs)
StaticSet.new(specs)
end
@@ -20,7 +26,7 @@ class TestGemResolver < Gem::TestCase
actual = resolver.resolve
exp = expected.sort_by { |s| s.full_name }
- act = actual.map { |a| a.spec }.sort_by { |s| s.full_name }
msg = "Set of gems was not the same: #{exp.map { |x| x.full_name}.inspect} != #{act.map { |x| x.full_name}.inspect}"
@@ -123,6 +129,30 @@ class TestGemResolver < Gem::TestCase
assert_equal ['b (= 2)'], reqs.to_a.map { |req| req.to_s }
end
def test_requests_ignore_dependencies
a1 = util_spec 'a', 1, 'b' => 2
@@ -140,6 +170,104 @@ class TestGemResolver < Gem::TestCase
assert_empty reqs
end
def test_no_overlap_specificly
a = util_spec "a", '1'
b = util_spec "b", "1"
@@ -215,7 +343,7 @@ class TestGemResolver < Gem::TestCase
res = Gem::Resolver.new([ad], s)
- assert_resolves_to [a2_p1], res
end
def test_only_returns_spec_once
@@ -19,6 +19,16 @@ class TestGemResolverActivationRequest < Gem::TestCase
@req = @DR::ActivationRequest.new @a3, @dep, [@a1, @a2]
end
def test_inspect
assert_match 'a-3', @req.inspect
assert_match 'from a (>= 0)', @req.inspect
@@ -73,13 +73,13 @@ class TestGemResolverAPISet < Gem::TestCase
set.prefetch [a_dep]
- @fetcher.data.delete "#{@dep_uri}?gems=a"
-
expected = [
@DR::APISpecification.new(set, data.first)
]
assert_equal expected, set.find_all(a_dep)
end
def test_find_all_local
@@ -28,6 +28,46 @@ class TestGemResolverAPISpecification < Gem::TestCase
assert_equal expected, spec.dependencies
end
def test_installable_platform_eh
set = Gem::Resolver::APISet.new
data = {
@@ -32,6 +32,26 @@ class TestGemResolverBestSet < Gem::TestCase
assert_equal %w[a-1], found.map { |s| s.full_name }
end
def test_find_all_local
spec_fetcher do |fetcher|
fetcher.spec 'a', 1
@@ -76,5 +96,42 @@ class TestGemResolverBestSet < Gem::TestCase
assert_empty set.sets
end
end
@@ -2,6 +2,33 @@ require 'rubygems/test_case'
class TestGemResolverComposedSet < Gem::TestCase
def test_remote_equals
best_set = Gem::Resolver::BestSet.new
current_set = Gem::Resolver::CurrentSet.new
@@ -22,10 +22,17 @@ class TestGemResolverConflict < Gem::TestCase
Gem::Resolver::Conflict.new child, active
expected = <<-EXPECTED
- Activated net-ssh-2.2.2 via:
- net-ssh-2.2.2 (>= 2.0.13)
- instead of (>= 2.6.5) via:
- net-ssh-2.2.2 (>= 2.0.13), rye-0.9.8 (= 0.9.8)
EXPECTED
assert_equal expected, conflict.explanation
@@ -44,10 +51,15 @@ class TestGemResolverConflict < Gem::TestCase
conflict = @DR::Conflict.new a1_req, activated
expected = <<-EXPECTED
- Activated a-2 via:
- a-2 (= 2)
- instead of (= 1) via:
- user request (gem command or Gemfile)
EXPECTED
assert_equal expected, conflict.explanation
@@ -64,8 +76,8 @@ class TestGemResolverConflict < Gem::TestCase
Gem::Resolver::Conflict.new nil, nil
expected = [
- 'net-ssh-2.2.2 (>= 2.0.13)',
- 'rye-0.9.8 (= 0.9.8)'
]
assert_equal expected, conflict.request_path(child.requester)
@@ -8,6 +8,70 @@ class TestGemResolverDependencyRequest < Gem::TestCase
@DR = Gem::Resolver::DependencyRequest
end
def test_requirement
dependency = dep 'a', '>= 1'
@@ -85,6 +85,32 @@ class TestGemResolverGitSet < Gem::TestCase
assert_empty @set.find_all dependency
end
def test_root_dir
assert_equal Gem.dir, @set.root_dir
@@ -32,6 +32,18 @@ class TestGemResolverGitSpecification < Gem::TestCase
refute_equal g_spec_a, i_spec
end
def test_install
git_gem 'a', 1
@@ -22,6 +22,8 @@ class TestGemResolverIndexSet < Gem::TestCase
fetcher = set.instance_variable_get :@f
refute_same Gem::SpecFetcher.fetcher, fetcher
end
def test_find_all
@@ -31,7 +33,7 @@ class TestGemResolverIndexSet < Gem::TestCase
fetcher.spec 'b', 1
end
- set = @DR::BestSet.new
dependency = dep 'a', '~> 1'
@@ -49,7 +51,7 @@ class TestGemResolverIndexSet < Gem::TestCase
fetcher.spec 'b', 1
end
- set = @DR::BestSet.new
set.remote = false
dependency = dep 'a', '~> 1'
@@ -59,5 +61,29 @@ class TestGemResolverIndexSet < Gem::TestCase
assert_empty set.find_all req
end
end
@@ -2,6 +2,101 @@ require 'rubygems/test_case'
class TestGemResolverInstallerSet < Gem::TestCase
def test_consider_local_eh
set = Gem::Resolver::InstallerSet.new :remote
@@ -30,6 +125,54 @@ class TestGemResolverInstallerSet < Gem::TestCase
refute set.consider_remote?
end
def test_load_spec
specs = spec_fetcher do |fetcher|
fetcher.spec 'a', 2
@@ -46,6 +189,18 @@ class TestGemResolverInstallerSet < Gem::TestCase
assert_equal specs["a-2-#{Gem::Platform.local}"].full_name, spec.full_name
end
def test_remote_equals_both
set = Gem::Resolver::InstallerSet.new :both
set.remote = true
@@ -5,14 +5,15 @@ class TestGemResolverLockSet < Gem::TestCase
def setup
super
- @source = Gem::Source.new @gem_repo
- @lock_source = Gem::Source::Lock.new @source
- @set = Gem::Resolver::LockSet.new @source
end
def test_add
- spec = @set.add 'a', '2', Gem::Platform::RUBY
assert_equal %w[a-2], @set.specs.map { |t| t.full_name }
@@ -26,12 +27,17 @@ class TestGemResolverLockSet < Gem::TestCase
end
def test_find_all
- @set.add 'a', '2', Gem::Platform::RUBY
- @set.add 'b', '2', Gem::Platform::RUBY
found = @set.find_all dep 'a'
assert_equal %w[a-2], found.map { |s| s.full_name }
end
def test_load_spec
@@ -9,7 +9,7 @@ class TestGemResolverLockSpecification < Gem::TestCase
@LS = Gem::Resolver::LockSpecification
@source = Gem::Source.new @gem_repo
- @set = Gem::Resolver::LockSet.new @source
end
def test_initialize
@@ -83,5 +83,16 @@ class TestGemResolverLockSpecification < Gem::TestCase
assert_equal [b_dep, c_dep], l_spec.spec.dependencies
end
end
@@ -3,6 +3,7 @@ require 'rubygems/test_case'
class TestGemResolverSpecification < Gem::TestCase
class TestSpec < Gem::Resolver::Specification
attr_reader :spec
def initialize spec
@@ -12,6 +13,26 @@ class TestGemResolverSpecification < Gem::TestCase
end
end
def test_installable_platform_eh
a = util_spec 'a', 1
@@ -28,5 +49,16 @@ class TestGemResolverSpecification < Gem::TestCase
refute b_spec.installable_platform?
end
end
@@ -11,10 +11,12 @@ class TestGemResolverVendorSet < Gem::TestCase
def test_add_vendor_gem
name, version, directory = vendor_gem
- @set.add_vendor_gem name, directory
spec = @set.load_spec name, version, Gem::Platform::RUBY, nil
assert_equal "#{name}-#{version}", spec.full_name
assert_equal File.expand_path(directory), spec.full_gem_path
@@ -55,6 +57,20 @@ class TestGemResolverVendorSet < Gem::TestCase
assert_equal expected, found
end
def test_load_spec
error = Object.const_defined?(:KeyError) ? KeyError : IndexError
@@ -347,7 +347,7 @@ class TestGemSecurityPolicy < Gem::TestCase
assert_match "WARNING: some_gem is not signed\n", @ui.error
assert_raises Gem::Security::Exception do
- @almost_no.verify [PUBLIC_CERT], nil, digests, {}
end
end
@@ -513,7 +513,7 @@ class TestGemSecurityPolicy < Gem::TestCase
digests['SHA1']['data.tar.gz'] = OpenSSL::Digest.new 'SHA1', 'hello'
assert_raises Gem::Security::Exception do
- @almost_no.verify_signatures @spec, digests, {}
end
end
@@ -10,8 +10,9 @@ class TestGemServer < Gem::TestCase
def setup
super
- @a1 = quick_gem 'a', '1'
- @a2 = quick_gem 'a', '2'
@server = Gem::Server.new Gem.dir, process_based_port, false
@req = WEBrick::HTTPRequest.new :Logger => nil
@@ -144,6 +145,36 @@ class TestGemServer < Gem::TestCase
assert_equal 2, @server.server.listeners.length
end
def test_quick_gemdirs
data = StringIO.new "GET /quick/Marshal.4.8/z-9.gemspec.rz HTTP/1.0\r\n\r\n"
dir = "#{@gemhome}2"
@@ -223,6 +254,38 @@ class TestGemServer < Gem::TestCase
assert_equal Gem::Platform.local, spec.platform
end
def test_rdoc
data = StringIO.new "GET /rdoc?q=a HTTP/1.0\r\n\r\n"
@req.parse data
@@ -279,7 +342,8 @@ class TestGemServer < Gem::TestCase
assert_equal 'application/octet-stream', @res['content-type']
assert_equal [['a', Gem::Version.new(1), Gem::Platform::RUBY],
- ['a', Gem::Version.new(2), Gem::Platform::RUBY]],
Marshal.load(@res.body)
end
@@ -318,7 +382,8 @@ class TestGemServer < Gem::TestCase
assert_equal 'application/x-gzip', @res['content-type']
assert_equal [['a', Gem::Version.new(1), Gem::Platform::RUBY],
- ['a', Gem::Version.new(2), Gem::Platform::RUBY]],
Marshal.load(Gem.gunzip(@res.body))
end
@@ -1,5 +1,6 @@
require 'rubygems/test_case'
require 'rubygems/source'
class TestGemSource < Gem::TestCase
@@ -40,13 +41,28 @@ class TestGemSource < Gem::TestCase
end
def test_dependency_resolver_set_bundler_api
- @fetcher.data["#{@gem_repo}api/v1/dependencies"] = 'data'
set = @source.dependency_resolver_set
assert_kind_of Gem::Resolver::APISet, set
end
def test_dependency_resolver_set_marshal_api
set = @source.dependency_resolver_set
@@ -27,6 +27,21 @@ class TestGemSourceGit < Gem::TestCase
assert_path_exists File.join @source.install_dir, 'a.gemspec'
end
def test_checkout_local
@source.remote = false
@@ -179,14 +194,18 @@ class TestGemSourceGit < Gem::TestCase
git = Gem::Source::Git.new 'a', 'git/a', 'master', false
remote = Gem::Source.new @gem_repo
installed = Gem::Source::Installed.new
assert_equal( 0, git. <=>(git), 'git <=> git')
assert_equal( 1, git. <=>(remote), 'git <=> remote')
assert_equal(-1, remote. <=>(git), 'remote <=> git')
- assert_equal( 1, installed.<=>(git), 'installed <=> git')
- assert_equal(-1, git. <=>(installed), 'git <=> installed')
end
def test_specs
@@ -254,6 +273,10 @@ class TestGemSourceGit < Gem::TestCase
end
end
def test_uri_hash
assert_equal @hash, @source.uri_hash
@@ -11,6 +11,8 @@ class TestGemSourceInstalled < Gem::TestCase
specific = Gem::Source::SpecificFile.new a1.cache_file
installed = Gem::Source::Installed.new
local = Gem::Source::Local.new
assert_equal( 0, installed.<=>(installed), 'installed <=> installed')
@@ -22,6 +24,12 @@ class TestGemSourceInstalled < Gem::TestCase
assert_equal(-1, specific. <=>(installed), 'specific <=> installed')
assert_equal( 1, installed.<=>(specific), 'installed <=> specific')
end
end
@@ -43,8 +43,8 @@ class TestGemSourceLock < Gem::TestCase
assert_equal( 0, i_lock.<=>(i_lock), 'i_lock <=> i_lock')
assert_equal( 0, v_lock.<=>(v_lock), 'v_lock <=> v_lock')
- assert_equal(-1, g_lock.<=>(i_lock), 'g_lock <=> i_lock')
- assert_equal( 1, i_lock.<=>(g_lock), 'i_lock <=> g_lock')
assert_equal(-1, g_lock.<=>(v_lock), 'g_lock <=> v_lock')
assert_equal( 1, v_lock.<=>(g_lock), 'v_lock <=> g_lock')
@@ -9,6 +9,10 @@ class TestGemSourceSpecificFile < Gem::TestCase
@sf = Gem::Source::SpecificFile.new(@a_gem)
end
def test_spec
assert_equal @a, @sf.spec
end
@@ -12,6 +12,7 @@ class TestGemSourceVendor < Gem::TestCase
def test_spaceship
vendor = Gem::Source::Vendor.new 'vendor/foo'
remote = Gem::Source.new @gem_repo
installed = Gem::Source::Installed.new
assert_equal( 0, vendor. <=>(vendor), 'vendor <=> vendor')
@@ -19,6 +20,9 @@ class TestGemSourceVendor < Gem::TestCase
assert_equal( 1, vendor. <=>(remote), 'vendor <=> remote')
assert_equal(-1, remote. <=>(vendor), 'remote <=> vendor')
assert_equal( 1, vendor. <=>(installed), 'vendor <=> installed')
assert_equal(-1, installed.<=>(vendor), 'installed <=> vendor')
end
@@ -225,7 +225,7 @@ end
util_spec 'b', '2.0'
c, _ = util_spec 'c', '1.0', 'b' => '= 2.0'
- e = assert_raises Gem::LoadError do
assert_activate nil, a, c, "b"
end
@@ -1135,6 +1135,24 @@ dependencies: []
assert_equal %w[lib/code.rb], @a2.files
end
def test_build_extensions
ext_spec
@@ -1231,11 +1249,10 @@ dependencies: []
FileUtils.chmod 0555, @ext.base_dir
FileUtils.chmod 0555, File.join(@ext.base_dir, 'extensions')
- assert_raises Errno::EACCES do
- @ext.build_extensions
- end
ensure
- unless Gem.win_platform? then
FileUtils.chmod 0755, File.join(@ext.base_dir, 'extensions')
FileUtils.chmod 0755, @ext.base_dir
end
@@ -1331,22 +1348,14 @@ dependencies: []
def test_contains_requirable_file_eh_extension
ext_spec
- extconf_rb = File.join @ext.gem_dir, @ext.extensions.first
- FileUtils.mkdir_p File.dirname extconf_rb
-
- open extconf_rb, 'w' do |f|
- f.write <<-'RUBY'
- open 'Makefile', 'w' do |f|
- f.puts "clean:\n\techo cleaned"
- f.puts "default:\n\techo built"
- f.puts "install:\n\techo installed"
- end
- RUBY
end
- refute @ext.contains_requirable_file? 'nonexistent'
- assert_path_exists @ext.extension_dir
end
def test_date
@@ -1791,13 +1800,33 @@ dependencies: []
enable_shared 'no' do
ext_spec
- @ext.require_path = 'lib'
- ext_install_dir = Pathname(@ext.extension_dir)
- full_gem_path = Pathname(@ext.full_gem_path)
- relative_install_dir = ext_install_dir.relative_path_from full_gem_path
- assert_equal [relative_install_dir.to_s, 'lib'], @ext.require_paths
end
end
@@ -1824,7 +1853,7 @@ dependencies: []
def test_full_require_paths
ext_spec
- @ext.require_path = 'lib'
expected = [
@ext.extension_dir,
@@ -2268,6 +2297,7 @@ end
@a1.add_runtime_dependency 'k', '> 1.2'
@a1.add_runtime_dependency 'l', '> 1.2.3'
@a1.add_runtime_dependency 'm', '~> 2.1.0'
use_ui @ui do
@a1.validate
@@ -2874,14 +2904,76 @@ end
assert_equal @m1.to_ruby, valid_ruby_spec
end
def test_find_by_name
- util_make_gems
- assert(Gem::Specification.find_by_name("a"))
- assert(Gem::Specification.find_by_name("a", "1"))
- assert(Gem::Specification.find_by_name("a", ">1"))
- assert_raises(Gem::LoadError) do
- Gem::Specification.find_by_name("monkeys")
end
end
def test_find_by_path
@@ -23,16 +23,11 @@ class TestStubSpecification < Gem::TestCase
def test_initialize_extension
stub = stub_with_extension
- ext_install_dir = Pathname(stub.extension_dir)
- full_gem_path = Pathname(stub.full_gem_path)
- relative_install_dir = ext_install_dir.relative_path_from full_gem_path
- relative_install_dir = relative_install_dir.to_s
-
- assert_equal 'stub_e', stub.name
- assert_equal v(2), stub.version
- assert_equal Gem::Platform::RUBY, stub.platform
- assert_equal [relative_install_dir, 'lib'], stub.require_paths
- assert_equal %w[ext/stub_e/extconf.rb], stub.extensions
end
def test_initialize_missing_stubline
@@ -55,22 +50,14 @@ class TestStubSpecification < Gem::TestCase
def test_contains_requirable_file_eh_extension
stub_with_extension do |stub|
- extconf_rb = File.join stub.gem_dir, stub.extensions.first
- FileUtils.mkdir_p File.dirname extconf_rb
-
- open extconf_rb, 'w' do |f|
- f.write <<-'RUBY'
- open 'Makefile', 'w' do |f|
- f.puts "clean:\n\techo cleaned"
- f.puts "default:\n\techo built"
- f.puts "install:\n\techo installed"
- end
- RUBY
end
- refute stub.contains_requirable_file? 'nonexistent'
- assert_path_exists stub.extension_dir
end
end
@@ -85,9 +72,70 @@ class TestStubSpecification < Gem::TestCase
assert_equal expected, stub.full_require_paths
end
def test_to_spec
assert @foo.to_spec.is_a?(Gem::Specification)
assert_equal "foo", @foo.to_spec.name
end
def stub_with_extension
@@ -325,6 +325,29 @@ create_makefile '#{@spec.name}'
assert_equal expected, e.message
end
def test_uninstall_selection_greater_than_one
util_make_gems
@@ -0,0 +1,32 @@
@@ -33,6 +33,12 @@ class TestKernel < Gem::TestCase
assert_equal 1, $:.select { |p| %r{a-1/lib} =~ p }.size
end
def test_gem_conflicting
assert gem('a', '= 1'), "Should load"
@@ -2,6 +2,26 @@ require 'rubygems/test_case'
require 'rubygems'
class TestGemRequire < Gem::TestCase
def setup
super
@@ -17,6 +37,46 @@ class TestGemRequire < Gem::TestCase
assert require(path), "'#{path}' was already required"
end
def test_require_is_not_lazy_with_exact_req
a1 = new_spec "a", "1", {"b" => "= 1"}, "lib/test_gem_require_a.rb"
b1 = new_spec "b", "1", nil, "lib/b/c.rb"