Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / App / Prove / State / Result / Test.pm
CommitLineData
3fea05b9 1package App::Prove::State::Result::Test;
2
3use strict;
4
5use vars qw($VERSION);
6
7=head1 NAME
8
9App::Prove::State::Result::Test - Individual test results.
10
11=head1 VERSION
12
13Version 3.17
14
15=cut
16
17$VERSION = '3.17';
18
19=head1 DESCRIPTION
20
21The C<prove> command supports a C<--state> option that instructs it to
22store persistent state across runs. This module encapsulates the results for a
23single test.
24
25=head1 SYNOPSIS
26
27 # Re-run failed tests
28 $ prove --state=fail,save -rbv
29
30=cut
31
32my %methods = (
33 name => { method => 'name' },
34 elapsed => { method => 'elapsed', default => 0 },
35 gen => { method => 'generation', default => 1 },
36 last_pass_time => { method => 'last_pass_time', default => undef },
37 last_fail_time => { method => 'last_fail_time', default => undef },
38 last_result => { method => 'result', default => 0 },
39 last_run_time => { method => 'run_time', default => undef },
40 last_todo => { method => 'num_todo', default => 0 },
41 mtime => { method => 'mtime', default => undef },
42 seq => { method => 'sequence', default => 1 },
43 total_passes => { method => 'total_passes', default => 0 },
44 total_failures => { method => 'total_failures', default => 0 },
45 parser => { method => 'parser' },
46);
47
48while ( my ( $key, $description ) = each %methods ) {
49 my $default = $description->{default};
50 no strict 'refs';
51 *{ $description->{method} } = sub {
52 my $self = shift;
53 if (@_) {
54 $self->{$key} = shift;
55 return $self;
56 }
57 return $self->{$key} || $default;
58 };
59}
60
61=head1 METHODS
62
63=head2 Class Methods
64
65=head3 C<new>
66
67=cut
68
69sub new {
70 my ( $class, $arg_for ) = @_;
71 $arg_for ||= {};
72 bless $arg_for => $class;
73}
74
75=head2 Instance Methods
76
77=head3 C<name>
78
79The name of the test. Usually a filename.
80
81=head3 C<elapsed>
82
83The total elapsed times the test took to run, in seconds from the epoch..
84
85=head3 C<generation>
86
87The number for the "generation" of the test run. The first generation is 1
88(one) and subsequent generations are 2, 3, etc.
89
90=head3 C<last_pass_time>
91
92The last time the test program passed, in seconds from the epoch.
93
94Returns C<undef> if the program has never passed.
95
96=head3 C<last_fail_time>
97
98The last time the test suite failed, in seconds from the epoch.
99
100Returns C<undef> if the program has never failed.
101
102=head3 C<mtime>
103
104Returns the mtime of the test, in seconds from the epoch.
105
106=head3 C<raw>
107
108Returns a hashref of raw test data, suitable for serialization by YAML.
109
110=head3 C<result>
111
112Currently, whether or not the test suite passed with no 'problems' (such as
113TODO passed).
114
115=head3 C<run_time>
116
117The total time it took for the test to run, in seconds. If C<Time::HiRes> is
118available, it will have finer granularity.
119
120=head3 C<num_todo>
121
122The number of tests with TODO directives.
123
124=head3 C<sequence>
125
126The order in which this test was run for the given test suite result.
127
128=head3 C<total_passes>
129
130The number of times the test has passed.
131
132=head3 C<total_failures>
133
134The number of times the test has failed.
135
136=head3 C<parser>
137
138The underlying parser object. This is useful if you need the full
139information for the test program.
140
141=cut
142
143sub raw {
144 my $self = shift;
145 my %raw = %$self;
146
147 # this is backwards-compatibility hack and is not guaranteed.
148 delete $raw{name};
149 delete $raw{parser};
150 return \%raw;
151}
152
1531;