Archive-Probe
view release on metacpan or search on metacpan
t/directory_test.t view on Meta::CPAN
$map->{xml} = $probe->_strip_dir($tmpdir, $file_ref->[0]);
}
else {
$map->{xml} = '';
}
});
$probe->add_pattern(
'index\.jsp',
sub {
my ($pattern, $file_ref) = @_;
if (@$file_ref) {
$map->{jsp} = $probe->_strip_dir($tmpdir, $file_ref->[0]);
}
else {
$map->{jsp} = '';
}
});
my $base_dir = catdir($test_data_dir, $test_data_no);
$probe->reset_matches();
$probe->search($base_dir, 1);
# verify that the target.abc file is found
my $exp = catfile('webapp.zip__', 'WEB-INF', 'config.xml');
is(
$map->{xml},
$exp,
'file search in zip'
);
my $a = catfile($tmpdir, 'webapp.zip__', 'WEB-INF', 'config.xml');
ok(-f $a, 'existence of config.xml');
# verify that the index.jsp file is found
$exp = catdir('webapp.zip__', 'index.jsp');
is(
$map->{jsp},
$exp,
'toplevel file search in zip'
);
my $b = catfile($tmpdir, 'webapp.zip__', 'index.jsp');
ok(-f $b, 'existence of index.jsp');
}
SKIP: {
skip "tar is not installed", 4 unless $probe->_is_cmd_avail('tar');
$probe->working_dir($tmpdir);
$probe->add_pattern(
'manifest\.mf',
sub {
my ($pattern, $file_ref) = @_;
if (@$file_ref) {
$map->{mf} = $probe->_strip_dir($tmpdir, $file_ref->[0]);
}
else {
$map->{mf} = '';
}
});
$probe->add_pattern(
'404\.jsp',
sub {
my ($pattern, $file_ref) = @_;
if (@$file_ref) {
$map->{404} = $probe->_strip_dir($tmpdir, $file_ref->[0]);
}
else {
$map->{404} = '';
}
});
$probe->add_pattern(
'readme\.txt',
sub {
my ($pattern, $file_ref) = @_;
if (@$file_ref) {
$map->{txt} = $probe->_strip_dir($tmpdir, $file_ref->[0]);
}
else {
$map->{txt} = '';
}
});
my $base_dir = catdir($test_data_dir, $test_data_no);
$probe->reset_matches();
$probe->search($base_dir, 1);
# verify that the manifest.mf file is found
my $exp = catfile('dir1', 'a.tgz__', 'META-INF', 'manifest.mf');
is(
$map->{mf},
$exp,
'file search in tgz under sub-directory'
);
my $a = catfile($tmpdir, 'dir1', 'a.tgz__', 'META-INF', 'manifest.mf');
ok(-f $a, 'existence of manifest.mf');
# verify that the 404.jsp file is found
$exp = catdir('dir1', 'a.tgz__', '404.jsp');
is(
$map->{404},
$exp,
'toplevel file search in tgz under sub-directory'
);
my $b = catfile($tmpdir, 'dir1', 'a.tgz__', '404.jsp');
ok(-f $b, 'existence of 404.jsp');
# verify that the readme.txt file is found
$exp = catfile('dir2', 'readme.txt');
is(
$map->{txt},
$exp,
'unarchived file search in sub-directory'
);
my $c = catfile($tmpdir, 'dir2', 'readme.txt');
ok(-f $c, 'existence of readme.txt');
}
# cleanup the temp directory to free disk space
rmtree($tmpdir);
# vim: set ai nu nobk expandtab sw=4 ts=4:
( run in 0.947 second using v1.01-cache-2.11-cpan-39bf76dae61 )