191122.1 · 483bb6b2aedf01a5b1adfec17850f1d13e107cf3
Rename t/issue*.t to be more meaningful
reading declarations
@@ -85,7 +85,9 @@ t/config-backwards-compat.t t/config-finder.t t/config-loader.t t/context.t+t/context-with-newlines.t t/default-filter.t+t/empty-lines.t t/exit-code.t t/ext-filter.t t/file-iterator.t@@ -103,19 +105,17 @@ t/invalid-ackrc.t t/invalid-options.t t/inverted-file-filter.t t/is-filter.t-t/issue244.t-t/issue491.t-t/issue522.t-t/issue562.t-t/issue571.t+t/line-endings.t t/longopts.t t/lowercase.t t/match-filter.t+t/multiple-captures.t t/mutex-options.t t/named-pipes.t t/needs-line-scan.t t/noackrc.t t/noenv.t+t/prescan-line-boundaries.t t/process-substitution.t t/runtests.pl t/trailing-whitespace.t
@@ -285,6 +285,7 @@ subtest 'test -g on a path' => sub { my $file_regex = 'text'; my @expected = qw(+ t/context-with-newlines.t t/context.t t/text/amontillado.txt t/text/bill-of-rights.txt@@ -306,6 +307,7 @@ subtest 'test -g with --color' => sub { my $file_regex = 'text'; my $expected_original = <<'HERE';+t/con(text)-with-newlines.t t/con(text).t t/(text)/amontillado.txt t/(text)/bill-of-rights.txt@@ -339,6 +341,7 @@ subtest q{test -g without --color; make sure colors don't show} => sub { my $file_regex = 'text'; my $expected = <<'HERE';+t/context-with-newlines.t t/context.t t/text/amontillado.txt t/text/bill-of-rights.txt
@@ -0,0 +1,20 @@+#!perl++# https://github.com/beyondgrep/ack2/issues/522++use strict;+use warnings;+use Test::More tests => 4;++use lib 't';+use Util;++prep_environment();++my @stdout;++@stdout = run_ack("use strict;\nuse warnings", 't/swamp');+is_empty_array( \@stdout, 'An embedded newline in the search regex should never match anything' );++@stdout = run_ack('-A', '1', "use strict;\nuse warnings", 't/swamp');+is_empty_array( \@stdout, 'An embedded newline in the search regex should never match anything, even with context' );
@@ -0,0 +1,23 @@+#!perl++# https://github.com/beyondgrep/ack2/issues/562++use strict;+use warnings;+use lib 't';++use Test::More tests => 2;+use Util;++prep_environment();+++my $tempfile = create_tempfile( ('') x 3 );++my @results = run_ack('^\s\s+$', $tempfile->filename);++is_empty_array( \@results, '^\s\s+$ should never match a sequence of empty lines' );++done_testing();++exit 0;
t/issue244.t
@@ -1,18 +0,0 @@-#!perl--# https://github.com/beyondgrep/ack2/issues/244--use strict;-use warnings;-use Test::More;--use lib 't';-use Util;--plan tests => 2;--prep_environment();--my ( $stdout, $stderr ) = run_ack_with_stderr('--color', '(foo)|(bar)', 't/swamp');-is_nonempty_array( $stdout );-is_empty_array( $stderr );
t/issue491.t
@@ -1,94 +0,0 @@-#!perl--=pod--This test checks for problems where line endings aren't handled correctly-by our pre-scanning of the file.-- # https://github.com/beyondgrep/ack2/issues/491- v2.14 with "-l" not emitting all matching files.-- > echo ' ' >space-newline.txt- > echo $' \n' >space-newline-newline.txt- > ack ' $' space-newline*.txt- space-newline-newline.txt- 1:-- space-newline.txt- 1:- > ack -l ' $' space-newline*.txt- space-newline.txt--=cut--use strict;-use warnings;-use lib 't';--use Test::More tests => 4;-use File::Temp;-use Util;--prep_environment();--my $dir = File::Temp->newdir;-my $wd = getcwd_clean();--safe_chdir( $dir->dirname );--my %matching_files = (- 'space-newline.txt' => " \n",- 'space-newline-space.txt' => " \n\t",- 'space-newline-newline.txt' => " \n\n",- 'space-newline-and-more.txt' => "this\n \nthat\n",- 'words-and-spaces.txt' => "this \nand that\n",-);-my %nonmatching_files = (- 'tabby.txt' => "\t\n",- 'also-tabby.txt' => " \t\n",-);--my %all_files = ( %matching_files, %nonmatching_files );-while ( my ($file,$content) = each %all_files ) {- write_file( $file, $content );-}-my @all_files = keys %all_files;-my @matching_files = keys %matching_files;-my @nonmatching_files = keys %nonmatching_files;--subtest 'Match normally' => sub {- plan tests => 2;-- my @results = run_ack( ' $', @all_files );- my @files_matched = @results;- s/:.*// for @files_matched;- sets_match( \@files_matched, [ @matching_files ], 'Found all the matching files in results' );-};--subtest 'Match with -l' => sub {- plan tests => 2;-- my @results = run_ack( '-l', ' $', @all_files );- sets_match( \@results, [ @matching_files ], 'Matching files should be in -l output' );-};--subtest 'Non-match with -L' => sub {- plan tests => 2;-- my @results = run_ack( '-L', ' $', @all_files );- sets_match( \@results, [ @nonmatching_files ], 'Nonmatching files should be in -L output' );-};--subtest 'Count with -c' => sub {- plan tests => 2;-- my @results = run_ack( '-c', ' $', @all_files );- sets_match( \@results, [- map { "$_:" . ( $matching_files{$_} ? 1 : 0 ) } @all_files- ], 'Matching files should be in -c output with correct counts' );-};--safe_chdir( $wd ); # Get out of temp directory so it can be cleaned up.--done_testing();-exit 0;
t/issue522.t
@@ -1,20 +0,0 @@-#!perl--# https://github.com/beyondgrep/ack2/issues/522--use strict;-use warnings;-use Test::More tests => 4;--use lib 't';-use Util;--prep_environment();--my @stdout;--@stdout = run_ack("use strict;\nuse warnings", 't/swamp');-is_empty_array( \@stdout, 'An embedded newline in the search regex should never match anything' );--@stdout = run_ack('-A', '1', "use strict;\nuse warnings", 't/swamp');-is_empty_array( \@stdout, 'An embedded newline in the search regex should never match anything, even with context' );
t/issue562.t
@@ -1,23 +0,0 @@-#!perl--# https://github.com/beyondgrep/ack2/issues/562--use strict;-use warnings;-use lib 't';--use Test::More tests => 2;-use Util;--prep_environment();---my $tempfile = create_tempfile( ('') x 3 );--my @results = run_ack('^\s\s+$', $tempfile->filename);--is_empty_array( \@results, '^\s\s+$ should never match a sequence of empty lines' );--done_testing();--exit 0;
t/issue571.t
@@ -1,21 +0,0 @@-#!perl--# https://github.com/beyondgrep/ack2/issues/571--use strict;-use warnings;-use lib 't';--use Test::More tests => 2;-use Util;--prep_environment();--my $tempfile = create_tempfile( <<'HERE' );-fo--oo-HERE--my @results = run_ack('-l', 'fo\s+oo', $tempfile->filename);-is_empty_array( \@results, '\s+ should never match across line boundaries' );
@@ -0,0 +1,94 @@+#!perl++=pod++This test checks for problems where line endings aren't handled correctly+by our pre-scanning of the file.++ # https://github.com/beyondgrep/ack2/issues/491+ v2.14 with "-l" not emitting all matching files.++ > echo ' ' >space-newline.txt+ > echo $' \n' >space-newline-newline.txt+ > ack ' $' space-newline*.txt+ space-newline-newline.txt+ 1:++ space-newline.txt+ 1:+ > ack -l ' $' space-newline*.txt+ space-newline.txt++=cut++use strict;+use warnings;+use lib 't';++use Test::More tests => 4;+use File::Temp;+use Util;++prep_environment();++my $dir = File::Temp->newdir;+my $wd = getcwd_clean();++safe_chdir( $dir->dirname );++my %matching_files = (+ 'space-newline.txt' => " \n",+ 'space-newline-space.txt' => " \n\t",+ 'space-newline-newline.txt' => " \n\n",+ 'space-newline-and-more.txt' => "this\n \nthat\n",+ 'words-and-spaces.txt' => "this \nand that\n",+);+my %nonmatching_files = (+ 'tabby.txt' => "\t\n",+ 'also-tabby.txt' => " \t\n",+);++my %all_files = ( %matching_files, %nonmatching_files );+while ( my ($file,$content) = each %all_files ) {+ write_file( $file, $content );+}+my @all_files = keys %all_files;+my @matching_files = keys %matching_files;+my @nonmatching_files = keys %nonmatching_files;++subtest 'Match normally' => sub {+ plan tests => 2;++ my @results = run_ack( ' $', @all_files );+ my @files_matched = @results;+ s/:.*// for @files_matched;+ sets_match( \@files_matched, [ @matching_files ], 'Found all the matching files in results' );+};++subtest 'Match with -l' => sub {+ plan tests => 2;++ my @results = run_ack( '-l', ' $', @all_files );+ sets_match( \@results, [ @matching_files ], 'Matching files should be in -l output' );+};++subtest 'Non-match with -L' => sub {+ plan tests => 2;++ my @results = run_ack( '-L', ' $', @all_files );+ sets_match( \@results, [ @nonmatching_files ], 'Nonmatching files should be in -L output' );+};++subtest 'Count with -c' => sub {+ plan tests => 2;++ my @results = run_ack( '-c', ' $', @all_files );+ sets_match( \@results, [+ map { "$_:" . ( $matching_files{$_} ? 1 : 0 ) } @all_files+ ], 'Matching files should be in -c output with correct counts' );+};++safe_chdir( $wd ); # Get out of temp directory so it can be cleaned up.++done_testing();+exit 0;
@@ -0,0 +1,21 @@+#!perl++# Multiple capture groups used to confuse ack.+# https://github.com/beyondgrep/ack2/issues/244++use strict;+use warnings;+use Test::More;++use lib 't';+use Util;++plan tests => 2;++prep_environment();++my ( $stdout, $stderr ) = run_ack_with_stderr('--color', '(foo)|(bar)', 't/swamp');+is_nonempty_array( $stdout );+is_empty_array( $stderr );++exit 0;
@@ -0,0 +1,21 @@+#!perl++# https://github.com/beyondgrep/ack2/issues/571++use strict;+use warnings;+use lib 't';++use Test::More tests => 2;+use Util;++prep_environment();++my $tempfile = create_tempfile( <<'HERE' );+fo++oo+HERE++my @results = run_ack('-l', 'fo\s+oo', $tempfile->filename);+is_empty_array( \@results, '\s+ should never match across line boundaries' );