File: 01_tar.t

package info (click to toggle)
libarchive-any-create-perl 0.3-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 124 kB
  • sloc: perl: 126; makefile: 2
file content (27 lines) | stat: -rw-r--r-- 617 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use strict;
use Archive::Any::Create;
use Archive::Tar;

use Test::More 'no_plan';

my $archive = Archive::Any::Create->new;

$archive->container('foo');
$archive->add_file('t/01_tar.t', "foobar\n");
$archive->add_file('t/02_xxx.t', "bazbaz\n");
$archive->write_file('foo.tar.gz');

open OUT, "> foo2.tar.gz";
$archive->write_filehandle(\*OUT, "tar.gz");
close OUT;

for my $file (qw( foo.tar.gz foo2.tar.gz )) {
    my $tar = Archive::Tar->new;
    $tar->read($file, 1);
    ok $tar->contains_file('foo/t/01_tar.t');
    is_deeply [ $tar->list_files ], [ 'foo/t/01_tar.t', 'foo/t/02_xxx.t' ];
    unlink $file;
}