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   16369 use 5.012;
  2         11  
4 2     2   18 use strict;
  2         16  
  2         54  
5 2     2   15 use warnings;
  2         5  
  2         84  
6              
7 2     2   15 use parent 'TAP::Formatter::Console'; # TODO make the parent a parameter
  2         5  
  2         42  
8              
9 2     2   12811 use Best [ [qw(YAML::XS YAML)], qw(DumpFile) ];
  2         6  
  2         51  
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 6914570 my $self = shift;
43 6         33 my ($aggregate, $interrupted) = @_;
44 6         21 my %results;
45              
46 6         116 $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         6410 while( my ($fn, $parser) = each %{$aggregate->{parser_for}} ) {
  12         133  
52             # Save the results for this test file
53 6         24 $results{$fn} = {};
54             $results{$fn}->{$_} = _ary($parser->$_)
55 6         53 for qw(passed failed skipped actual_passed actual_failed todo todo_passed);
56             } #foreach result file
57              
58             # Save the output
59 6         158 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   292 return $_[0] if ref $_[0] eq 'ARRAY';
66 42         231 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: #