line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TAP::Formatter::EARL::Session; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
716
|
use 5.010001; |
|
3
|
|
|
|
|
10
|
|
4
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
54
|
|
5
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
118
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KJETILK'; |
8
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
14
|
use Moo; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
24
|
|
11
|
3
|
|
|
3
|
|
874
|
use Data::Dumper; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
142
|
|
12
|
|
|
|
|
|
|
|
13
|
3
|
|
|
3
|
|
1014
|
use Types::Standard qw(ConsumerOf); |
|
3
|
|
|
|
|
121999
|
|
|
3
|
|
|
|
|
41
|
|
14
|
3
|
|
|
3
|
|
2814
|
use Attean; |
|
3
|
|
|
|
|
3048649
|
|
|
3
|
|
|
|
|
20
|
|
15
|
3
|
|
|
3
|
|
106
|
use Attean::RDF; |
|
3
|
|
|
|
|
18
|
|
|
3
|
|
|
|
|
23
|
|
16
|
3
|
|
|
3
|
|
2386
|
use Types::Namespace qw( Namespace NamespaceMap ); |
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
26
|
|
17
|
3
|
|
|
3
|
|
2580
|
use Types::Attean qw(AtteanIRI to_AtteanIRI); |
|
3
|
|
|
|
|
9671
|
|
|
3
|
|
|
|
|
30
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has model => (is => 'ro', |
21
|
|
|
|
|
|
|
required => 1, |
22
|
|
|
|
|
|
|
isa => ConsumerOf['Attean::API::MutableModel']); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has software_uri => ( |
26
|
|
|
|
|
|
|
is => "ro", |
27
|
|
|
|
|
|
|
isa => AtteanIRI, |
28
|
|
|
|
|
|
|
required => 1 |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has ns => ( |
34
|
|
|
|
|
|
|
is => "ro", |
35
|
|
|
|
|
|
|
isa => NamespaceMap, |
36
|
|
|
|
|
|
|
required => 1, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has graph_name => ( |
40
|
|
|
|
|
|
|
is => "rw", |
41
|
|
|
|
|
|
|
isa => AtteanIRI, |
42
|
|
|
|
|
|
|
required => 1 |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
has result_prefix => (is => "ro", isa => Namespace, coerce => 1, required => 1 ); |
46
|
|
|
|
|
|
|
has assertion_prefix => (is => "ro", isa => Namespace, coerce => 1, required => 1 ); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub result { |
49
|
1
|
|
|
1
|
1
|
96910
|
my ($self, $result) = @_; |
50
|
1
|
|
|
|
|
23
|
my $giri = $self->graph_name; |
51
|
1
|
|
|
|
|
10
|
my $ns = $self->ns; |
52
|
1
|
50
|
|
|
|
6
|
if ($result->isa('TAP::Parser::Result::Test')) { |
53
|
1
|
|
|
|
|
6
|
my $tiri = to_AtteanIRI($self->result_prefix->iri('test_num_' . $result->number)); |
54
|
1
|
|
|
|
|
2214
|
my $airi = to_AtteanIRI($self->assertion_prefix->iri('test_num_' . $result->number)); |
55
|
1
|
|
|
|
|
635
|
$self->model->add_quad(quad($airi, to_AtteanIRI($ns->rdf->type), to_AtteanIRI($ns->earl->Assertion), $giri)); |
56
|
1
|
|
|
|
|
8380
|
$self->model->add_quad(quad($airi, to_AtteanIRI($ns->earl->assertedBy), $self->software_uri, $giri)); |
57
|
1
|
|
|
|
|
18902
|
$self->model->add_quad(quad($airi, to_AtteanIRI($ns->earl->result), $tiri, $giri)); |
58
|
|
|
|
|
|
|
# TODO: Subject and test properties are metadata given by test |
59
|
1
|
|
|
|
|
3119
|
$self->model->add_quad(quad($tiri, to_AtteanIRI($ns->rdf->type), to_AtteanIRI($ns->earl->TestResult), $giri)); |
60
|
1
|
50
|
|
|
|
3072
|
my $outcome = $result->is_ok ? $ns->earl->passed : $ns->earl->failed; |
61
|
1
|
50
|
|
|
|
187
|
if ($result->directive) { |
62
|
|
|
|
|
|
|
# Then, the test is either TODO or SKIP, they lack description |
63
|
0
|
|
|
|
|
0
|
$outcome = $ns->earl->untested; |
64
|
0
|
|
|
|
|
0
|
$self->model->add_quad(quad($tiri, to_AtteanIRI($ns->earl->info), langliteral($result->directive . ': ' . $result->explanation, 'en'), $giri)); |
65
|
|
|
|
|
|
|
} else { |
66
|
1
|
|
|
|
|
14
|
$self->model->add_quad(quad($tiri, to_AtteanIRI($ns->dc->title), langliteral($result->description, 'en'), $giri)); |
67
|
|
|
|
|
|
|
} |
68
|
1
|
|
|
|
|
6925
|
$self->model->add_quad(quad($tiri, to_AtteanIRI($ns->earl->outcome), to_AtteanIRI($outcome), $giri)); |
69
|
1
|
|
|
|
|
3031
|
return 1; |
70
|
|
|
|
|
|
|
} |
71
|
0
|
|
|
|
|
|
return 0; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub close_test { |
75
|
0
|
|
|
0
|
1
|
|
return; # No-op for now |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=pod |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=encoding utf-8 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 NAME |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
TAP::Formatter::EARL::Session - Session implementation for TAP Formatter to EARL |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 SYNOPSIS |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
use TAP::Formatter::EARL::Session; |
92
|
|
|
|
|
|
|
use Attean; |
93
|
|
|
|
|
|
|
use Attean::RDF; |
94
|
|
|
|
|
|
|
use URI::NamespaceMap; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
TAP::Formatter::EARL::Session->new( |
97
|
|
|
|
|
|
|
model => Attean->temporary_model, |
98
|
|
|
|
|
|
|
software_uri => iri('http://example.org/script'), |
99
|
|
|
|
|
|
|
ns => URI::NamespaceMap->new( [ 'rdf', 'dc', 'earl', 'doap' ] ), |
100
|
|
|
|
|
|
|
graph_name => iri('http://example.org/graph'), |
101
|
|
|
|
|
|
|
result_prefix => URI::Namespace->new('http://example.org/result#'), |
102
|
|
|
|
|
|
|
assertion_prefix => URI::Namespace->new('http://example.org/assertion#') |
103
|
|
|
|
|
|
|
); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 DESCRIPTION |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This defines a session for each individual part of the test |
108
|
|
|
|
|
|
|
result. You would probably not call this directly. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 Attributes |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
It has a number of attributes, they are all required. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=over |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item * C<< software_uri >> |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
An L<Attean::IRI> object that identifies the software itself. This URI |
120
|
|
|
|
|
|
|
will typically be minted by L<TAP::Formatter::EARL> and therefore |
121
|
|
|
|
|
|
|
passed as to this class as a IRI rather than just a prefix. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=back |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
The following attributes are passed from L<TAP::Formatter::EARL>, see the documentation there: |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=over |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item * C<< model >> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item * C<< ns >> |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item * C<< graph_name >> |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item * C<< assertion_prefix >> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item * C<< result_prefix >> |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=back |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Note that the attributes do not have defaults in this class, but the |
142
|
|
|
|
|
|
|
implementation of L<TAP::Formatter::EARL> will pass them on. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 Methods |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
The methods are implementations of methods required by the framework. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=over |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item * C<< result( $result ) >> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
A L<TAP::Parser::Result> object will be passed as argument to this |
154
|
|
|
|
|
|
|
method, and based on its contents, RDF will be added to the model as a |
155
|
|
|
|
|
|
|
side-effect. Will return true if any statements were added, 0 |
156
|
|
|
|
|
|
|
otherwise. Currently, only subclasses of L<TAP::Parser::Result::Test> |
157
|
|
|
|
|
|
|
will be formulated as RDF. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item * C<< close_test >> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
No-op for now. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=back |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 BUGS |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Please report any bugs to |
169
|
|
|
|
|
|
|
L<https://github.com/kjetilk/p5-tap-formatter-earl/issues>. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 SEE ALSO |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 AUTHOR |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Kjetil Kjernsmo E<lt>kjetilk@cpan.orgE<gt>. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
This software is copyright (c) 2019 by Inrupt Inc. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
This is free software, licensed under: |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
The MIT (X11) License |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
189
|
|
|
|
|
|
|
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
190
|
|
|
|
|
|
|
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
191
|
|
|
|
|
|
|
|