Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Die if the target is not recognized
  • Loading branch information
hinrik committed Jul 24, 2009
1 parent 65c15e2 commit e0fa86e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -3,6 +3,7 @@
- Move parsers to the App::Grok::Parser:: namespace
- Move all resource backends to App::Grok::Resource::*
- Added Win32::Console::ANSI as a recommended dep
- Make sure we die if the target is not recognized

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 @@ -28,6 +28,7 @@ t/04_targets/01_file.t
t/04_targets/02_synopsis.t
t/04_targets/03_function.t
t/04_targets/04_table.t
t/04_targets/05_failure.t
t_source/basic.pod
t_source/basic5.pod
xt/perlcriticrc
Expand Down
1 change: 1 addition & 0 deletions lib/App/Grok.pm
Expand Up @@ -145,6 +145,7 @@ sub render_target {
$found = spec_fetch($target) if !defined $found;
$found = table_fetch($target) if !defined $found;
$found = file_fetch($target) if !defined $found;
die "Target '$target' not recognized\n" if !defined $found;

my $parser = $self->detect_source($found);
eval "require $parser";
Expand Down
11 changes: 11 additions & 0 deletions t/04_targets/05_failure.t
@@ -0,0 +1,11 @@
use strict;
use warnings;
use File::Spec::Functions 'catfile';
use Test::More tests => 1;

# grok should die with an error message if the target is not recognized
my $grok = catfile('script', 'grok');

my $target = 'definitely_completely_unrecognized_target';
my $result = qx/$^X $grok $target 2>&1/;
like($result, qr/^Target '$target' not recognized$/, "Sane error message");

0 comments on commit e0fa86e

Please sign in to comment.