File: testTree.t

package info (click to toggle)
libarchive-zip-perl 1.14-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 548 kB
  • ctags: 317
  • sloc: perl: 3,369; makefile: 45
file content (45 lines) | stat: -rw-r--r-- 1,211 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Test Archive::Zip::Tree module
# $Revision: 1.6 $
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl t/testTree.t'
# vim: ts=4 sw=4 ft=perl

$^W = 1;
$| = 1;
use strict;
use Test;
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
use FileHandle;
use File::Spec 0.8;

my $zip;
my @memberNames;

sub makeZip
{
	my ($src, $dest, $pred) = @_;
	$zip = Archive::Zip->new();
	$zip->addTree($src, $dest, $pred);
	@memberNames = $zip->memberNames();
}

sub makeZipAndLookFor
{
	my ($src, $dest, $pred, $lookFor) = @_;
	makeZip($src, $dest, $pred);
	ok( @memberNames );
	ok( (grep { $_ eq $lookFor } @memberNames) == 1 )
		or print STDERR "Can't find $lookFor in (" . join(",", @memberNames) . ")\n";
}

BEGIN { plan tests => 6, todo => [] }

BEGIN { require 't/common.pl' }

use constant FILENAME => File::Spec->catfile(TESTDIR, 'testing.txt');

my ($testFileVolume, $testFileDirs, $testFileName) = File::Spec->splitpath($0);

makeZipAndLookFor('.', '', sub { print "file $_\n"; -f && /\.t$/ }, 't/test.t' );
makeZipAndLookFor('.', 'e/', sub { -f && /\.t$/ }, 'e/t/test.t');
makeZipAndLookFor('./t', '', sub { -f && /\.t$/ }, 'test.t' );