4 use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
8 use Test::More tests => 17;
11 require( File::Spec->catfile('t', 'common.pl') )
12 or die "Can't load t/common.pl";
17 my $libs = join ( ' -I', @INC );
18 my $cmd = "\"$^X\" \"-I$libs\" -w \"". join('" "', @_). '"';
20 return wantarray ? ( $?, $output ) : $?;
23 use constant FILENAME => File::Spec->catpath( '', TESTDIR, 'testing.txt' );
24 use constant ZFILENAME => TESTDIR . "/testing.txt"; # name in zip
26 my $zip = Archive::Zip->new();
27 isa_ok( $zip, 'Archive::Zip' );
28 $zip->addString( TESTSTRING, FILENAME );
29 $zip->writeToFileNamed(INPUTZIP);
31 my ( $status, $output );
32 my $fh = IO::File->new( "test.log", "w" );
33 isa_ok( $fh, 'IO::File' );
35 is( runPerlCommand( 'examples/copy.pl', INPUTZIP, OUTPUTZIP ), 0 );
37 is( runPerlCommand( 'examples/extract.pl', OUTPUTZIP, ZFILENAME ), 0 );
39 is( runPerlCommand( 'examples/mfh.pl', INPUTZIP ), 0 );
41 is( runPerlCommand( 'examples/zip.pl', OUTPUTZIP, INPUTZIP, FILENAME ), 0 );
43 ( $status, $output ) = runPerlCommand( 'examples/zipinfo.pl', INPUTZIP );
45 $fh->print("zipinfo output:\n");
48 ( $status, $output ) = runPerlCommand( 'examples/ziptest.pl', INPUTZIP );
50 $fh->print("ziptest output:\n");
53 ( $status, $output ) = runPerlCommand( 'examples/zipGrep.pl', '100', INPUTZIP );
55 is( $output, ZFILENAME . ":100\n" );
58 # creates test.zip, may be sensitive to /dev/null
60 # removed because requires IO::Scalar
61 # ok( runPerlCommand('examples/readScalar.pl'), 0 );
64 is( runPerlCommand( 'examples/selfex.pl', OUTPUTZIP, FILENAME ), 0 );
66 is( runPerlCommand(OUTPUTZIP), 0 );
68 File::Spec->catpath( '', File::Spec->catdir( 'extracted', TESTDIR ),
70 is( -f $fn, 1, "$fn exists" );
79 is( runPerlCommand( 'examples/updateTree.pl', OUTPUTZIP, TESTDIR ), 0, "updateTree.pl create" );
80 is( -f OUTPUTZIP, 1, "zip created" );
81 is( runPerlCommand( 'examples/updateTree.pl', OUTPUTZIP, TESTDIR ), 0, "updateTree.pl update" );
82 is( -f OUTPUTZIP, 1, "zip updated" );