Skip to content

Commit

Permalink
Convert ack-i to YAML
Browse files Browse the repository at this point in the history
  • Loading branch information
petdance committed Feb 6, 2025
1 parent ab5c780 commit a678e32
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 182 deletions.
3 changes: 1 addition & 2 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ t/ack-group.t
t/ack-h.yaml
t/ack-help-types.t
t/ack-help.t
t/ack-i.barfly
t/ack-i.t
t/ack-i.yaml
t/ack-ignore-dir.t
t/ack-ignore-file.t
t/ack-k.yaml
Expand Down
1 change: 1 addition & 0 deletions t/Util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,7 @@ sub _validate_test {
indent-stdout
name
ordered
stdin
stderr
stdout
);
Expand Down
140 changes: 0 additions & 140 deletions t/ack-i.barfly

This file was deleted.

39 changes: 0 additions & 39 deletions t/ack-i.t

This file was deleted.

125 changes: 125 additions & 0 deletions t/ack-i.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
name: Straight -i
args:
- APPLE t/swamp/groceries/fruit t/swamp/groceries/junk t/swamp/groceries/meat -i
- APPLE t/swamp/groceries/fruit t/swamp/groceries/junk t/swamp/groceries/meat --ignore-case
ordered: true
stdout: |
t/swamp/groceries/fruit:1:apple
t/swamp/groceries/junk:1:apple fritters
---
name: No -i or -I
args:
- foo
- foo -I
- foo --no-smart-case
ordered: true
stdin: |
Football
foo bar
foOtball
bluhblah
football
stdout: |
foo bar
football
---
name: Normal -i
args:
- foo -i
- foo --ignore-case
- Foo -i
- Foo --ignore-case
ordered: true
stdin: |
Football
foo bar
pickles
foOtball
bluhblah
football
stdout: |
Football
foo bar
foOtball
football
---
name: Smartcase invoked
args:
- foo --smart-case
- foo -S
ordered: true
stdin: |
football
foo bar
Football
foOtball
stdout: |
football
foo bar
Football
foOtball
---
name: Smartcase invoked because of the case of the search string
args:
- Foo --smart-case
- Foo -S
ordered: true
stdin: |
football
foo bar
Football
foOtball
stdout: |
Football
---
name: -i overrides --smart-case
args:
- Foo --smart-case -i
- foo --smart-case -i
- Foo -S -i
- foo -S -i
ordered: true
stdin: |
football
foo bar
Football
foOtball
stdout: |
football
foo bar
Football
foOtball
---
name: -I overrides -i
args:
- Foo -i -I
- Foo --ignore-case -I
ordered: true
stdin: |
Football
football
foo bar
foOtball
stdout: |
Football
---
name: -I overrides --smart-case
args:
- Foo --smart-case -I
- Foo -S -I
ordered: true
stdin: |
Football
football
foo bar
foOtball
stdout: |
Football
15 changes: 14 additions & 1 deletion t/yaml.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use warnings;
use strict;

use Test::More tests => 15;
use Test::More tests => 16;

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

for my $test ( @tests ) {
my $tempfilename;
if ( my $stdin = $test->{stdin} ) {
my $fh = File::Temp->new( UNLINK => 0 ); # We'll delete it ourselves.
$tempfilename = $fh->filename;
print {$fh} $stdin;
close $fh;
}
for my $args ( @{$test->{args}} ) {
if ( $tempfilename ) {
$args = [ @{$args}, $tempfilename ];
}
subtest $test->{name} . ' ' . join( ', ', @{$args} ) => sub {
if ( $test->{ordered} ) {
ack_lists_match( $args, $test->{stdout}, $test->{name} );
Expand All @@ -29,6 +39,9 @@ MAIN: {
is( get_rc(), $test->{exitcode} );
}
}
if ( $tempfilename ) {
unlink( $tempfilename );
}
}
};
}
Expand Down

0 comments on commit a678e32

Please sign in to comment.