diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-08-27 10:05:04 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-08-27 10:05:04 +0000 |
commit | 85d461456c154d7b4a72b20369e0d65d7880ce02 (patch) | |
tree | 21e1be2c786c8040a426841768e046fb4dc365b1 /test/rubygems/test_gem_package.rb | |
parent | 3a83ba90c35833bab757998def36cfe872dec461 (diff) | |
download | ruby-85d461456c154d7b4a72b20369e0d65d7880ce02.tar.gz |
Merge master branch from rubygems upstream.
* It's preparation to release RubyGems 3.0.0.beta2 and Ruby 2.6.0
preview 3.
* https://github.com/rubygems/rubygems/compare/v3.0.0.beta1...fad2eb15a282b19dfcb4b48bc95b8b39ebb4511f
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_package.rb')
-rw-r--r-- | test/rubygems/test_gem_package.rb | 77 |
1 files changed, 56 insertions, 21 deletions
diff --git a/test/rubygems/test_gem_package.rb b/test/rubygems/test_gem_package.rb index 09ef27ee22..a53cda1274 100644 --- a/test/rubygems/test_gem_package.rb +++ b/test/rubygems/test_gem_package.rb @@ -150,7 +150,7 @@ class TestGemPackage < Gem::Package::TarTestCase end def test_add_files_symlink - skip 'symlink not supported' if Gem.win_platform? + skip 'symlink not supported' if Gem.win_platform? && RUBY_VERSION < '2.3' spec = Gem::Specification.new spec.files = %w[lib/code.rb lib/code_sym.rb] @@ -159,7 +159,15 @@ class TestGemPackage < Gem::Package::TarTestCase File.open 'lib/code.rb', 'w' do |io| io.write '# lib/code.rb' end # NOTE: 'code.rb' is correct, because it's relative to lib/code_sym.rb - File.symlink('code.rb', 'lib/code_sym.rb') + begin + File.symlink('code.rb', 'lib/code_sym.rb') + rescue Errno::EACCES => e + if win_platform? + skip "symlink - must be admin with no UAC on Windows" + else + raise e + end + end package = Gem::Package.new 'bogus.gem' package.spec = spec @@ -315,6 +323,19 @@ class TestGemPackage < Gem::Package::TarTestCase assert_equal 'missing value for attribute summary', e.message end + def test_build_invalid_arguments + spec = Gem::Specification.new 'build', '1' + + package = Gem::Package.new spec.file_name + package.spec = spec + + e = assert_raises ArgumentError do + package.build true, true + end + + assert_equal "skip_validation = true and strict_validation = true are incompatible", e.message + end + def test_build_signed skip 'openssl is missing' unless defined?(OpenSSL::SSL) @@ -451,7 +472,7 @@ class TestGemPackage < Gem::Package::TarTestCase end def test_extract_tar_gz_symlink_relative_path - skip 'symlink not supported' if Gem.win_platform? + skip 'symlink not supported' if Gem.win_platform? && RUBY_VERSION < '2.3' package = Gem::Package.new @gem @@ -461,7 +482,15 @@ class TestGemPackage < Gem::Package::TarTestCase tar.add_symlink 'lib/foo.rb', '../relative.rb', 0644 end - package.extract_tar_gz tgz_io, @destination + begin + package.extract_tar_gz tgz_io, @destination + rescue Errno::EACCES => e + if win_platform? + skip "symlink - must be admin with no UAC on Windows" + else + raise e + end + end extracted = File.join @destination, 'lib/foo.rb' assert_path_exists extracted @@ -472,28 +501,34 @@ class TestGemPackage < Gem::Package::TarTestCase end def test_extract_symlink_parent - skip 'symlink not supported' if Gem.win_platform? + skip 'symlink not supported' if Gem.win_platform? && RUBY_VERSION < '2.3' - package = Gem::Package.new @gem + package = Gem::Package.new @gem - tgz_io = util_tar_gz do |tar| - tar.mkdir 'lib', 0755 - tar.add_symlink 'lib/link', '../..', 0644 - tar.add_file 'lib/link/outside.txt', 0644 do |io| io.write 'hi' end - end + tgz_io = util_tar_gz do |tar| + tar.mkdir 'lib', 0755 + tar.add_symlink 'lib/link', '../..', 0644 + tar.add_file 'lib/link/outside.txt', 0644 do |io| io.write 'hi' end + end - # Extract into a subdirectory of @destination; if this test fails it writes - # a file outside destination_subdir, but we want the file to remain inside - # @destination so it will be cleaned up. - destination_subdir = File.join @destination, 'subdir' - FileUtils.mkdir_p destination_subdir + # Extract into a subdirectory of @destination; if this test fails it writes + # a file outside destination_subdir, but we want the file to remain inside + # @destination so it will be cleaned up. + destination_subdir = File.join @destination, 'subdir' + FileUtils.mkdir_p destination_subdir - e = assert_raises Gem::Package::PathError do - package.extract_tar_gz tgz_io, destination_subdir - end + e = assert_raises(Gem::Package::PathError, Errno::EACCES) do + package.extract_tar_gz tgz_io, destination_subdir + end - assert_equal("installing into parent path lib/link/outside.txt of " + - "#{destination_subdir} is not allowed", e.message) + if Gem::Package::PathError === e + assert_equal("installing into parent path lib/link/outside.txt of " + + "#{destination_subdir} is not allowed", e.message) + elsif win_platform? + skip "symlink - must be admin with no UAC on Windows" + else + raise e + end end def test_extract_tar_gz_directory |