Skip to content

Commit

Permalink
Fixed problem with -l/--locate, added test for it
Browse files Browse the repository at this point in the history
  • Loading branch information
hinrik committed Jul 24, 2009
1 parent 2f9635a commit 0bc215d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Changes
Expand Up @@ -5,6 +5,8 @@
- Added Win32::Console::ANSI as a recommended dep
- Make sure we die if the target is not recognized
- Fix small S32 parsing bug, causing Pod errors
- Look up man pages (perlintro, etc)
- Added test for -l/--locate

0.15 Fri Jul 24 11:47:30 GMT 2009
- Fix logic error causing 'ansi' not to be the default on non-Win32
Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Expand Up @@ -24,6 +24,7 @@ t/03_opts/03_help.t
t/03_opts/04_version.t
t/03_opts/05_no_pager.t
t/03_opts/06_index.t
t/03_opts/07_locate.t
t/04_targets/01_file.t
t/04_targets/02_synopsis.t
t/04_targets/03_function.t
Expand Down
4 changes: 2 additions & 2 deletions lib/App/Grok.pm
Expand Up @@ -48,12 +48,12 @@ sub run {

my $target = defined $opt{file} ? $opt{file} : $ARGV[0];

if ($opt{only}) {
if ($opt{locate}) {
if (defined $opt{file}) {
print file_locate($opt{file}), "\n";
}
else {
my $file = $self->locate_target();
my $file = $self->locate_target($target);
defined $file
? print $file, "\n"
: die "Target file not found\n";
Expand Down
11 changes: 11 additions & 0 deletions t/03_opts/07_locate.t
@@ -0,0 +1,11 @@
use strict;
use warnings;
use File::Spec::Functions 'catfile';
use Test::More tests => 2;

my $script = catfile('script', 'grok');
my $locate_short = qx/$^X $script -l s02/;
my $locate_long = qx/$^X $script --locate s02/;

like($locate_short, qr/S02-bits\.pod$/m, 'Found location of Synopsis 2 (-l)');
like($locate_long, qr/S02-bits\.pod$/m, 'Found location of Synopsis 2 (--locate)');

0 comments on commit 0bc215d

Please sign in to comment.