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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
use strict;
use warnings;
use Test::More tests => 2;
use File::Temp qw( tempdir );
use File::Spec;
use Archive::Ar;
my $dir = tempdir( CLEANUP => 1 );
my $fn = File::Spec->catfile($dir, 'foo.ar');
note "fn = $fn";
my $content = do {local $/ = undef; <DATA>};
open my $fh, '>', $fn or die "$fn: $!\n";
binmode $fh;
print $fh $content;
close $fh;
subtest 'remove list' => sub {
plan tests => 3;
my $ar = Archive::Ar->new($fn);
isa_ok $ar, 'Archive::Ar';
my $count = eval { $ar->remove('foo.txt', 'baz.txt') };
is $count, 2, 'count = 2';
diag $@ if $@;
is_deeply scalar $ar->list_files, ['bar.txt'], "just bar";
};
subtest 'remove ref' => sub {
plan tests => 3;
my $ar = Archive::Ar->new($fn);
isa_ok $ar, 'Archive::Ar';
my $count = eval { $ar->remove(['foo.txt', 'baz.txt']) };
is $count, 2, 'count = 2';
diag $@ if $@;
is_deeply scalar $ar->list_files, ['bar.txt'], "just bar";
};
__DATA__
!<arch>
foo.txt 1384344423 1000 1000 100644 9 `
hi there
bar.txt 1384344423 1000 1000 100644 31 `
this is the content of bar.txt
baz.txt 1384344423 1000 1000 100644 11 `
and again.
|