summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_package.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/rubygems/test_gem_package.rb')
-rw-r--r--test/rubygems/test_gem_package.rb47
1 files changed, 46 insertions, 1 deletions
diff --git a/test/rubygems/test_gem_package.rb b/test/rubygems/test_gem_package.rb
index 9d9c224..bbb036d 100644
--- a/test/rubygems/test_gem_package.rb
+++ b/test/rubygems/test_gem_package.rb
@@ -132,6 +132,37 @@ class TestGemPackage < Gem::Package::TarTestCase
assert_equal %w[lib/code.rb], files
end
+ def test_add_files_symlink
+ skip 'symlink not supported' if Gem.win_platform?
+
+ spec = Gem::Specification.new
+ spec.files = %w[lib/code.rb lib/code_sym.rb]
+
+ FileUtils.mkdir_p 'lib'
+ open 'lib/code.rb', 'w' do |io| io.write '# lib/code.rb' end
+ File.symlink('lib/code.rb', 'lib/code_sym.rb')
+
+ package = Gem::Package.new 'bogus.gem'
+ package.spec = spec
+
+ tar = util_tar do |tar_io|
+ package.add_files tar_io
+ end
+
+ tar.rewind
+
+ files, symlinks = [], []
+
+ Gem::Package::TarReader.new tar do |tar_io|
+ tar_io.each_entry do |entry|
+ (entry.symlink? ? symlinks : files) << entry.full_name
+ end
+ end
+
+ assert_equal %w[lib/code.rb], files
+ assert_equal %w[lib/code_sym.rb], symlinks
+ end
+
def test_build
spec = Gem::Specification.new 'build', '1'
spec.summary = 'build'
@@ -396,6 +427,21 @@ class TestGemPackage < Gem::Package::TarTestCase
"#{@destination} is not allowed", e.message)
end
+ def test_extract_tar_gz_symlink_absolute
+ package = Gem::Package.new @gem
+
+ tgz_io = util_tar_gz do |tar|
+ tar.add_symlink 'code.rb', '/absolute.rb', 0644
+ end
+
+ e = assert_raises Gem::Package::PathError do
+ package.extract_tar_gz tgz_io, @destination
+ end
+
+ assert_equal("installing into parent path /absolute.rb of " +
+ "#{@destination} is not allowed", e.message)
+ end
+
def test_extract_tar_gz_directory
package = Gem::Package.new @gem
@@ -821,4 +867,3 @@ class TestGemPackage < Gem::Package::TarTestCase
end
end
-