#!/usr/bin/perl -w
BEGIN {
if
(-d
't'
) {
push
@INC
,
't'
;
}
}
my
$test_data_dir
= get_test_data_dir();
my
$test_data_no
=
'tc5'
;
my
$map
= {};
my
$tmpdir
= tempdir(
'_arXXXXXXXX'
,
DIR
=> File::Spec->tmpdir());
my
$probe
= Archive::Probe->new();
SKIP: {
skip
"tar is not installed"
, 3
unless
$probe
->_is_cmd_avail(
'tar'
);
$probe
->working_dir(
$tmpdir
);
$probe
->add_pattern(
'\w+\.abc'
,
sub
{
my
(
$pattern
,
$file_ref
) =
@_
;
if
(
@$file_ref
) {
$map
->{abc} =
$probe
->strip_dir(
$tmpdir
,
$file_ref
->[0]);
}
else
{
$map
->{abc} =
''
;
}
});
my
$base_dir
= catdir(
$test_data_dir
,
$test_data_no
);
$probe
->reset_matches();
$probe
->search(
$base_dir
, 1);
my
$exp
= catdir(
'a.tar__'
,
'b.tgz__'
,
'c.bz2__'
,
'version.abc'
);
is(
$map
->{abc},
$exp
,
'file search in deep nested tar archive'
);
my
$b
= catfile(
$tmpdir
,
'a.tar__'
,
'b.tgz'
);
ok(-f
$b
,
'existence of b.tgz'
);
my
$c
= catfile(
$tmpdir
,
'a.tar__'
,
'b.tgz__'
,
'c.bz2'
);
ok(-f
$c
,
'existence of c.bz2'
);
}
rmtree(
$tmpdir
);