4 @INC = ("../lib", "lib/compress");
8 use lib qw(t t/compress);
16 use IO::Compress::Gzip 'gzip' ;
20 plan(skip_all => "Examples needs Perl 5.005 or better - you have Perl $]" )
23 # use Test::NoWarnings, if available
26 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
28 plan tests => 19 + $extra ;
32 my $Inc = join " ", map qq["-I$_"] => @INC;
33 $Inc = '"-MExtUtils::testlib"'
34 if ! $ENV{PERL_CORE} && eval " require ExtUtils::testlib; " ;
36 my $Perl = ($ENV{'FULLPERL'} or $^X or 'perl') ;
37 $Perl = qq["$Perl"] if $^O eq 'MSWin32' ;
39 $Perl = "$Perl $Inc -w" ;
40 #$Perl .= " -Mblib " ;
41 my $examples = $ENV{PERL_CORE} ? "../ext/Compress/Zlib/examples"
54 my @hello1 = grep(s/$/\n/, split(/\n/, $hello1)) ;
67 my @hello2 = grep(s/$/\n/, split(/\n/, $hello2)) ;
69 my $file1 = "hello1.gz" ;
70 my $file2 = "hello2.gz" ;
71 my $stderr = "err.out" ;
73 for ($file1, $file2, $stderr) { 1 while unlink $_ } ;
76 gzip \$hello1 => $file1 ;
77 gzip \$hello2 => $file2 ;
82 my $expected = shift ;
84 my $stderr = 'err.out';
85 1 while unlink $stderr;
87 my $cmd = "$command 2>$stderr";
92 $aok &= is $?, 0, " exit status is 0" ;
94 $aok &= is readFile($stderr), '', " no stderr" ;
96 $aok &= is $stdout, $expected, " expected content is ok"
97 if defined $expected ;
100 diag "Command line: $cmd";
101 my ($file, $line) = (caller)[1,2];
102 diag "Test called from $file, line $line";
105 1 while unlink $stderr;
111 title "gzcat - command line" ;
112 check "$Perl ${examples}/gzcat $file1 $file2", $hello1 . $hello2;
114 title "gzcat - stdin" ;
115 check "$Perl ${examples}/gzcat <$file1 ", $hello1;
122 check "$Perl ${examples}/gzgrep the $file1 $file2",
123 join('', grep(/the/, @hello1, @hello2));
125 for ($file1, $file2, $stderr) { 1 while unlink $_ } ;
134 writeFile($file1, $hello1) ;
135 check "$Perl ${examples}/gzstream <$file1 >$file2";
138 check "$Perl ${examples}/gzcat $file2", $hello1 ;
143 for ($file1, $file2, $stderr) { 1 while unlink $_ } ;