Skip to content

Commit

Permalink
Move ack-column to yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
petdance committed Jan 20, 2025
1 parent 26ad88e commit c984c33
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 91 deletions.
2 changes: 1 addition & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ t/ack-1.t
t/ack-Q.t
t/ack-c.yaml
t/ack-color.t
t/ack-column.t
t/ack-column.yaml
t/ack-create-ackrc.t
t/ack-dump.t
t/ack-f.yaml
Expand Down
10 changes: 7 additions & 3 deletions t/Util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1290,9 +1290,12 @@ sub read_tests {

$test->{args} = _split_args( $test->{args} );

# Assume successful run unless otherwise specified.
# Assume successful run.
$test->{exitcode} //= 0;

# Assume order doesn't matter.
$test->{ordered} //= 0;

_validate_test( $test );
}

Expand Down Expand Up @@ -1328,11 +1331,12 @@ sub _validate_test {
my $test = shift;

my @valid_keys = qw(
name
args
exitcode
stdout
name
ordered
stderr
stdout
);
for my $key ( keys %{$test} ) {
die "Invalid key $key" unless _in( $key, \@valid_keys );
Expand Down
3 changes: 3 additions & 0 deletions t/ack-c.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: -c
args: God -c --sort-files t/text
ordered: true
stdout: |
t/text/amontillado.txt:2
t/text/bill-of-rights.txt:0
Expand All @@ -21,6 +22,7 @@ stdout: |
---
name: -c and -v
args: the -i -w -v -c --sort-files t/text
ordered: true
stdout: |
t/text/amontillado.txt:206
t/text/bill-of-rights.txt:45
Expand All @@ -35,6 +37,7 @@ stdout: |
---
name: -c and -l
args: congress -i -l -c --sort-files t/text
ordered: true
stdout: |
t/text/bill-of-rights.txt:1
t/text/constitution.txt:29
Expand Down
85 changes: 0 additions & 85 deletions t/ack-column.t

This file was deleted.

45 changes: 45 additions & 0 deletions t/ack-column.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
name: With --columns
args: nevermore --column -w -i --with-filename --noenv t/text/raven.txt
ordered: true
stdout: |
t/text/raven.txt:55:23: Quoth the Raven, "Nevermore."
t/text/raven.txt:62:24: With such name as "Nevermore."
t/text/raven.txt:69:26: Then the bird said, "Nevermore."
t/text/raven.txt:76:18: Of 'Never -- nevermore.'
t/text/raven.txt:83:24: Meant in croaking "Nevermore."
t/text/raven.txt:90:26: She shall press, ah, nevermore!
t/text/raven.txt:97:23: Quoth the Raven, "Nevermore."
t/text/raven.txt:104:23: Quoth the Raven, "Nevermore."
t/text/raven.txt:111:23: Quoth the Raven, "Nevermore."
t/text/raven.txt:118:23: Quoth the Raven, "Nevermore."
t/text/raven.txt:125:22: Shall be lifted--nevermore!
---
name: With --column and --not
args: nevermore --not Quoth -w -i --with-filename --noenv --column t/text/raven.txt
ordered: true
stdout: |
t/text/raven.txt:62:24: With such name as "Nevermore."
t/text/raven.txt:69:26: Then the bird said, "Nevermore."
t/text/raven.txt:76:18: Of 'Never -- nevermore.'
t/text/raven.txt:83:24: Meant in croaking "Nevermore."
t/text/raven.txt:90:26: She shall press, ah, nevermore!
t/text/raven.txt:125:22: Shall be lifted--nevermore!
---
name: Without columns
args: nevermore -w -i --with-filename --noenv --no-column t/text/raven.txt
ordered: true
stdout: |
t/text/raven.txt:55: Quoth the Raven, "Nevermore."
t/text/raven.txt:62: With such name as "Nevermore."
t/text/raven.txt:69: Then the bird said, "Nevermore."
t/text/raven.txt:76: Of 'Never -- nevermore.'
t/text/raven.txt:83: Meant in croaking "Nevermore."
t/text/raven.txt:90: She shall press, ah, nevermore!
t/text/raven.txt:97: Quoth the Raven, "Nevermore."
t/text/raven.txt:104: Quoth the Raven, "Nevermore."
t/text/raven.txt:111: Quoth the Raven, "Nevermore."
t/text/raven.txt:118: Quoth the Raven, "Nevermore."
t/text/raven.txt:125: Shall be lifted--nevermore!
3 changes: 3 additions & 0 deletions t/ack-v.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Normal case
args: -v w t/text/ozymandias.txt
ordered: true
stdout: |
I met a traveller from an antique land
Stand in the desert... Near them, on the sand,
Expand All @@ -12,6 +13,7 @@ stdout: |
---
name: Ignore case
args: -i -v w t/text/ozymandias.txt
ordered: true
stdout: |
I met a traveller from an antique land
Stand in the desert... Near them, on the sand,
Expand All @@ -22,6 +24,7 @@ stdout: |
---
name: With not
args: -i -v the --not them t/text/ozymandias.txt
ordered: true
stdout: |
I met a traveller from an antique land
Who said: Two vast and trunkless legs of stone
Expand Down
9 changes: 7 additions & 2 deletions 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 => 5;
use Test::More tests => 6;

use lib 't';
use Util;
Expand All @@ -20,7 +20,12 @@ MAIN: {
for my $test ( @tests ) {
for my $args ( @{$test->{args}} ) {
subtest $file . ' ' . join( ', ', @{$args} ) => sub {
ack_sets_match( $args, $test->{stdout}, $test->{name} );
if ( $test->{ordered} ) {
ack_lists_match( $args, $test->{stdout}, $test->{name} );
}
else {
ack_sets_match( $args, $test->{stdout}, $test->{name} );
}
is( get_rc(), $test->{exitcode} );
}
}
Expand Down

0 comments on commit c984c33

Please sign in to comment.