Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

New tests for GNU long options

  • Loading branch information...
commit e6078d0842ffba9d49e61bb45f596c40979e2914 1 parent d1ec5a9
petdance authored
View
1  Ack.pm
@@ -284,6 +284,7 @@ sub show_help {
print <<"END_OF_HELP";
Usage: ack [OPTION]... PATTERN [FILES]
+
Search for PATTERN in each source file in the tree from cwd on down.
If [FILES] is specified, then only those files/directories are checked.
ack may also search STDIN, but only if no FILES are specified, or if
View
3  Changes
@@ -18,6 +18,9 @@ NEXT
[ENHANCEMENTS]
Added .properties extension for --java.
+ Added more GNU-style long opts. Thanks to Ævar Arnfjörð Bjarmason,
+ my second utf-8 string.
+
1.60 Fri Mar 9 22:34:15 CST 2007
View
3  MANIFEST
@@ -17,6 +17,7 @@ t/ack-type.t
t/ack-v.t
t/filetypes.t
t/interesting.t
+t/longopts.t
t/pod.t
t/pod-coverage.t
t/standalone.t
@@ -48,6 +49,7 @@ t/swamp/html.htm
t/swamp/html.html
t/swamp/javascript.js
t/swamp/moose-andy.jpg
+t/swamp/options.pl
t/swamp/parrot.pir
t/swamp/perl-test.t
t/swamp/perl-without-extension
@@ -59,4 +61,3 @@ t/text/boy-named-sue.txt
t/text/freedom-of-choice.txt
t/text/science-of-myth.txt
t/text/shut-up-be-happy.txt
-META.yml Module meta-data (added by MakeMaker)
View
1  ack
@@ -663,6 +663,7 @@ L<http://ack.googlecode.com/svn/>
How appropriate to have I<ack>nowledgements!
Thanks to everyone who has contributed to ack in any way, including
+Ævar Arnfjörð Bjarmason,
Piers Cawley,
Stephen Steneker,
Elias Lutfallah,
View
1  ack-help.txt
@@ -1,4 +1,5 @@
Usage: ack [OPTION]... PATTERN [FILES]
+
Search for PATTERN in each source file in the tree from cwd on down.
If [FILES] is specified, then only those files/directories are checked.
ack may also search STDIN, but only if no FILES are specified, or if
View
12 ack-standalone
@@ -151,7 +151,7 @@ MAIN: {
my @what;
if ( @ARGV ) {
- @what = $is_windows ? glob( @ARGV ) : @ARGV;
+ @what = $is_windows ? <@ARGV> : @ARGV;
# Show filenames unless we've specified one single file
$opt{show_filename} = (@what > 1) || (!-f $what[0]);
@@ -342,6 +342,7 @@ sub _search_v {
return;
} # _search_v()
+=encoding utf-8
=head1 NAME
@@ -660,6 +661,7 @@ L<http://ack.googlecode.com/svn/>
How appropriate to have I<ack>nowledgements!
Thanks to everyone who has contributed to ack in any way, including
+Ævar Arnfjörð Bjarmason,
Piers Cawley,
Stephen Steneker,
Elias Lutfallah,
@@ -678,7 +680,7 @@ Ask Bjørn Hansen,
Jerry Gay,
Will Coleda,
Mike O'Regan,
-Slaven Rezic,
+Slaven Rezić,
Mark Stosberg,
David Alan Pisoni,
Adriano Ferreira,
@@ -1010,8 +1012,13 @@ sub options_sanity_check {
my %opts = @_;
my $ok = 1;
+ # List mode doesn't make sense with any of these
$ok = 0 if _option_conflict( \%opts, 'l', [qw( A B C o group )] );
+
+ # XXX This should work, I would think.
$ok = 0 if _option_conflict( \%opts, 'l', [qw( m )] );
+
+ # File-searching is definitely irrelevant on these
$ok = 0 if _option_conflict( \%opts, 'f', [qw( A B C o m group )] );
return $ok;
@@ -1078,6 +1085,7 @@ sub show_help {
print <<"END_OF_HELP";
Usage: ack [OPTION]... PATTERN [FILES]
+
Search for PATTERN in each source file in the tree from cwd on down.
If [FILES] is specified, then only those files/directories are checked.
ack may also search STDIN, but only if no FILES are specified, or if
View
2  t/ack-type.t
@@ -25,11 +25,13 @@ my $perl = [qw(
t/etc/shebang.pl.xxx
t/filetypes.t
t/interesting.t
+ t/longopts.t
t/pod-coverage.t
t/pod.t
t/standalone.t
t/swamp/0
t/swamp/Makefile.PL
+ t/swamp/options.pl
t/swamp/perl-test.t
t/swamp/perl-without-extension
t/swamp/perl.cgi
View
2  t/interesting.t
@@ -29,6 +29,7 @@ PERL_FILES: {
sets_match( \@files, [qw(
t/swamp/0
t/swamp/Makefile.PL
+ t/swamp/options.pl
t/swamp/perl.cgi
t/swamp/perl.pl
t/swamp/perl.pm
@@ -51,6 +52,7 @@ PERL_FILES_GLOBBED: {
sets_match( \@files, [qw(
t/swamp/0
t/swamp/Makefile.PL
+ t/swamp/options.pl
t/swamp/perl.cgi
t/swamp/perl.pl
t/swamp/perl.pm
View
111 t/longopts.t
@@ -0,0 +1,111 @@
+#!perl
+
+use strict;
+use warnings;
+
+=head1 DESCRIPTION
+
+This tests whether L<ack(1)>'s command line options work as expected.
+
+=cut
+
+use Test::More qw( no_plan );
+
+my $swamp = 't/swamp';
+my $ack = './ack';
+
+=head1 TESTS
+
+=over
+
+=cut
+
+=item --help
+
+=cut
+
+like
+ qx{ $^X $ack $_ },
+ qr{ ^Usage: .* Example: }xs,
+ qq{$_ output is correct}
+ for qw( -h --help );
+
+=item --version
+
+=cut
+
+like
+ qx{ $^X $ack $_ },
+ qr{ ^ack .* Copyright .* Perl }xs,
+ qq{$_ output is correct}
+ for qw( --version );
+
+=item --ignore-case
+
+=cut
+
+like
+ qx{ $^X $ack $_ "upper case" t/swamp/options.pl },
+ qr{UPPER CASE},
+ qq{$_ works correctly for ascii}
+ for qw( -i --ignore-case );
+
+=item --invert-match
+
+=cut
+
+unlike
+ qx{ $^X $ack $_ "use warnings" t/swamp/options.pl },
+ qr{use warnings},
+ qq{$_ works correctly}
+ for qw( -v --invert-match );
+
+=item --word-regexp
+
+=cut
+
+like
+ qx{ $^X $ack $_ "word" t/swamp/options.pl },
+ qr{ word },
+ qq{$_ ignores non-words}
+ for qw( -w --word-regexp );
+
+unlike
+ qx{ $^X $ack $_ "word" t/swamp/options.pl },
+ qr{notaword},
+ qq{$_ ignores non-words}
+ for qw( -w --word-regexp );
+
+=item --literal
+
+=cut
+
+like
+ qx{ $^X $ack $_ '[abc]' t/swamp/options.pl },
+ qr{\Q[abc]\E},
+ qq{$_ matches a literal string}
+ for qw( -Q --literal );
+
+=item --files-with-matches
+
+=cut
+
+like
+ qx{ $^X $ack $_ 'use strict' t/swamp/options.pl },
+ qr{t/swamp/options\.pl},
+ qq{$_ prints matching files}
+ for qw( -l --files-with-matches );
+
+=item --files-without-match
+
+=cut
+
+unlike
+ qx{ $^X $ack $_ 'use puppies' t/swamp/options.pl },
+ qr{t/swamp/options\.pl},
+ qq{$_ prints matching files}
+ for qw( -L --files-without-match );
+
+=back
+
+=cut
View
19 t/swamp/options.pl
@@ -0,0 +1,19 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+=head1 NAME
+
+options - Test file for ack command line options
+
+=cut
+
+[abc]
+
+@Q_fields = split(/\b(?:a|b|c)\b/)
+
+__DATA__
+THIS IS ALL IN UPPER CASE
+
+this is a word here
+notawordhere
View
1  t/zero.t
@@ -21,6 +21,7 @@ chdir $swamp or die "Unable to chdir to $swamp: $!\n";
my @actual_swamp_perl = qw(
0
Makefile.PL
+ options.pl
perl.cgi
perl.pl
perl.pm
Please sign in to comment.
Something went wrong with that request. Please try again.