class CPIOArchiveWriterTest

Public Instance Methods

test_adding_a_file_with_an_excessively_long_name_should_raise() click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 398
def test_adding_a_file_with_an_excessively_long_name_should_raise
  archiver = CPIO::ArchiveWriter.new(StringIO.new)
  assert_raise(CPIO::ArchiveFormatError) do
    archiver.open do |arch|
      name = "fffff" * (CPIO::ArchiveHeader::FieldMaxValues[:namesize])
      arch.add_file(name) { |sio| }
    end
  end
end
test_adding_a_non_executable_file_should_preserve_said_mode() click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 408
def test_adding_a_non_executable_file_should_preserve_said_mode
  io = StringIO.new
  archiver = CPIO::ArchiveWriter.new(io)
  archiver.open do |arch|
    arch.add_file("barfoo", 0444) { |sio| }
  end
  CPIO::ArchiveReader.new(io).each_entry do |ent|
    assert !ent.executable? && ent.file?
  end
end
test_adding_an_executable_file_should_preserve_said_mode() click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 419
def test_adding_an_executable_file_should_preserve_said_mode
  io = StringIO.new
  archiver = CPIO::ArchiveWriter.new(io)
  archiver.open do |arch|
    arch.add_file("barfoo", 0500) { |sio| }
  end
  CPIO::ArchiveReader.new(io).each_entry do |ent|
    assert ent.executable? && ent.file?
  end
end
test_adding_empty_files_should_work() click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 387
def test_adding_empty_files_should_work
  expected = 1
  io = StringIO.new
  archiver = CPIO::ArchiveWriter.new(io)
  archiver.open do |arch|
    arch.add_file("barfoo", 0111) { |sio| }
  end
  CPIO::ArchiveReader.new(io).each_entry { |ent| expected -= 1 if ent.file? }
  assert_equal 0, expected
end
test_making_directories_should_work() click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 349
def test_making_directories_should_work
  expected = 2
  io = StringIO.new
  archiver = CPIO::ArchiveWriter.new(io)
  archiver.open do |arch|
    arch.mkdir "foo"
    arch.mkdir "bar"
  end
  CPIO::ArchiveReader.new(io).each_entry { |ent| expected -= 1 if ent.directory? }
  assert_equal 0, expected
end
test_making_files_and_directories_should_work() click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 373
def test_making_files_and_directories_should_work
  expected = 4
  io = StringIO.new
  archiver = CPIO::ArchiveWriter.new(io)
  archiver.open do |arch|
    arch.mkdir "blah"
    arch.add_file("foo") { |sio| sio.write("foobar") }
    arch.add_file("barfoo") { |sio| sio.write("barfoo") }
    arch.add_file("barfoobaz", 0111) { |sio| sio.write("wee") }
  end
  CPIO::ArchiveReader.new(io).each_entry { |ent| expected -= 1 }
  assert_equal 0, expected
end
test_making_files_should_work() click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 361
def test_making_files_should_work
  expected = 2
  io = StringIO.new
  archiver = CPIO::ArchiveWriter.new(io)
  archiver.open do |arch|
    arch.add_file("foo") { |sio| sio.write("foobar") }
    arch.add_file("barfoo") { |sio| sio.write("barfoo") }
  end
  CPIO::ArchiveReader.new(io).each_entry { |ent| expected -= 1 if ent.file? }
  assert_equal 0, expected
end