3
3
# Before `make install' is performed this script should be runnable with
4
4
# `make test'. After `make install' it should work as `perl t/testex.t'
5
5
# vim: ts=4 sw=4 ft=perl
11
11
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
14
BEGIN { plan tests => 6, todo => [] }
15
BEGIN { plan tests => 15, todo => [] }
16
17
BEGIN { require 't/common.pl' }
20
my $libs = join(' -I', @INC);
21
my $cmd = "$^X -I$libs -w @_";
22
my $output = qx($cmd);
23
return wantarray ? ($?, $output) : $?;
21
my $libs = join ( ' -I', @INC );
22
my $cmd = "\"$^X\" \"-I$libs\" -w \"". join('" "', @_). '"';
24
return wantarray ? ( $?, $output ) : $?;
26
use constant FILENAME => TESTDIR . 'testing.txt';
27
use constant FILENAME => File::Spec->catpath( '', TESTDIR, 'testing.txt' );
28
use constant ZFILENAME => TESTDIR . "/testing.txt"; # name in zip
27
30
my $zip = Archive::Zip->new();
28
$zip->addString(TESTSTRING, FILENAME);
31
$zip->addString( TESTSTRING, FILENAME );
29
32
$zip->writeToFileNamed(INPUTZIP);
31
my ($status, $output);
32
my $fh = FileHandle->new("test.log", "w");
34
ok(runPerlCommand( 'examples/copy.pl', INPUTZIP, OUTPUTZIP ), 0);
35
ok(runPerlCommand( 'examples/extract.pl', OUTPUTZIP, FILENAME), 0);
36
ok(runPerlCommand( 'examples/mfh.pl', INPUTZIP ), 0);
37
ok(runPerlCommand( 'examples/zip.pl', OUTPUTZIP, INPUTZIP, FILENAME ), 0);
38
($status, $output) = runPerlCommand( 'examples/zipinfo.pl', INPUTZIP );
34
my ( $status, $output );
35
my $fh = IO::File->new( "test.log", "w" );
37
ok( runPerlCommand( 'examples/copy.pl', INPUTZIP, OUTPUTZIP ), 0 );
39
ok( runPerlCommand( 'examples/extract.pl', OUTPUTZIP, ZFILENAME ), 0 );
41
ok( runPerlCommand( 'examples/mfh.pl', INPUTZIP ), 0 );
43
ok( runPerlCommand( 'examples/zip.pl', OUTPUTZIP, INPUTZIP, FILENAME ), 0 );
45
( $status, $output ) = runPerlCommand( 'examples/zipinfo.pl', INPUTZIP );
40
47
$fh->print("zipinfo output:\n");
41
48
$fh->print($output);
42
($status, $output) = runPerlCommand( 'examples/ziptest.pl', INPUTZIP );
50
( $status, $output ) = runPerlCommand( 'examples/ziptest.pl', INPUTZIP );
44
52
$fh->print("ziptest output:\n");
45
53
$fh->print($output);
55
( $status, $output ) = runPerlCommand( 'examples/zipGrep.pl', '100', INPUTZIP );
57
ok( $output, ZFILENAME . ":100\n" );
60
# creates test.zip, may be sensitive to /dev/null
62
# removed because requires IO::Scalar
63
# ok( runPerlCommand('examples/readScalar.pl'), 0 );
66
ok( runPerlCommand( 'examples/selfex.pl', OUTPUTZIP, FILENAME ), 0 );
68
ok( runPerlCommand(OUTPUTZIP), 0 );
70
File::Spec->catpath( '', File::Spec->catdir( 'extracted', TESTDIR ),
72
ok( -f $fn, 1, "$fn exists" );
81
ok( runPerlCommand( 'examples/updateTree.pl', OUTPUTZIP, TESTDIR ), 0, "updateTree.pl create" );
82
ok( -f OUTPUTZIP, 1, "zip created" );
83
ok( runPerlCommand( 'examples/updateTree.pl', OUTPUTZIP, TESTDIR ), 0, "updateTree.pl update" );
84
ok( -f OUTPUTZIP, 1, "zip updated" );