Ticket #684: pgegrep_test.patch

File pgegrep_test.patch, 1.1 KB (added by dukeleto, 13 years ago)

This adds a pgegrep_output_like() function to help test pgegrep and adds a test for -V

  • (a) /dev/null vs. (b) t/tools/pgegrep.t

    a b  
     1#! perl 
     2# Copyright (C) 2009, Parrot Foundation. 
     3=head1 NAME 
     4 
     5t/tools/pgegrep.t - test the script tools/utils/pgegrep 
     6 
     7=head1 SYNOPSIS 
     8 
     9    % prove t/tools/pgegrep.t 
     10 
     11=head1 DESCRIPTION 
     12 
     13Tests the features of of the C<pgegrep> utility. 
     14 
     15=cut 
     16 
     17use strict; 
     18use warnings; 
     19use lib qw( . lib ../lib ../../lib ); 
     20 
     21use Fatal qw{open close}; 
     22use Test::More; 
     23use Parrot::Test tests => 1; 
     24use Parrot::Config; 
     25use File::Spec   (); 
     26 
     27sub pgegrep_output_like { 
     28    my ($options, $snippet, $desc)  = @_; 
     29 
     30    my $PARROT  = ".$PConfig{slash}$PConfig{test_prog}"; 
     31    my $pgegrep = File::Spec->catfile( qw{. tools util pgegrep} ); 
     32    my $out     = `$PARROT $pgegrep $options`; 
     33 
     34    like( $out, $snippet, $desc ); 
     35 
     36    return; 
     37} 
     38 
     39pgegrep_output_like( 
     40    '-V', 
     41    qr!\Qpgegrep v0.0.1\E!, 
     42    'pge reports correct version' 
     43); 
     44 
     45# Local Variables: 
     46#   mode: cperl 
     47#   cperl-indent-level: 4 
     48#   fill-column: 100 
     49# End: 
     50# vim: expandtab shiftwidth=4: