| 1 | package Tapper::Reports::Receiver::Level2::Codespeed; | ||||||||||||||||||||||||||||
| 2 | 2 | our $AUTHORITY = 'cpan:TAPPER'; | |||||||||||||||||||||||||||
| 3 | 2 | $Tapper::Reports::Receiver::Level2::Codespeed::VERSION = '5.0.2'; | |||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Data::DPath 'dpath'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Scalar::Util "reftype"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | sub submit | ||||||||||||||||||||||||||||
| 13 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
submit: called CC=10 SCAR=24.4
Pod
documented
| |||||||||||||||||||||||||||||
| 14 | 1 | my ($util, $report, $options) = @_; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 1 | my $codespeed_url = $options->{url}; | |||||||||||||||||||||||||||
| 17 | 1 | my $subscribe_dpath = $options->{subscribe_dpath}; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | return unless $codespeed_url && $subscribe_dpath; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$codespeed_url and $subscribe_dpath
MC/DC0%0/2
$codespeed_url and $subscribe_dpath
$codespeed_url
$subscribe_dpath
Truth table33%1/3
A and B
A= $codespeed_urlB= $subscribe_dpath
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | my $max_retry = 5; | |||||||||||||||||||||||||||
| 22 | 1 | my $tap_dom = $report->get_cached_tapdom; | |||||||||||||||||||||||||||
| 23 | 1 | my @chunks = dpath($subscribe_dpath)->match($tap_dom); | |||||||||||||||||||||||||||
| 24 | 1 | ▶ | @chunks = @{$chunks[0]} while $chunks[0] && reftype $chunks[0] eq "ARRAY"; # deref all array envelops | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$chunks[0] and builtin::reftype($chunks[0]) eq "ARRAY"
MC/DC50%1/2
$chunks[0] and builtin::reftype($chunks[0]) eq "ARRAY"
$chunks[0]
builtin::reftype($chunks[0]) eq "ARRAY"
Truth table66%2/3
A and B
A= $chunks[0]B= builtin::reftype($chunks[0]) eq "ARRAY"
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1 | ▶ | return unless @chunks; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 1 | my $ua = LWP::UserAgent->new; | |||||||||||||||||||||||||||
| 29 | 1 | $ua->timeout(10); | |||||||||||||||||||||||||||
| 30 | 1 | foreach my $chunk (@chunks) { | |||||||||||||||||||||||||||
| 31 | 4 | my $response; | |||||||||||||||||||||||||||
| 32 | 4 | my $retry = $max_retry; | |||||||||||||||||||||||||||
| 33 | 4 | ▶ | do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $response->is_success and $retry--
MC/DC0%0/2
not $response->is_success and $retry--
not $response->is_success
$retry--
Truth table33%1/3
not(A) and B
A= not $response->is_successB= $retry--
| |||||||||||||||||||||||||||||
| 34 | 4 | $response = $ua->post($codespeed_url."/result/add/", $chunk); | |||||||||||||||||||||||||||
| 35 | } while ( !$response->is_success and $retry-- ); | ||||||||||||||||||||||||||||
| 36 | 4 | ▶ | $util->log->warn("Submit to $codespeed_url FAILED.") if !$response->is_success; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 2 | 1; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | __END__ | ||||||||||||||||||||||||||||