« blib/lib/App/Prove/Elasticsearch/Utils.pm
↑ Summary
blib/lib/App/Prove/Elasticsearch/Versioner/Default.pm »
| 1 | # ABSTRACT: Associate Test results with a tracked defect | ||||||||||||
| 2 | # PODNAME: App::ape::update | ||||||||||||
| 3 | |||||||||||||
| 4 | package App::ape::update; | ||||||||||||
| 5 | 6 | $App::ape::update::VERSION = '0.001'; | |||||||||||
| 6 | 6 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 6 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | |||||||||||||
| 9 | 6 | ▶ | use Getopt::Long qw{GetOptionsFromArray}; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 6 | ▶ | use App::Prove::Elasticsearch::Utils; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 6 | ▶ | use Pod::Usage; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | |||||||||||||
| 13 | 5 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||
| 14 | 5 | my ($class, @args) = @_; | |||||||||||
| 15 | |||||||||||||
| 16 | 5 | my (%options, @conf, $help); | |||||||||||
| 17 | GetOptionsFromArray( | ||||||||||||
| 18 | \@args, | ||||||||||||
| 19 | 'defect=s@' => \$options{defects}, | ||||||||||||
| 20 | 'platform=s@' => \$options{platforms}, | ||||||||||||
| 21 | 'version=s@' => \$options{versions}, | ||||||||||||
| 22 | 'configure=s@' => \@conf, | ||||||||||||
| 23 | 'status=s' => \$options{status}, | ||||||||||||
| 24 | 5 | 'help' => \$help | |||||||||||
| 25 | ); | ||||||||||||
| 26 | |||||||||||||
| 27 | 5 | ▶ | $options{defects} //= []; | ||||||||||
|
Condition100%2/2
$options{"defects"} //= []
MC/DC100%1/1
$options{"defects"} //= []
$options{"defects"}
Truth table100%2/2
A
A= $options{"defects"}
| |||||||||||||
| 28 | |||||||||||||
| 29 | #Deliberately exiting here, as I "unit" test this as the binary | ||||||||||||
| 30 | 5 | ▶ | pod2usage(0) if $help; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 31 | |||||||||||||
| 32 | 4 | ▶ | if (!scalar(@args)) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 33 | 1 | pod2usage( | |||||||||||
| 34 | -exitval => "NOEXIT", | ||||||||||||
| 35 | -msg => "Insufficient arguments. You must pass at least one test.", | ||||||||||||
| 36 | ); | ||||||||||||
| 37 | 1 | return 1; | |||||||||||
| 38 | } | ||||||||||||
| 39 | |||||||||||||
| 40 | 3 | ▶ | if (!scalar(@{$options{defects}})) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 41 | 1 | pod2usage( | |||||||||||
| 42 | -exitval => "NOEXIT", | ||||||||||||
| 43 | -msg => | ||||||||||||
| 44 | "Insufficient arguments. You must pass at least one defect.", | ||||||||||||
| 45 | ); | ||||||||||||
| 46 | 1 | return 4; | |||||||||||
| 47 | } | ||||||||||||
| 48 | |||||||||||||
| 49 | 2 | my $conf = App::Prove::Elasticsearch::Utils::process_configuration(@conf); | |||||||||||
| 50 | |||||||||||||
| 51 | 2 | ▶ | if ( | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 52 | scalar( | ||||||||||||
| 53 | grep { | ||||||||||||
| 54 | 2 | my $subj = $_; | |||||||||||
| 55 | 2 | grep { $subj eq $_ } qw{server.host server.port} | |||||||||||
| 56 | } keys(%$conf) | ||||||||||||
| 57 | ) != 2 | ||||||||||||
| 58 | ) { | ||||||||||||
| 59 | 1 | pod2usage( | |||||||||||
| 60 | -exitval => "NOEXIT", | ||||||||||||
| 61 | -msg => | ||||||||||||
| 62 | "Insufficient information provided to associate defect with test results to elasticsearch", | ||||||||||||
| 63 | ); | ||||||||||||
| 64 | 1 | return 3; | |||||||||||
| 65 | } | ||||||||||||
| 66 | |||||||||||||
| 67 | 1 | my $self = {options => \%options, cases => \@args}; | |||||||||||
| 68 | |||||||||||||
| 69 | 1 | $self->{indexer} = App::Prove::Elasticsearch::Utils::require_indexer($conf); | |||||||||||
| 70 | 1 | &{\&{$self->{indexer} . "::check_index"}}($conf); | |||||||||||
| 71 | |||||||||||||
| 72 | 1 | return bless($self, $class); | |||||||||||
| 73 | } | ||||||||||||
| 74 | |||||||||||||
| 75 | 1 | ▶ | sub run { | ||||||||||
|
Subroutine
run: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||
| 76 | 1 | my $self = shift; | |||||||||||
| 77 | 1 | my $global_result = 0; | |||||||||||
| 78 | 1 | foreach my $case (@{$self->{cases}}) { | |||||||||||
| 79 | 1 | $self->{options}{case} = $case; | |||||||||||
| 80 | $global_result += | ||||||||||||
| 81 | 1 | &{\&{$self->{indexer} . "::associate_case_with_result"}} | |||||||||||
| 82 | 1 | (%{$self->{options}}); | |||||||||||
| 83 | } | ||||||||||||
| 84 | 1 | ▶ | print "$global_result tests failed to be associated, examine above output\n" | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 85 | if $global_result; | ||||||||||||
| 86 | 1 | ▶ | return $global_result ? 2 : 0; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 87 | } | ||||||||||||
| 88 | |||||||||||||
| 89 | 6 | 1; | |||||||||||
| 90 | |||||||||||||
| 91 | __END__ | ||||||||||||