Changeset 72


Ignore:
Timestamp:
11/29/05 21:32:17 (19 years ago)
Author:
thauvin
Message:
  • ensure compress return an error if command failed
Location:
trunk/soft/ObsData
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/soft/ObsData/ObsData/Archive/Compressed.pm

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r20 r72  
    5656    } 
    5757 
    58     open(my $sourcefh, "$self->{uncomp} '$self->{archive}' |") or return undef; 
     58    open(my $sourcefh, "$self->{uncomp} '$self->{archive}' 2>/dev/null |") or return undef; 
    5959     
    6060    if(!copy($sourcefh, $fh)) { 
     
    6464    } 
    6565     
    66     close($sourcefh); 
    6766    close($fh); 
     67    if(!close($sourcefh)) { 
     68        $self->seterror("$self->{uncomp} exit with error" . ($! ? (" " . $!) : "")); 
     69        unlink($fname); 
     70        return undef; 
     71    } 
    6872    $fname 
    6973} 
  • trunk/soft/ObsData/t/OA-03.t

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r12 r72  
    11# $Id$ 
    22 
    3 use Test::More tests => 4; 
     3use Test::More tests => 6; 
    44use ObsData::Archive; 
    55use File::Temp qw(tempdir); 
    66 
    77my $tempdir = tempdir; 
    8 print $tempdir . "\n"; 
    98 
    109my $oa = ObsData::Archive->new('testdata/coin.gz'); 
     
    1716ok(-r "$tempdir/coin", "the file has been really extract"); 
    1817 
     18$oa = ObsData::Archive->new('testdata/wrongcoin.gz'); 
     19ok(!$oa->extract('wrongcoin', "$tempdir/coin"), "Get an error if extraction failed"); 
     20ok($oa->error, "Can get error"); 
     21 
    1922system(qw(rm -fr), $tempdir); 
Note: See TracChangeset for help on using the changeset viewer.