| 1 | package Test::Class::Moose::Runner; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | # ABSTRACT: Runner for Test::Class::Moose tests | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 32 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 32 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 32 | ▶ | use namespace::autoclean; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 32 | ▶ | use 5.010000; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 32 | our $VERSION = '1.00'; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 32 | ▶ | use Moose 2.0000; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 32 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 32 | ▶ | use Test::Class::Moose::Config; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 32 | has 'test_configuration' => ( | |||||||||||||||||||
| 19 | is => 'ro', | ||||||||||||||||||||
| 20 | isa => 'Test::Class::Moose::Config', | ||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 32 | has 'jobs' => ( | |||||||||||||||||||
| 24 | is => 'ro', | ||||||||||||||||||||
| 25 | isa => 'Int', | ||||||||||||||||||||
| 26 | default => 1, | ||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 32 | has 'show_parallel_progress' => ( | |||||||||||||||||||
| 30 | is => 'ro', | ||||||||||||||||||||
| 31 | isa => 'Bool', | ||||||||||||||||||||
| 32 | default => 1, | ||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 32 | has 'color_output' => ( | |||||||||||||||||||
| 36 | is => 'ro', | ||||||||||||||||||||
| 37 | isa => 'Bool', | ||||||||||||||||||||
| 38 | default => 1, | ||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | has 'executor_roles' => ( | ||||||||||||||||||||
| 42 | traits => ['Array'], | ||||||||||||||||||||
| 43 | is => 'ro', | ||||||||||||||||||||
| 44 | isa => 'ArrayRef[RoleName]', | ||||||||||||||||||||
| 45 | 39 | ▶ | default => sub { [] }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 46 | 32 | handles => { | |||||||||||||||||||
| 47 | _has_executor_roles => 'count', | ||||||||||||||||||||
| 48 | }, | ||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 32 | has '_executor' => ( | |||||||||||||||||||
| 52 | is => 'ro', | ||||||||||||||||||||
| 53 | init_arg => undef, | ||||||||||||||||||||
| 54 | lazy_build => 1, | ||||||||||||||||||||
| 55 | handles => [ 'runtests', 'test_classes', 'test_report' ], | ||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 32 | my %config_attrs = map { $_->init_arg => 1 } | |||||||||||||||||||
| 59 | Test::Class::Moose::Config->meta->get_all_attributes; | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 40 | ▶ | around BUILDARGS => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
| |||||||||||||||||||||
| 62 | 40 | my $orig = shift; | |||||||||||||||||||
| 63 | 40 | my $class = shift; | |||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 40 | my $p = $class->$orig(@_); | |||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 78 | ▶ | my %config_p = map { $config_attrs{$_} ? ( $_ => delete $p->{$_} ) : () } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 68 | 40 | keys %{$p}; | |||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | 40 | ▶ | $p->{test_configuration} ||= Test::Class::Moose::Config->new(%config_p); | ||||||||||||||||||
|
Condition33%1/3
$p->{"test_configuration"} ||= "Test::Class::Moose::Config"->new(%config_p)
MC/DC0%0/2
$p->{"test_configuration"} ||= "Test::Class::Moose::Config"->new(%config_p)
$p->{"test_configuration"}
"Test::Class::Moose::Config"->new(%config_p)
Truth table33%1/3
A ||= B
A= $p->{"test_configuration"}B= "Test::Class::Moose::Config"->new(%config_p)
| |||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 40 | return $p; | |||||||||||||||||||
| 73 | 32 | }; | |||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 35 | ▶ | sub _build__executor { | ||||||||||||||||||
|
Subroutine
_build__executor: called CC=3 SCAR=11.0
| |||||||||||||||||||||
| 76 | 35 | my $self = shift; | |||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | 35 | my $executor; | |||||||||||||||||||
| 79 | 35 | ▶ | if ( $self->jobs == 1 ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 80 | 24 | require Test::Class::Moose::Executor::Sequential; | |||||||||||||||||||
| 81 | 24 | $executor = Test::Class::Moose::Executor::Sequential->new( | |||||||||||||||||||
| 82 | test_configuration => $self->test_configuration ); | ||||||||||||||||||||
| 83 | } | ||||||||||||||||||||
| 84 | else { | ||||||||||||||||||||
| 85 | 11 | require Test::Class::Moose::Executor::Parallel; | |||||||||||||||||||
| 86 | 11 | $executor = Test::Class::Moose::Executor::Parallel->new( | |||||||||||||||||||
| 87 | test_configuration => $self->test_configuration, | ||||||||||||||||||||
| 88 | jobs => $self->jobs, | ||||||||||||||||||||
| 89 | color_output => $self->color_output, | ||||||||||||||||||||
| 90 | show_parallel_progress => $self->show_parallel_progress, | ||||||||||||||||||||
| 91 | ); | ||||||||||||||||||||
| 92 | } | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | 35 | ▶ | return $executor unless $self->_has_executor_roles; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | 1 | require Moose::Util; | |||||||||||||||||||
| 97 | 1 | Moose::Util::apply_all_roles( $executor, @{ $self->executor_roles } ); | |||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | 1 | return $executor; | |||||||||||||||||||
| 100 | } | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | 32 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | 32 | 1; | |||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | __END__ | ||||||||||||||||||||