1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#!perl -w
use warnings;
use strict;
use Test::More tests => 6;
use lib 't';
use Util;
use File::Next ();
prep_environment();
my @files = qw(
t/swamp/options.pl
t/swamp/options.pl.bak
);
$_ = File::Next::reslash($_) for @files;
JUST_THE_DIR: {
my @expected = split( /\n/, <<"EOF" );
$files[0]:19:notawordhere
EOF
my @files = qw( t/swamp );
my @args = qw( notaword );
ack_sets_match( [ @args, @files ], \@expected, q{One hit for specifying a dir} );
}
SPECIFYING_A_BAK_FILE: {
my @expected = split( /\n/, <<"EOF" );
$files[0]:19:notawordhere
$files[1]:19:notawordhere
EOF
my @files = qw( t/swamp/options.pl t/swamp/options.pl.bak );
my @args = qw( notaword );
ack_sets_match( [ @args, @files ], \@expected, q{Two hits for specifying the file} );
}
FILE_NOT_THERE: {
my $file = File::Next::reslash( 't/swamp/perl.pod' );
my @expected_stderr = split( /\n/, <<'EOF' );
ack-standalone: non-existent-file.txt: No such file or directory
EOF
my @expected_stdout = split( /\n/, <<"EOF" );
${file}:3:=head2 There's important stuff in here!
EOF
my @files = ( 'non-existent-file.txt', $file );
my @args = qw( head2 );
my ($stdout, $stderr) = run_ack_with_stderr( @args, @files );
lists_match( $stderr, \@expected_stderr, q{Error if there's no file} );
lists_match( $stdout, \@expected_stdout, 'Find the one file that has a hit' );
}
|