| 1 | # ABSTRACT: Read from a TAP archive and convert it for displaying | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package Archive::TAP::Convert; | ||||||||||||||||||||||||||||
| 4 | 3 | $Archive::TAP::Convert::VERSION = '0.007'; | |||||||||||||||||||||||||||
| 5 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Capture::Tiny qw( capture_merged ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use TAP::Harness; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use TAP::Harness::Archive; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 3 | require Exporter; | |||||||||||||||||||||||||||
| 13 | 3 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||
| 14 | 3 | our @EXPORT = qw(convert_from_taparchive); | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | # one and only subroutine of this module | ||||||||||||||||||||||||||||
| 17 | 2 | ▶ | sub convert_from_taparchive { | ||||||||||||||||||||||||||
|
Subroutine
convert_from_taparchive: called CC=8 SCAR=21.4
Pod
documented
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 2 | my %args = @_; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # Input Arguments: archive, formatter, force_inline | ||||||||||||||||||||||||||||
| 22 | # Set default values: | ||||||||||||||||||||||||||||
| 23 | die 'no archive specified' | ||||||||||||||||||||||||||||
| 24 | 2 | ▶ | unless (exists $args{archive}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 2 | my $formatter; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 2 | ▶ | if ( exists $args{formatter} && ref ( $args{formatter} ) =~ /^TAP::Formatter::/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $args{"formatter"} and ref($args{"formatter"}) =~ /^TAP::Formatter::/
MC/DC50%1/2
exists $args{"formatter"} and ref($args{"formatter"}) =~ /^TAP::Formatter::/
exists $args{"formatter"}
ref($args{"formatter"}) =~ /^TAP::Formatter::/
Truth table66%2/3
A and B
A= exists $args{"formatter"}B= ref($args{"formatter"}) =~ /^TAP::Formatter::/
| |||||||||||||||||||||||||||||
| 29 | 1 | $formatter = $args{formatter}; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | else { | ||||||||||||||||||||||||||||
| 32 | $args{formatter} = 'TAP::Formatter::HTML' | ||||||||||||||||||||||||||||
| 33 | 1 | ▶ | unless (exists $args{formatter}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | $args{force_inline} = 0 | ||||||||||||||||||||||||||||
| 35 | 1 | ▶ | unless (exists $args{force_inline}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | # This is the complicate but flexible version to: | ||||||||||||||||||||||||||||
| 38 | # use TAP::Formatter::HTML; | ||||||||||||||||||||||||||||
| 39 | # my $formatter = TAP::Formatter::HTML->new; | ||||||||||||||||||||||||||||
| 40 | 1 | (my $require_name = $args{formatter} . ".pm") =~ s{::}{/}g; | |||||||||||||||||||||||||||
| 41 | 1 | eval { | |||||||||||||||||||||||||||
| 42 | 1 | require $require_name; | |||||||||||||||||||||||||||
| 43 | 1 | $formatter = $args{formatter}->new(); | |||||||||||||||||||||||||||
| 44 | }; | ||||||||||||||||||||||||||||
| 45 | 1 | ▶ | die "Problems with formatter $args{formatter}" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | . " at $require_name: $@" | ||||||||||||||||||||||||||||
| 47 | if $@; | ||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | # if set, include all CSS and JS in HTML file | ||||||||||||||||||||||||||||
| 51 | 2 | ▶ | if ($args{force_inline}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 0 | $formatter->force_inline_css(1); | |||||||||||||||||||||||||||
| 53 | 0 | $formatter->force_inline_js (1); | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | # Now we do a lot of magic to convert this stuff... | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 2 | my $harness = TAP::Harness->new({ formatter => $formatter }); | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 2 | $formatter->really_quiet(1); | |||||||||||||||||||||||||||
| 61 | 2 | $formatter->prepare; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 2 | my $session; | |||||||||||||||||||||||||||
| 64 | my $aggregator = TAP::Harness::Archive->aggregator_from_archive({ | ||||||||||||||||||||||||||||
| 65 | archive => $args{archive}, | ||||||||||||||||||||||||||||
| 66 | parser_callbacks => { | ||||||||||||||||||||||||||||
| 67 | 6 | ▶ | ALL => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 68 | 6 | $session->result( $_[0] ); | |||||||||||||||||||||||||||
| 69 | }, | ||||||||||||||||||||||||||||
| 70 | }, | ||||||||||||||||||||||||||||
| 71 | 2 | ▶ | made_parser_callback => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 72 | 2 | $session = $formatter->open_test( $_[1], $_[0] ); | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | 2 | }); | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 2 | $aggregator->start; | |||||||||||||||||||||||||||
| 77 | 2 | $aggregator->stop; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | # This code also prints to STDOUT but we will catch it! | ||||||||||||||||||||||||||||
| 80 | 2 | ▶ | return capture_merged { $formatter->summary($aggregator) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 3 | 1; | |||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | __END__ | ||||||||||||||||||||||||||||