"Fossies" - the Fresh Open Source Software Archive

Member "Archive-Tar-2.38/t/08_ptargrep.t" (14 Dec 2014, 831 Bytes) of package /linux/privat/Archive-Tar-2.38.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 use strict;
    2 use warnings;
    3 use Test::More tests => 1;
    4 
    5 use File::Spec;
    6 use FindBin '$Bin';
    7 use Archive::Tar;
    8 
    9 # filenames
   10 my $tartest = File::Spec->catfile("t", "ptargrep");
   11 my $foo = File::Spec->catfile("t", "ptargrep", "foo");
   12 my $tarfile = File::Spec->catfile("t", "ptargrep.tar");
   13 my $ptargrep = File::Spec->catfile($Bin, "..", "bin", "ptargrep");
   14 my $cmd = qq/$^X $ptargrep --list-only "file foo" $tarfile/;
   15 
   16 # create directory/files
   17 mkdir $tartest;
   18 open my $fh, ">", $foo or die $!;
   19 print $fh "file foo\n";
   20 close $fh;
   21 
   22 # create archive
   23 my $tar = Archive::Tar->new;
   24 $tar->add_files($foo);
   25 $tar->write($tarfile);
   26 
   27 # see if ptargrep matches
   28 my $out = qx{$cmd};
   29 cmp_ok($out, 'eq', "$foo\n", "ptargrep shows matched file");
   30 
   31 # cleanup
   32 END {
   33     unlink $tarfile or die $!;
   34     unlink $foo or die $!;
   35     rmdir $tartest or die $!;
   36 }