File Coverage

blib/lib/App/Prove/Plugin/Test/OnlySomeP/Formatter.pm
Criterion Covered Total %
statement 25 25 100.0
branch 1 2 50.0
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 34 35 97.1


line stmt bran cond sub pod time code
1             #!perl
2             package App::Prove::Plugin::Test::OnlySomeP::Formatter;
3 2     2   13069 use 5.012;
  2         8  
4 2     2   16 use strict;
  2         7  
  2         62  
5 2     2   14 use warnings;
  2         10  
  2         68  
6              
7 2     2   11 use parent 'TAP::Formatter::Console'; # TODO make the parent a parameter
  2         3  
  2         33  
8              
9 2     2   10421 use Best [ [qw(YAML::XS YAML)], qw(DumpFile) ];
  2         5  
  2         43  
10              
11             #use Data::Dumper;
12              
13             our $VERSION = '0.001003';
14              
15             # Docs {{{2
16              
17             =head1 NAME
18              
19             App::Prove::Plugin::Test::OnlySomeP::Formatter - formatter supporting Test::OnlySome
20              
21             =head1 INSTALLATION
22              
23             See L, with which this module is distributed.
24              
25             =head1 EXPORTS
26              
27             =head2 summary
28              
29             Called after the tests run. Outputs the test results to a YAML file.
30              
31             =cut
32              
33             # }}}2
34              
35             #sub _initialize { # DEBUG
36             # my $self = shift;
37             # print STDERR "Formatter got args: ", Dumper([@_]), "\n";
38             # return $self->SUPER::_initialize(@_);
39             #} #_initialize()
40              
41             sub summary {
42 6     6 1 5992813 my $self = shift;
43 6         24 my ($aggregate, $interrupted) = @_;
44 6         22 my %results;
45              
46 6         85 $self->SUPER::summary(@_);
47              
48             # Collect the results. Can't use $parser->next, since App::Prove has
49             # already iterated over the results.
50              
51 6         5228 while( my ($fn, $parser) = each %{$aggregate->{parser_for}} ) {
  12         108  
52             # Save the results for this test file
53 6         24 $results{$fn} = {};
54             $results{$fn}->{$_} = _ary($parser->$_)
55 6         41 for qw(passed failed skipped actual_passed actual_failed todo todo_passed);
56             } #foreach result file
57              
58             # Save the output
59 6         114 DumpFile $App::Prove::Plugin::Test::OnlySomeP::Filename, \%results;
60             # The plugin guarantees this exists.
61             } #summary()
62              
63             # Wrap the arg(s) in an arrayref unless the first arg already is one.
64             sub _ary {
65 42 50   42   256 return $_[0] if ref $_[0] eq 'ARRAY';
66 42         189 return [@_];
67             }
68              
69             # More docs {{{2
70             =head1 AUTHOR
71              
72             Christopher White, C<< >>
73              
74             =head1 BUGS
75              
76             Please report any bugs or feature requests on GitHub, at
77             L.
78              
79             =head1 SUPPORT
80              
81             You can find documentation for this module with the perldoc command.
82              
83             perldoc Test::OnlySome
84              
85             You can also look for information at:
86              
87             =over 4
88              
89             =item * The GitHub repository
90              
91             L
92              
93             =item * AnnoCPAN: Annotated CPAN documentation
94              
95             L
96              
97             =item * CPAN Ratings
98              
99             L
100              
101             =item * Search CPAN
102              
103             L
104              
105             =item * RT: CPAN's request tracker
106              
107             L
108              
109             =back
110              
111             =cut
112              
113             # }}}2
114             # License {{{2
115              
116             =head1 ACKNOWLEDGEMENTS
117              
118             Thanks to sugyan for L, which provided inspiration.
119              
120             =head1 LICENSE AND COPYRIGHT
121              
122             Copyright 2018 Christopher White.
123              
124             This program is distributed under the MIT (X11) License:
125             L
126              
127             Permission is hereby granted, free of charge, to any person
128             obtaining a copy of this software and associated documentation
129             files (the "Software"), to deal in the Software without
130             restriction, including without limitation the rights to use,
131             copy, modify, merge, publish, distribute, sublicense, and/or sell
132             copies of the Software, and to permit persons to whom the
133             Software is furnished to do so, subject to the following
134             conditions:
135              
136             The above copyright notice and this permission notice shall be
137             included in all copies or substantial portions of the Software.
138              
139             THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
140             EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
141             OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
142             NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
143             HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
144             WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
145             FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
146             OTHER DEALINGS IN THE SOFTWARE.
147              
148             =cut
149              
150             # }}}2
151             1;
152             # vi: set fdm=marker fdl=1 fo-=ro: #