Skip to content

Commit 62e2d64

Browse files
committed
Boolean -g is working again
1 parent 01c8f69 commit 62e2d64

File tree

4 files changed

+16
-23
lines changed

4 files changed

+16
-23
lines changed

lib/App/Ack.pm

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -875,24 +875,21 @@ sub build_all_regexes {
875875
$re_hilite = $re_match;
876876
$re_scan = join( '|', @scan_parts );
877877
}
878-
879-
# NOT: alpha NOT beta
880-
if ( @parts = @{$opt->{not}} ) {
878+
else {
881879
($re_match, $re_scan) = build_regex( $opt_regex, $opt );
882880
$re_hilite = $re_match;
881+
}
883882

883+
# The --not does not affect the main regex. It is checked separately.
884+
# NOT: alpha NOT beta
885+
if ( @parts = @{$opt->{not}} ) {
884886
my @not_parts;
885887
for my $part ( @parts ) {
886888
(my $re, undef) = build_regex( $part, $opt );
887889
push @not_parts, $re;
888890
}
889891
$re_not = join( '|', @not_parts );
890892
}
891-
# No booleans.
892-
else {
893-
($re_match, $re_scan) = build_regex( $opt_regex, $opt );
894-
$re_hilite = $re_match;
895-
}
896893

897894
return ($re_match, $re_not, $re_hilite, $re_scan);
898895
}

t/ack-g.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,23 +123,28 @@ stdout: |
123123
---
124124
name: -g and --and
125125
args: -g foo --and test t/
126-
stdout:
126+
stdout: |
127127
t/swamp/foo_test.py
128128
t/swamp/test_foo.py
129129
130130
---
131131
name: -g and --not
132132
args: -g foo --not test t/
133-
stdout:
133+
stdout: |
134134
t/etc/shebang.foobar.xxx
135135
t/swamp/file.foo
136136
137137
---
138138
name: -g and --or
139-
args: -g foo --or test t/
140-
stdout:
139+
args: -g foo --or ample t/
140+
stdout: |
141141
t/etc/shebang.foobar.xxx
142-
t/swamp/file.bar
142+
t/swamp/example.R
143143
t/swamp/file.foo
144144
t/swamp/foo_test.py
145+
t/swamp/Sample.ascx
146+
t/swamp/Sample.asmx
147+
t/swamp/sample.asp
148+
t/swamp/sample.aspx
149+
t/swamp/sample.rake
145150
t/swamp/test_foo.py

t/mutex.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,3 @@ exitcode: 255
7171
stdout:
7272
stderr: |
7373
ack: Options '--and' and '--or' can't be used together.
74-
75-
---
76-
name: --or and --not
77-
args:
78-
- this --or that --not other
79-
exitcode: 255
80-
stdout:
81-
stderr: |
82-
ack: Options '--not' and '--or' can't be used together.

t/yaml.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ MAIN: {
3434
if ( $tempfilename ) {
3535
$args = [ @{$args}, $tempfilename ];
3636
}
37-
subtest $test->{name} . ' ' . join( ', ', @{$args} ) => sub {
37+
subtest $test->{name} . ': ack ' . join( ' ', @{$args} ) => sub {
3838
if ( exists $test->{stderr} ) {
3939
ack_stderr_matches( $args, $test->{stderr}, $test->{name} );
4040
is( get_rc(), $test->{exitcode}, 'Exit code matches' );

0 commit comments

Comments
 (0)