-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tool to run yath when using cpanm and similar
- Loading branch information
Showing
4 changed files
with
121 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package App::Yath::Renderer::TAPHarness; | ||
use strict; | ||
use warnings; | ||
|
||
our $VERSION = '2.000000'; | ||
|
||
use parent 'App::Yath::Renderer'; | ||
use Test2::Harness::Util::HashBase; | ||
|
||
sub render_event {} | ||
|
||
sub finish { | ||
my $self = shift; | ||
my ($auditor) = @_; | ||
|
||
$TAP::Harness::Yath::SUMMARY = $auditor->summary; | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package TAP::Harness::Yath; | ||
use strict; | ||
use warnings; | ||
|
||
# $ENV{HARNESS_SUBCLASS} | ||
|
||
{ | ||
package TAP::Harness::Yath::Aggregator; | ||
|
||
use Test2::Harness::Util::HashBase qw{ | ||
files_total | ||
files_failed | ||
files_passed | ||
asserts_total | ||
asserts_passed | ||
asserts_failed | ||
}; | ||
|
||
sub has_errors { $_[0]->{+FILES_FAILED} || $_[0]->{+ASSERTS_FAILED} } | ||
|
||
sub total { $_[0]->{+ASSERTS_TOTAL} } | ||
sub failed { $_[0]->{+ASSERTS_FAILED} } | ||
sub passed { $_[0]->{+ASSERTS_PASSED} } | ||
|
||
sub total_files { $_[0]->{+FILES_TOTAL} } | ||
sub failed_files { $_[0]->{+FILES_FAILED} } | ||
} | ||
|
||
our $SUMMARY; | ||
|
||
use App::Yath::Script; | ||
use Test2::Harness::Util::HashBase qw{ | ||
color | ||
ignore_exit | ||
jobs | ||
lib | ||
switches | ||
timer | ||
verbosity | ||
}; | ||
|
||
sub runtests { | ||
my $self = shift; | ||
my (@tests) = @_; | ||
|
||
my @env_args = $ENV{TAP_HARNESS_YATH_ARGS} ? split(/\s*,\s*/, $ENV{TAP_HARNESS_YATH_ARGS}) : (); | ||
|
||
my @args = ( | ||
'test', | ||
$self->{+COLOR} ? '--color' : (), | ||
'--jobs=' . ($self->{+JOBS} // 1), | ||
'-v=' . ($self->{+VERBOSITY} // 0), | ||
(map { "-I$_" } @{$self->{+LIB} // []}), | ||
(map { "-S=$_" } @{$self->{+SWITCHES} // []}), | ||
'--renderer=Default', | ||
'--renderer=TAPHarness', | ||
@env_args, | ||
@tests, | ||
); | ||
|
||
my $got = App::Yath::Script::run(__FILE__, \@args); | ||
|
||
my $files_total = $SUMMARY->{'tests_seen'} //= 0; | ||
my $files_failed = $SUMMARY->{'failed'} //= $got; | ||
my $files_passed = $files_total - $files_failed; | ||
|
||
my $asserts_total = $SUMMARY->{'asserts_seen'} // 0; | ||
my $asserts_passed = $SUMMARY->{'asserts_passed'} // 0; | ||
my $asserts_failed = $SUMMARY->{'asserts_failed'} // 0; | ||
|
||
my $out = TAP::Harness::Yath::Aggregator->new( | ||
files_total => $files_total, | ||
files_failed => $files_failed, | ||
files_passed => $files_passed, | ||
|
||
asserts_total => $asserts_total, | ||
asserts_passed => $asserts_passed, | ||
asserts_failed => $asserts_failed, | ||
); | ||
|
||
return $out; | ||
} | ||
|
||
1; | ||
|
||
__END__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters