forked from beyondgrep/ack1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ack-env.t
75 lines (57 loc) · 2.48 KB
/
ack-env.t
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
63
64
65
66
67
68
69
70
71
72
73
74
75
#!perl
use warnings;
use strict;
use Test::More tests => 10;
use lib 't';
use Util;
prep_environment();
SINGLE_TEXT_MATCH_ENV: {
my @expected = (
'And I said: "My name is Sue! How do you do! Now you gonna die!"',
);
my @files = qw( t/text );
local $ENV{ACK_OPTIONS} = '-1'; # set the parameter via the options
my @args = qw( Sue! -h --text --env --nocolor ); # and specifying --env does not change the result
my @results = run_ack( @args, @files );
sets_match( \@results, \@expected, 'Looking for first instance of Sue! with --env' );
}
SINGLE_TEXT_MATCH_NOENV: {
my @expected = split( /\n/, <<'EOF' );
And I said: "My name is Sue! How do you do! Now you gonna die!"
Bill or George! Anything but Sue! I still hate that name!
EOF
my @files = qw( t/text );
local $ENV{ACK_OPTIONS} = '-1'; # set the parameter via the options
my @args = qw( Sue! -h --text --noenv ); # but disable environment processing
my @results = run_ack( @args, @files );
sets_match( \@results, \@expected, 'Looking for Sue! with --noenv' );
}
SEARCH_FOR_DASH_DASH_NOENV: {
my @expected = ' magic string --noenv';
my @files = qw( t/text );
local $ENV{ACK_OPTIONS} = '-h --cc'; # set the parameter via the options
my @args = qw( --nocolor -- --noenv t/swamp ); # but disable environment processing
my @results = run_ack( @args, @files );
sets_match( \@results, \@expected, 'Looking for Sue! with --noenv' );
}
SINGLE_TEXT_MATCH_NOENV_ENV: {
my @expected = (
'And I said: "My name is Sue! How do you do! Now you gonna die!"',
);
my @files = qw( t/text );
local $ENV{ACK_OPTIONS} = '-1'; # set the parameter via the options
my @args = qw( Sue! -h --text --noenv --env --nocolor ); # and specifying --noenv --env does not change the result
my @results = run_ack( @args, @files );
sets_match( \@results, \@expected, 'Looking for first instance of Sue! with --noenv --env' );
}
SINGLE_TEXT_MATCH_ENV_NOENV: {
my @expected = split( /\n/, <<'EOF' );
And I said: "My name is Sue! How do you do! Now you gonna die!"
Bill or George! Anything but Sue! I still hate that name!
EOF
my @files = qw( t/text );
local $ENV{ACK_OPTIONS} = '-1'; # set the parameter via the options
my @args = qw( Sue! -h --text --env --noenv ); # but disable environment processing
my @results = run_ack( @args, @files );
sets_match( \@results, \@expected, 'Looking for Sue! with --env --noenv' );
}