« blib/lib/Alien/Build/Plugin/Extract/CommandLine.pm
↑ Summary
blib/lib/Alien/Build/Plugin/Download/Negotiate.pm »
| 1 | package Test::Alien::Diag; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use 5.008004; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Test2::API qw( context ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Exporter qw( import ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 2 | our @EXPORT = qw( alien_diag ); | |||||||||||||||||||||||||||
| 10 | 2 | our @EXPORT_OK = @EXPORT; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | # ABSTRACT: Print out standard diagnostic for Aliens in the test step. | ||||||||||||||||||||||||||||
| 13 | 2 | our $VERSION = '2.88'; # VERSION | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 2 | my @default_scalar_properties = qw( | |||||||||||||||||||||||||||
| 17 | cflags cflags_static libs libs_static version install_type | ||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 2 | my @default_list_properties = qw( | |||||||||||||||||||||||||||
| 21 | dynamic_libs bin_dir | ||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | sub alien_diag ($@) | ||||||||||||||||||||||||||||
| 25 | 7 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
alien_diag: called CC=22 SCAR=30.9
Pod
documented
| |||||||||||||||||||||||||||||
| 26 | 7 | my $ctx = context(); | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 7 | ▶ | my %options = defined $_[-1] && ref($_[-1]) eq 'HASH' ? %{ pop @_ } : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $_[-1] and ref $_[-1] eq "HASH"
MC/DC50%1/2
defined $_[-1] and ref $_[-1] eq "HASH"
defined $_[-1]
ref $_[-1] eq "HASH"
Truth table66%2/3
A and B
A= defined $_[-1]B= ref $_[-1] eq "HASH"
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 7 | ▶ | my @extra_properties = @{ delete $options{properties} || [] }; | ||||||||||||||||||||||||||
|
Condition100%2/2
delete $options{'properties'} || []
MC/DC100%1/1
delete $options{'properties'} || []
delete $options{'properties'}
Truth table100%2/2
A
A= delete $options{'properties'}
| |||||||||||||||||||||||||||||
| 31 | 7 | ▶ | my @extra_list_properties = @{ delete $options{list_properties} || [] }; | ||||||||||||||||||||||||||
|
Condition100%2/2
delete $options{'list_properties'} || []
MC/DC100%1/1
delete $options{'list_properties'} || []
delete $options{'list_properties'}
Truth table100%2/2
A
A= delete $options{'list_properties'}
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 7 | my $max = 0; | |||||||||||||||||||||||||||
| 34 | 7 | foreach my $alien (@_) | |||||||||||||||||||||||||||
| 35 | { | ||||||||||||||||||||||||||||
| 36 | 9 | foreach my $name (@default_scalar_properties, @default_list_properties, @extra_properties, @extra_list_properties) | |||||||||||||||||||||||||||
| 37 | { | ||||||||||||||||||||||||||||
| 38 | 84 | ▶ | if(eval { $alien->can($name) }) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | { | ||||||||||||||||||||||||||||
| 40 | 28 | my $str = "$alien->$name"; | |||||||||||||||||||||||||||
| 41 | 28 | ▶ | if(length($str) > $max) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | { | ||||||||||||||||||||||||||||
| 43 | 13 | $max = length($str); | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 7 | $ctx->diag(''); | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 7 | ▶ | if(%options) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | { | ||||||||||||||||||||||||||||
| 54 | 2 | my @extra = sort keys %options; | |||||||||||||||||||||||||||
| 55 | 2 | ▶ | $ctx->diag("warning: unknown option@{[ @extra > 1 ? 's' : '' ]} for alien_diag: @extra"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 2 | $ctx->diag("(you should check for typos or maybe upgrade to a newer version of Alien::Build)"); | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 7 | foreach my $alien (@_) { | |||||||||||||||||||||||||||
| 61 | 9 | $ctx->diag('') for 1..2; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 9 | my $found = 0; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 9 | foreach my $name (sort(@default_scalar_properties, @extra_properties)) | |||||||||||||||||||||||||||
| 66 | { | ||||||||||||||||||||||||||||
| 67 | 60 | ▶ | if(eval { $alien->can($name) }) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | { | ||||||||||||||||||||||||||||
| 69 | 20 | $found++; | |||||||||||||||||||||||||||
| 70 | 20 | my $value = $alien->$name; | |||||||||||||||||||||||||||
| 71 | 20 | ▶ | $value = '[undef]' unless defined $value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 20 | $ctx->diag(sprintf "%-${max}s = %s", "$alien->$name", $value); | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 9 | foreach my $name (sort(@default_list_properties, @extra_list_properties)) | |||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||
| 78 | 24 | ▶ | if(eval { $alien->can($name) }) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | { | ||||||||||||||||||||||||||||
| 80 | 8 | $found++; | |||||||||||||||||||||||||||
| 81 | 8 | my @list = eval { $alien->$name }; | |||||||||||||||||||||||||||
| 82 | 8 | ▶ | next if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | 8 | $ctx->diag(sprintf "%-${max}s = %s", "$alien->$name", $_) for @list; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 9 | ▶ | $ctx->diag("no diagnostics found for $alien") unless $found; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 7 | $ctx->diag('') for 1..2; | |||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 7 | $ctx->release; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 2 | 1; | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | __END__ | ||||||||||||||||||||||||||||