diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-28 02:26:39 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-28 02:26:39 +0000 |
commit | b177a87a1c48e3d763f94ab327a6532d51eb9a51 (patch) | |
tree | bd57731d31e70e0b5837bcff618f0b56b2be3b5e /test | |
parent | 276e899fd5993c0723b85cee2b9452b3b22ac096 (diff) | |
download | ruby-b177a87a1c48e3d763f94ab327a6532d51eb9a51.tar.gz |
* lib/rubygems.rb, lib/rubygems/*, test/rubygems/*: Update rubygems-2.6.2.
Please see entries of 2.6.2 on
https://github.com/rubygems/rubygems/blob/master/History.txt
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/rubygems/test_gem.rb | 11 | ||||
-rw-r--r-- | test/rubygems/test_gem_installer.rb | 51 | ||||
-rw-r--r-- | test/rubygems/test_gem_resolver.rb | 12 | ||||
-rw-r--r-- | test/rubygems/test_kernel.rb | 7 | ||||
-rw-r--r-- | test/rubygems/test_require.rb | 28 |
5 files changed, 108 insertions, 1 deletions
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index aa57261d5e..e78f874b4e 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -816,6 +816,17 @@ class TestGem < Gem::TestCase RbConfig::CONFIG['ruby_version'] = orig_ruby_version end + def test_self_env_requirement + ENV["GEM_REQUIREMENT_FOO"] = '>= 1.2.3' + ENV["GEM_REQUIREMENT_BAR"] = '1.2.3' + ENV["GEM_REQUIREMENT_BAZ"] = 'abcd' + + assert_equal Gem::Requirement.create('>= 1.2.3'), Gem.env_requirement('foo') + assert_equal Gem::Requirement.create('1.2.3'), Gem.env_requirement('bAr') + assert_raises(Gem::Requirement::BadRequirementError) { Gem.env_requirement('baz') } + assert_equal Gem::Requirement.default, Gem.env_requirement('qux') + end + def test_self_ruby_version_1_8_5 util_set_RUBY_VERSION '1.8.5' diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index 5ec71d0a01..f9149650f0 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -48,7 +48,7 @@ if ARGV.first end end -load Gem.bin_path('a', 'executable', version) +load Gem.activate_bin_path('a', 'executable', version) EOF wrapper = @installer.app_script_text 'executable' @@ -781,6 +781,55 @@ gem 'other', version assert_match(/ran executable/, e.message) end + def test_conflicting_binstubs + Dir.mkdir util_inst_bindir + util_clear_gems + + # build old version that has a bin file + util_setup_gem do |spec| + File.open File.join('bin', 'executable'), 'w' do |f| + f.puts "require 'code'" + end + File.open File.join('lib', 'code.rb'), 'w' do |f| + f.puts 'raise "I have an executable"' + end + end + + @installer.wrappers = true + build_rake_in do + use_ui @ui do + @newspec = @installer.install + end + end + + old_bin_file = File.join @installer.bin_dir, 'executable' + + # build new version that doesn't have a bin file + util_setup_gem do |spec| + FileUtils.rm File.join('bin', 'executable') + spec.files.delete File.join('bin', 'executable') + spec.executables.delete 'executable' + spec.version = @spec.version.bump + File.open File.join('lib', 'code.rb'), 'w' do |f| + f.puts 'raise "I do not have an executable"' + end + end + + build_rake_in do + use_ui @ui do + @newspec = @installer.install + end + end + + e = assert_raises RuntimeError do + instance_eval File.read(old_bin_file) + end + + # We expect the bin stub to activate the version that actually contains + # the binstub. + assert_match('I have an executable', e.message) + end + def test_install_creates_binstub_that_understand_version Dir.mkdir util_inst_bindir util_setup_gem diff --git a/test/rubygems/test_gem_resolver.rb b/test/rubygems/test_gem_resolver.rb index dd480b023a..cf457db198 100644 --- a/test/rubygems/test_gem_resolver.rb +++ b/test/rubygems/test_gem_resolver.rb @@ -695,6 +695,18 @@ class TestGemResolver < Gem::TestCase assert_equal [a1, a1_p1], selected end + def test_search_for_local_platform_partial_string_match + a1 = util_spec 'a', 1 + a1_p1 = util_spec 'a', 1 do |s| s.platform = Gem::Platform.local.os end + a1_p2 = util_spec 'a', 1 do |s| s.platform = 'unknown' end + + s = set(a1_p1, a1_p2, a1) + d = [make_dep('a')] + r = Gem::Resolver.new(d, s) + + assert_resolves_to [a1_p1], r + end + def test_raises_and_explains_when_platform_prevents_install a1 = util_spec "a", "1" do |s| s.platform = Gem::Platform.new %w[c p 1] diff --git a/test/rubygems/test_kernel.rb b/test/rubygems/test_kernel.rb index d79b21c639..e6e11b8efb 100644 --- a/test/rubygems/test_kernel.rb +++ b/test/rubygems/test_kernel.rb @@ -64,6 +64,13 @@ class TestKernel < Gem::TestCase assert gem('d', '>= 1.a'), 'prerelease requirement may load prerelease' end + def test_gem_env_req + ENV["GEM_REQUIREMENT_A"] = '~> 2.0' + assert_raises(Gem::LoadError) { gem('a', '= 1') } + assert gem('a', '> 1') + assert_equal @a2, Gem.loaded_specs['a'] + end + def test_gem_conflicting assert gem('a', '= 1'), "Should load" diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb index ec0c48ac68..04cbc094d8 100644 --- a/test/rubygems/test_require.rb +++ b/test/rubygems/test_require.rb @@ -319,4 +319,32 @@ class TestGemRequire < Gem::TestCase def unresolved_names Gem::Specification.unresolved_deps.values.map(&:to_s).sort end + + def test_try_activate_error_unlocks_require_monitor + silence_warnings do + class << ::Gem + alias old_try_activate try_activate + def try_activate(*); raise 'raised from try_activate'; end + end + end + + require 'does_not_exist_for_try_activate_test' + rescue RuntimeError => e + assert_match(/raised from try_activate/, e.message) + assert Kernel::RUBYGEMS_ACTIVATION_MONITOR.try_enter, "require monitor was not unlocked when try_activate raised" + ensure + silence_warnings do + class << ::Gem + alias try_activate old_try_activate + end + end + Kernel::RUBYGEMS_ACTIVATION_MONITOR.exit + end + + def silence_warnings + old_verbose, $VERBOSE = $VERBOSE, false + yield + ensure + $VERBOSE = old_verbose + end end |