Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bin/pherkin
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Controlling Execution
--matching [mode] Step function multiple matches behaviour:
`first` (default) selects first match, `relaxed` warns
and runs first match or `strict` stops execution
--strict Requires steps to be defined; fails on undefined
and pending steps (steps forcing 'skip')

Output formatting

Expand Down Expand Up @@ -172,6 +174,4 @@ BEGIN {
}
}

my $result = App::pherkin->new()->run(@ARGV);

exit( $result->result eq 'failing' );
exit App::pherkin->new()->run(@ARGV);
32 changes: 25 additions & 7 deletions lib/App/pherkin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ has 'tags' => ( is => 'rw', isa => ArrayRef, required => 0 );
has 'tag_scheme' => ( is => 'rw', isa => ArrayRef, required => 0 );
has 'match_only' => ( is => 'rw', isa => Bool, default => 0 );
has 'matching' => ( is => 'rw', isa => Str, default => 'first');
has 'strict' => ( is => 'rw', isa => Bool, default => 0 );

has 'harness' => ( is => 'rw' );

Expand Down Expand Up @@ -121,7 +122,20 @@ sub _run_tests {
$executor->execute( $_, $harness, $tag_spec ) for @features;

$harness->shutdown();
return $harness->result;

my $exit_code = 0;
my $result = $harness->result;
if ($result eq 'failing') {
$exit_code = 2;
}
elsif ($self->strict) {
if ($result eq 'pending'
or $result eq 'undefined') {
$exit_code = 1;
}
}

return $exit_code;
}

sub _initialize_harness {
Expand Down Expand Up @@ -255,17 +269,18 @@ sub _process_arguments {
debug_profiles => ['debug-profiles'],

# Standard
help => ['h|help|?'],
help => [ 'h|help|?' ],
includes => [ 'I=s@', [] ],
lib => ['l|lib'],
blib => ['b|blib'],
output => ['o|output=s'],
lib => [ 'l|lib' ],
blib => [ 'b|blib' ],
output => [ 'o|output=s' ],
strict => [ 'strict' ],
steps => [ 's|steps=s@', [] ],
tags => [ 't|tags=s@', [] ],
i18n => ['i18n=s'],
i18n => [ 'i18n=s' ],
extensions => [ 'e|extension=s@', [] ],
matching => [ 'matching=s' ],
match_only => ['m|match'],
match_only => [ 'm|match' ],
);

GetOptions(
Expand Down Expand Up @@ -415,6 +430,9 @@ sub _process_arguments {
# Match only?
$self->match_only( $deref->('match_only') );

$self->strict( $deref->('strict') )
if $deref->('strict');

return ( pop @ARGV );
}

Expand Down