Skip to content

Commit

Permalink
Update Archive::Extract to 0.28
Browse files Browse the repository at this point in the history
From: "Jos I. Boumans" <jos@dwim.org>
Message-Id: <A6FBAEE4-A1F3-41BE-A051-ABF03540E9F1@dwim.org>

p4raw-id: //depot/perl@35105
  • Loading branch information
Jos I. Boumans authored and Steve Hay committed Dec 15, 2008
1 parent a23fa24 commit 8328529
Show file tree
Hide file tree
Showing 21 changed files with 278 additions and 211 deletions.
367 changes: 188 additions & 179 deletions lib/Archive/Extract.pm

Large diffs are not rendered by default.

84 changes: 71 additions & 13 deletions lib/Archive/Extract/t/01_Archive-Extract.t
Expand Up @@ -207,8 +207,53 @@ if( $Debug ) {
ok( $obj, " Object created based on '$type'" );
ok( !$obj->error, " No error logged" );
}

### test unknown type
{ ### must turn on warnings to catch error here
local $Archive::Extract::WARN = 1;

my $warnings;
local $SIG{__WARN__} = sub { $warnings .= "@_" };

my $ae = $Class->new( archive => $Me );
ok( !$ae, " No archive created based on '$Me'" );
ok( !$Class->error, " Error not captured in class method" );
ok( $warnings, " Error captured as warning" );
like( $warnings, qr/Cannot determine file type for/,
" Error is: unknown file type" );
}
}

### test multiple errors
### XXX whitebox test
{ ### grab a random file from the template, so we can make an object
my $ae = Archive::Extract->new(
archive => File::Spec->catfile($SrcDir,[keys %$tmpl]->[0])
);
ok( $ae, "Archive created" );
ok( not($ae->error), " No errors yet" );

### log a few errors
{ local $Archive::Extract::WARN = 0;
$ae->_error( $_ ) for 1..5;
}

my $err = $ae->error;
ok( $err, " Errors retrieved" );

my $expect = join $/, 1..5;
is( $err, $expect, " As expected" );

### this resets the errors
### override the 'check' routine to return false, so we bail out of
### extract() early and just run the error reset code;
{ no warnings qw[once redefine];
local *Archive::Extract::check = sub { return };
$ae->extract;
}
ok( not($ae->error), " Errors erased after ->extract() call" );
}

### XXX whitebox test
### test __get_extract_dir
SKIP: { my $meth = '__get_extract_dir';
Expand Down Expand Up @@ -243,15 +288,18 @@ SKIP: { my $meth = '__get_extract_dir';
}
}

for my $switch (0,1) {
### configuration to run in: allow perl or allow binaries
for my $switch ( [0,1], [1,0] ) {
my $cfg = "PP: $switch->[0] Bin: $switch->[1]";

local $Archive::Extract::PREFER_BIN = $switch;
diag("Running extract with PREFER_BIN = $Archive::Extract::PREFER_BIN")
if $Debug;
local $Archive::Extract::_ALLOW_PURE_PERL = $switch->[0];
local $Archive::Extract::_ALLOW_BIN = $switch->[1];

diag("Running extract with configuration: $cfg") if $Debug;

for my $archive (keys %$tmpl) {

diag("Extracting $archive") if $Debug;
diag("Extracting $archive in config $cfg") if $Debug;

### check first if we can do the proper

Expand Down Expand Up @@ -313,7 +361,7 @@ for my $switch (0,1) {

### test buffers ###
my $turn_off = !$use_buffer && !$pgm_fail &&
$Archive::Extract::PREFER_BIN;
$Archive::Extract::_ALLOW_BIN;

### whitebox test ###
### stupid warnings ###
Expand All @@ -331,31 +379,41 @@ for my $switch (0,1) {

my $rv = $ae->extract( to => $to );

ok( $rv, "extract() for '$archive' reports success");

diag("Extractor was: " . $ae->_extractor) if $Debug;

SKIP: {
my $re = qr/^No buffer captured/;
my $err = $ae->error || '';

### skip buffer tests if we dont have buffers or
### explicitly turned them off
skip "No buffers available", 7,
skip "No buffers available", 8
if ( $turn_off || !IPC::Cmd->can_capture_buffer)
&& $err =~ $re;

### skip tests if we dont have an extractor
skip "No extractor available", 8
if $err =~ /Extract failed; no extractors available/;

ok( $rv, "extract() for '$archive' reports success ($cfg)");

diag("Extractor was: " . $ae->_extractor) if $Debug;

### if we /should/ have buffers, there should be
### no errors complaining we dont have them...
unlike( $err, $re,
"No errors capturing buffers" );

### might be 1 or 2, depending wether we extracted
### a dir too
my $files = $ae->files || [];
my $file_cnt = grep { defined } $file, $dir;
is( scalar @{ $ae->files || []}, $file_cnt,
is( scalar @$files, $file_cnt,
"Found correct number of output files" );
is( $ae->files->[-1], $nix_path,

### due to prototypes on is(), if there's no -1 index on
### the array ref, it'll give a fatal exception:
### "Modification of non-creatable array value attempted,
### subscript -1 at -e line 1." So wrap it in do { }
is( do { $files->[-1] }, $nix_path,
"Found correct output file '$nix_path'" );

ok( -e $abs_path,
Expand Down
2 changes: 1 addition & 1 deletion lib/Archive/Extract/t/src/double_dir.zip.packed
Expand Up @@ -10,7 +10,7 @@ To recreate it use the following command:

uupacktool.pl -p lib/Archive/Extract/t/src/double_dir.zip lib/Archive/Extract/t/src/double_dir.zip.packed

Created at Thu Sep 20 15:38:01 2007
Created at Sat Dec 13 17:18:49 2008
#########################################################################
__UU__
M4$L#!`H``````&QH,S0````````````````%`!4`>"]Y+WI55`D``PR`ST,,
Expand Down
2 changes: 1 addition & 1 deletion lib/Archive/Extract/t/src/x.Z.packed
Expand Up @@ -10,7 +10,7 @@ To recreate it use the following command:

uupacktool.pl -p lib/Archive/Extract/t/src/x.Z lib/Archive/Extract/t/src/x.Z.packed

Created at Thu Sep 20 15:38:01 2007
Created at Sat Dec 13 17:18:49 2008
#########################################################################
__UU__
''YV0>`(J````
2 changes: 1 addition & 1 deletion lib/Archive/Extract/t/src/x.bz2.packed
Expand Up @@ -10,7 +10,7 @@ To recreate it use the following command:

uupacktool.pl -p lib/Archive/Extract/t/src/x.bz2 lib/Archive/Extract/t/src/x.bz2.packed

Created at Thu Sep 20 15:38:01 2007
Created at Sat Dec 13 17:18:49 2008
#########################################################################
__UU__
.0EIH.1=R13A0D```````
2 changes: 1 addition & 1 deletion lib/Archive/Extract/t/src/x.gz.packed
Expand Up @@ -10,7 +10,7 @@ To recreate it use the following command:

uupacktool.pl -p lib/Archive/Extract/t/src/x.gz lib/Archive/Extract/t/src/x.gz.packed

Created at Thu Sep 20 15:38:01 2007
Created at Sat Dec 13 17:18:49 2008
#########################################################################
__UU__
6'XL("+F;6D8``W@``P``````````````
2 changes: 1 addition & 1 deletion lib/Archive/Extract/t/src/x.jar.packed
Expand Up @@ -10,7 +10,7 @@ To recreate it use the following command:

uupacktool.pl -p lib/Archive/Extract/t/src/x.jar lib/Archive/Extract/t/src/x.jar.packed

Created at Thu Sep 20 15:38:01 2007
Created at Sat Dec 13 17:18:49 2008
#########################################################################
__UU__
M4$L#!`H```````MAQ3`````````````````!`!``8558#`!)`B%!EIO!0/4!
Expand Down
2 changes: 1 addition & 1 deletion lib/Archive/Extract/t/src/x.lzma.packed
Expand Up @@ -10,7 +10,7 @@ To recreate it use the following command:

uupacktool.pl -p lib/Archive/Extract/t/src/x.lzma lib/Archive/Extract/t/src/x.lzma.packed

Created at Tue Mar 4 00:26:10 2008
Created at Sat Dec 13 17:18:49 2008
#########################################################################
__UU__
270``@```````````````````
2 changes: 1 addition & 1 deletion lib/Archive/Extract/t/src/x.par.packed
Expand Up @@ -10,7 +10,7 @@ To recreate it use the following command:

uupacktool.pl -p lib/Archive/Extract/t/src/x.par lib/Archive/Extract/t/src/x.par.packed

Created at Thu Sep 20 15:38:01 2007
Created at Sat Dec 13 17:18:49 2008
#########################################################################
__UU__
M4$L#!`H```````MAQ3`````````````````!`!``8558#`!)`B%!EIO!0/4!
Expand Down
2 changes: 1 addition & 1 deletion lib/Archive/Extract/t/src/x.tar.gz.packed
Expand Up @@ -10,7 +10,7 @@ To recreate it use the following command:

uupacktool.pl -p lib/Archive/Extract/t/src/x.tar.gz lib/Archive/Extract/t/src/x.tar.gz.packed

Created at Thu Sep 20 15:38:01 2007
Created at Sat Dec 13 17:18:49 2008
#########################################################################
__UU__
M'XL(`````````^W.NPW"0!!%T2EE2YC%:[N>#7""1,"G?QM##!&.SDE&(]W@
Expand Down
2 changes: 1 addition & 1 deletion lib/Archive/Extract/t/src/x.tar.packed
Expand Up @@ -10,7 +10,7 @@ To recreate it use the following command:

uupacktool.pl -p lib/Archive/Extract/t/src/x.tar lib/Archive/Extract/t/src/x.tar.packed

Created at Thu Sep 20 15:38:01 2007
Created at Sat Dec 13 17:18:49 2008
#########################################################################
__UU__
M80``````````````````````````````````````````````````````````
Expand Down
2 changes: 1 addition & 1 deletion lib/Archive/Extract/t/src/x.tgz.packed
Expand Up @@ -10,7 +10,7 @@ To recreate it use the following command:

uupacktool.pl -p lib/Archive/Extract/t/src/x.tgz lib/Archive/Extract/t/src/x.tgz.packed

Created at Thu Sep 20 15:38:01 2007
Created at Sat Dec 13 17:18:49 2008
#########################################################################
__UU__
M'XL(`````````^W.NPW"0!!%T2EE2YC%:[N>#7""1,"G?QM##!&.SDE&(]W@
Expand Down
2 changes: 1 addition & 1 deletion lib/Archive/Extract/t/src/x.zip.packed
Expand Up @@ -10,7 +10,7 @@ To recreate it use the following command:

uupacktool.pl -p lib/Archive/Extract/t/src/x.zip lib/Archive/Extract/t/src/x.zip.packed

Created at Thu Sep 20 15:38:01 2007
Created at Sat Dec 13 17:18:49 2008
#########################################################################
__UU__
M4$L#!`H```````MAQ3`````````````````!`!``8558#`!)`B%!EIO!0/4!
Expand Down
2 changes: 1 addition & 1 deletion lib/Archive/Extract/t/src/y.jar.packed
Expand Up @@ -10,7 +10,7 @@ To recreate it use the following command:

uupacktool.pl -p lib/Archive/Extract/t/src/y.jar lib/Archive/Extract/t/src/y.jar.packed

Created at Thu Sep 20 15:38:01 2007
Created at Sat Dec 13 17:18:49 2008
#########################################################################
__UU__
M4$L#!`H``````,NBB#$````````````````"`!``>2]56`P`M%6W06Y4MT'U
Expand Down
2 changes: 1 addition & 1 deletion lib/Archive/Extract/t/src/y.par.packed
Expand Up @@ -10,7 +10,7 @@ To recreate it use the following command:

uupacktool.pl -p lib/Archive/Extract/t/src/y.par lib/Archive/Extract/t/src/y.par.packed

Created at Thu Sep 20 15:38:01 2007
Created at Sat Dec 13 17:18:49 2008
#########################################################################
__UU__
M4$L#!`H``````,NBB#$````````````````"`!``>2]56`P`M%6W06Y4MT'U
Expand Down
2 changes: 1 addition & 1 deletion lib/Archive/Extract/t/src/y.tar.bz2.packed
Expand Up @@ -10,7 +10,7 @@ To recreate it use the following command:

uupacktool.pl -p lib/Archive/Extract/t/src/y.tar.bz2 lib/Archive/Extract/t/src/y.tar.bz2.packed

Created at Thu Sep 20 15:38:01 2007
Created at Sat Dec 13 17:18:50 2008
#########################################################################
__UU__
M0EIH.3%!6293636W".T``+)[E,B``$!``/>```-B"1XP!```0``((`"2A*4]
Expand Down
2 changes: 1 addition & 1 deletion lib/Archive/Extract/t/src/y.tar.gz.packed
Expand Up @@ -10,7 +10,7 @@ To recreate it use the following command:

uupacktool.pl -p lib/Archive/Extract/t/src/y.tar.gz lib/Archive/Extract/t/src/y.tar.gz.packed

Created at Thu Sep 20 15:38:01 2007
Created at Sat Dec 13 17:18:51 2008
#########################################################################
__UU__
M'XL(`````````^W1,0Z#,`R%81\E-R"F><EY&,I2J4.!`4Y?JH@5J4,JH?[?
Expand Down
2 changes: 1 addition & 1 deletion lib/Archive/Extract/t/src/y.tar.packed
Expand Up @@ -10,7 +10,7 @@ To recreate it use the following command:

uupacktool.pl -p lib/Archive/Extract/t/src/y.tar lib/Archive/Extract/t/src/y.tar.packed

Created at Thu Sep 20 15:38:01 2007
Created at Sat Dec 13 17:18:50 2008
#########################################################################
__UU__
M>2\`````````````````````````````````````````````````````````
Expand Down
2 changes: 1 addition & 1 deletion lib/Archive/Extract/t/src/y.tbz.packed
Expand Up @@ -10,7 +10,7 @@ To recreate it use the following command:

uupacktool.pl -p lib/Archive/Extract/t/src/y.tbz lib/Archive/Extract/t/src/y.tbz.packed

Created at Thu Sep 20 15:38:01 2007
Created at Sat Dec 13 17:18:51 2008
#########################################################################
__UU__
M0EIH.3%!6293636W".T``+)[E,B``$!``/>```-B"1XP!```0``((`"2A*4]
Expand Down
2 changes: 1 addition & 1 deletion lib/Archive/Extract/t/src/y.tgz.packed
Expand Up @@ -10,7 +10,7 @@ To recreate it use the following command:

uupacktool.pl -p lib/Archive/Extract/t/src/y.tgz lib/Archive/Extract/t/src/y.tgz.packed

Created at Thu Sep 20 15:38:02 2007
Created at Sat Dec 13 17:18:51 2008
#########################################################################
__UU__
M'XL(`````````^W1,0Z#,`R%81\E-R"F><EY&,I2J4.!`4Y?JH@5J4,JH?[?
Expand Down
2 changes: 1 addition & 1 deletion lib/Archive/Extract/t/src/y.zip.packed
Expand Up @@ -10,7 +10,7 @@ To recreate it use the following command:

uupacktool.pl -p lib/Archive/Extract/t/src/y.zip lib/Archive/Extract/t/src/y.zip.packed

Created at Thu Sep 20 15:38:02 2007
Created at Sat Dec 13 17:18:51 2008
#########################################################################
__UU__
M4$L#!`H``````,NBB#$````````````````"`!``>2]56`P`M%6W06Y4MT'U
Expand Down

0 comments on commit 8328529

Please sign in to comment.