line
stmt
bran
cond
sub
pod
time
code
1
# ABSTRACT: Read from a TAP archive and convert it for displaying
2
3
4
package Convert::TAP::Archive;
5
{
6
$Convert::TAP::Archive::VERSION = '0.004'; # TRIAL
7
}
8
9
2
2
14423
use strict;
2
5
2
55
10
2
2
10
use warnings;
2
4
2
59
11
12
2
2
805
use Capture::Tiny qw( capture_merged );
2
39852
2
143
13
2
2
925
use TAP::Harness;
2
8536
2
58
14
2
2
846
use TAP::Harness::Archive;
2
212097
2
659
15
16
require Exporter;
17
our @ISA = qw(Exporter);
18
our @EXPORT = qw(convert_from_taparchive);
19
20
# one and only subroutine of this module
21
sub convert_from_taparchive {
22
23
# Input Arguments
24
1
1
1
103
my $archive_absolutepath = shift;
25
1
50
9
my $output_formatter_classname = shift || 'TAP::Formatter::HTML';
26
1
50
11
my $JS_inside_HTML = shift || 0; # boolean
27
28
# This is the complicate but flexible version to:
29
# use TAP::Formatter::HTML;
30
# my $formatter = TAP::Formatter::HTML->new;
31
1
5
my $formatter;
32
1
14
(my $require_name = $output_formatter_classname . ".pm") =~ s{::}{/}g;
33
1
5
eval {
34
1
844
require $require_name;
35
1
42197
$formatter = $output_formatter_classname->new();
36
};
37
1
50
19041
die "Problems with formatter $output_formatter_classname"
38
. " at $require_name: $@"
39
if $@;
40
41
# Now we do a lot of magic to convert this stuff...
42
43
1
16
my $harness = TAP::Harness->new({ formatter => $formatter });
44
45
1
253
$formatter->really_quiet(1);
46
1
19
$formatter->prepare;
47
48
1
29
my $session;
49
my $aggregator = TAP::Harness::Archive->aggregator_from_archive({
50
archive => $archive_absolutepath,
51
parser_callbacks => {
52
ALL => sub {
53
3
3
1820
$session->result( $_[0] );
54
},
55
},
56
made_parser_callback => sub {
57
1
1
25362
$session = $formatter->open_test( $_[1], $_[0] );
58
}
59
1
23
});
60
61
1
1266
$aggregator->start;
62
1
33
$aggregator->stop;
63
64
# This code also prints to STDOUT but we will catch it!
65
1
1
50
my $html = capture_merged { $formatter->summary($aggregator) };
1
1255
66
67
1
50
129336
unless ($JS_inside_HTML) {
68
1
44
return $html;
69
}
70
else {
71
0
0
my $js_script_tag = '';
74
75
0
0
$html =~ s/ //;
76
0
0
$html =~ s///;
77
0
0
$html =~ s//$js_script_tag/;
78
79
0
0
return $html;
80
}
81
82
83
}
84
85
1;
86
87
=pod
88
89
=head1 NAME
90
91
Convert::TAP::Archive - Read from a TAP archive and convert it for displaying
92
93
=head1 VERSION
94
95
version 0.004
96
97
=head1 SYNOPSIS
98
99
use Convert::TAP::Archive qw(convert_from_taparchive);
100
101
my $html = convert_from_taparchive(
102
'/must/be/the/complete/path/to/test.tar.gz',
103
'TAP::Formatter::HTML',
104
);
105
106
=encoding utf8
107
108
=head1 ABOUT
109
110
This modul can be of help for you if you have TAP archives (e.g. created with C and now you wish to have the content of this archives in a special format like HTML or JUnit (or whatever format).
111
112
=head1 EXPORTED METHODS
113
114
=head2 convert_from_taparchive
115
116
The method takes two arguments.
117
The first is required.
118
It is the B path to your TAP archive.
119
The second defaults to C, but you can give any other formatter.
120
The method will return the content of the TAP archive, parsed according to the formatter you have specified.
121
122
my $html = convert_from_taparchive(
123
'/must/be/the/complete/path/to/test.tar.gz',
124
'TAP::Formatter::HTML',
125
);
126
127
You can give any optional true value as a third argument and it will pack all Javascript inside the HTML instead of linking to to files from L.
128
129
=head1 BUGS AND LIMITATIONS
130
131
No known issues.
132
133
=head1 SEE ALSO
134
135
=over
136
137
=item *
138
139
L
140
141
=item *
142
143
L and its implementations for L, L or L.
144
145
=back
146
147
=head1 AUTHOR
148
149
Boris Däppen , Renée Bäcker
150
151
=head1 COPYRIGHT AND LICENSE
152
153
This software is copyright (c) 2013 by Boris Däppen, Renée Bäcker, plusW.
154
155
This is free software; you can redistribute it and/or modify it under
156
the same terms as the Perl 5 programming language system itself.
157
158
=cut
159
160
__DATA__