Skip to content

Commit a678e32

Browse files
committed
Convert ack-i to YAML
1 parent ab5c780 commit a678e32

File tree

6 files changed

+141
-182
lines changed

6 files changed

+141
-182
lines changed

MANIFEST

+1-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ t/ack-group.t
4747
t/ack-h.yaml
4848
t/ack-help-types.t
4949
t/ack-help.t
50-
t/ack-i.barfly
51-
t/ack-i.t
50+
t/ack-i.yaml
5251
t/ack-ignore-dir.t
5352
t/ack-ignore-file.t
5453
t/ack-k.yaml

t/Util.pm

+1
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,7 @@ sub _validate_test {
13411341
indent-stdout
13421342
name
13431343
ordered
1344+
stdin
13441345
stderr
13451346
stdout
13461347
);

t/ack-i.barfly

-140
This file was deleted.

t/ack-i.t

-39
This file was deleted.

t/ack-i.yaml

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
name: Straight -i
3+
args:
4+
- APPLE t/swamp/groceries/fruit t/swamp/groceries/junk t/swamp/groceries/meat -i
5+
- APPLE t/swamp/groceries/fruit t/swamp/groceries/junk t/swamp/groceries/meat --ignore-case
6+
ordered: true
7+
stdout: |
8+
t/swamp/groceries/fruit:1:apple
9+
t/swamp/groceries/junk:1:apple fritters
10+
11+
---
12+
name: No -i or -I
13+
args:
14+
- foo
15+
- foo -I
16+
- foo --no-smart-case
17+
ordered: true
18+
stdin: |
19+
Football
20+
foo bar
21+
foOtball
22+
bluhblah
23+
football
24+
stdout: |
25+
foo bar
26+
football
27+
28+
---
29+
name: Normal -i
30+
args:
31+
- foo -i
32+
- foo --ignore-case
33+
- Foo -i
34+
- Foo --ignore-case
35+
ordered: true
36+
stdin: |
37+
Football
38+
foo bar
39+
pickles
40+
foOtball
41+
bluhblah
42+
football
43+
stdout: |
44+
Football
45+
foo bar
46+
foOtball
47+
football
48+
49+
---
50+
name: Smartcase invoked
51+
args:
52+
- foo --smart-case
53+
- foo -S
54+
ordered: true
55+
stdin: |
56+
football
57+
foo bar
58+
Football
59+
foOtball
60+
stdout: |
61+
football
62+
foo bar
63+
Football
64+
foOtball
65+
66+
---
67+
name: Smartcase invoked because of the case of the search string
68+
args:
69+
- Foo --smart-case
70+
- Foo -S
71+
ordered: true
72+
stdin: |
73+
football
74+
foo bar
75+
Football
76+
foOtball
77+
stdout: |
78+
Football
79+
80+
---
81+
name: -i overrides --smart-case
82+
args:
83+
- Foo --smart-case -i
84+
- foo --smart-case -i
85+
- Foo -S -i
86+
- foo -S -i
87+
ordered: true
88+
stdin: |
89+
football
90+
foo bar
91+
Football
92+
foOtball
93+
stdout: |
94+
football
95+
foo bar
96+
Football
97+
foOtball
98+
99+
---
100+
name: -I overrides -i
101+
args:
102+
- Foo -i -I
103+
- Foo --ignore-case -I
104+
ordered: true
105+
stdin: |
106+
Football
107+
football
108+
foo bar
109+
foOtball
110+
stdout: |
111+
Football
112+
113+
---
114+
name: -I overrides --smart-case
115+
args:
116+
- Foo --smart-case -I
117+
- Foo -S -I
118+
ordered: true
119+
stdin: |
120+
Football
121+
football
122+
foo bar
123+
foOtball
124+
stdout: |
125+
Football

t/yaml.t

+14-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use warnings;
44
use strict;
55

6-
use Test::More tests => 15;
6+
use Test::More tests => 16;
77

88
use lib 't';
99
use Util;
@@ -18,7 +18,17 @@ MAIN: {
1818
my @tests = read_tests( $file );
1919

2020
for my $test ( @tests ) {
21+
my $tempfilename;
22+
if ( my $stdin = $test->{stdin} ) {
23+
my $fh = File::Temp->new( UNLINK => 0 ); # We'll delete it ourselves.
24+
$tempfilename = $fh->filename;
25+
print {$fh} $stdin;
26+
close $fh;
27+
}
2128
for my $args ( @{$test->{args}} ) {
29+
if ( $tempfilename ) {
30+
$args = [ @{$args}, $tempfilename ];
31+
}
2232
subtest $test->{name} . ' ' . join( ', ', @{$args} ) => sub {
2333
if ( $test->{ordered} ) {
2434
ack_lists_match( $args, $test->{stdout}, $test->{name} );
@@ -29,6 +39,9 @@ MAIN: {
2939
is( get_rc(), $test->{exitcode} );
3040
}
3141
}
42+
if ( $tempfilename ) {
43+
unlink( $tempfilename );
44+
}
3245
}
3346
};
3447
}

0 commit comments

Comments
 (0)