scripts/dump-parsed-cpanm-build-logs

filter: Statementstmt 100% 37 / 37 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 97.9% 47 / 48 CC 1 SCAR 0.0
CC
1
Cov
98%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/CPAN/cpanminus/reporter/RetainReports.pm ↑ Summary
1 #!/usr/bin/env perl
2 4 eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
3 if 0; # not running under some shell
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Data::Dump qw( dd pp );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 =head1 NAME
12  
13 dump-parsed-cpanm-build-logs - pretty-print logs stored in JSON
14  
15 =head1 USAGE
16  
17 Multiple files:
18  
19 dump-parsed-cpanm-build-logs \
20 /path/to/tad/results/perl-5.27.6/analysis/01/CPANID.Some-Distro-0.008.log.json \
21 /path/to/tad/results/perl-5.27.6/analysis/01/OTHERCPANID.Some-Other-Distro-0.001.log.json
22  
23 or a single file on F<STDIN>:
24  
25 cat /path/to/tad/results/perl-5.27.6/analysis/01/CPANID.Some.Distro-.log.json | \
26 dump-parsed-cpanm-build-logs
27  
28 NOTE: This program's name is long. You may wish to create a shorter alias for it
29 provided that alias does not clash with any other program whose name indicates
30 it "dumps JSON."
31  
32 =head1 DESCRIPTION
33  
34 This is a helper program for use with Perl extension
35 L<CPAN-cpanminus-reporter-RetainReports|http://search.cpan.org/dist/CPAN-cpanminus-reporter-RetainReports/>.
36  
37 When you call that module's C<run()> method, a F<build.log> created by
38 F<cpanm> is parsed to create individual files on disk for each module which
39 received a grade such as C<PASS>, C<FAIL>, C<NA> or C<UNKNOWN>. Those files
40 are written in compact JSON for use as input into other programs. But compact
41 JSON is not very human-readable. Use this program to pretty-print the report
42 to F<STDOUT>.
43  
44 =head2 Sample Output
45  
46 Running the program on the two files in the F<examples/> directory in this distribution generates:
47  
48 {
49 author => "DAGOLDEN",
50 dist => "Sub-Uplevel",
51 distname => "Sub-Uplevel-0.2800",
52 distversion => "0.2800",
53 grade => "PASS",
54 prereqs => undef,
55 test_output => [
56 "Building and testing Sub-Uplevel-0.2800",
57 "cp lib/Sub/Uplevel.pm blib/lib/Sub/Uplevel.pm",
58 "PERL_DL_NONLAZY=1 \"/home/jkeenan/var/tad/testing/perl-5.27.6/bin/perl\" \"-MExtUtils::Command::MM\" \"-MTest::Harness\" \"-e\" \"undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')\" t/*.t",
59 "# ",
60 "# Versions for all modules listed in MYMETA.json (including optional ones):",
61 "# ",
62 "# === Configure Requires ===",
63 "# ",
64 "# Module Want Have",
65 "# ------------------- ---- ----",
66 "# ExtUtils::MakeMaker 6.17 7.30",
67 "# ",
68 "# === Build Requires ===",
69 "# ",
70 "# Module Want Have",
71 "# ------------------- ---- ----",
72 "# ExtUtils::MakeMaker any 7.30",
73 "# ",
74 "# === Test Requires ===",
75 "# ",
76 "# Module Want Have",
77 "# ------------------- ---- --------",
78 "# Exporter any 5.72",
79 "# ExtUtils::MakeMaker any 7.30",
80 "# File::Spec any 3.69",
81 "# Test::More any 1.302111",
82 "# lib any 0.64",
83 "# ",
84 "# === Test Recommends ===",
85 "# ",
86 "# Module Want Have",
87 "# ---------- -------- --------",
88 "# CPAN::Meta 2.120900 2.150010",
89 "# ",
90 "# === Runtime Requires ===",
91 "# ",
92 "# Module Want Have",
93 "# -------- ---- ----",
94 "# Carp any 1.44",
95 "# constant any 1.33",
96 "# strict any 1.11",
97 "# warnings any 1.38",
98 "# ",
99 "t/00-report-prereqs.t ........ ok",
100 "t/01_die_check.t ............. ok",
101 "t/02_uplevel.t ............... ok",
102 "t/03_nested_uplevels.t ....... ok",
103 "t/04_honor_later_override.t .. ok",
104 "t/05_honor_prior_override.t .. ok",
105 "t/06_db_args.t ............... ok",
106 "t/07_uplevel_too_high.t ...... ok",
107 "t/08_exporter.t .............. ok",
108 "t/09_emptylist.t ............. ok",
109 "All tests successful.",
110 "Files=10, Tests=158, 1 wallclock secs ( 0.06 usr 0.00 sys + 0.68 cusr 0.07 csys = 0.81 CPU)",
111 "Result: PASS",
112 ],
113 via => "App::cpanminus::reporter 0.17 (1.7043)",
114 }
115 {
116 author => "DAGOLDEN",
117 dist => "Test-API",
118 distname => "Test-API-0.008",
119 distversion => 0.008,
120 grade => "FAIL",
121 prereqs => undef,
122 test_output => [
123 "Building and testing Test-API-0.008",
124 "cp lib/Test/API.pm blib/lib/Test/API.pm",
125 "PERL_DL_NONLAZY=1 \"/home/jkeenan/var/tad/testing/perl-5.27.6/bin/perl\" \"-MExtUtils::Command::MM\" \"-MTest::Harness\" \"-e\" \"undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')\" t/*.t",
126 "# ",
127 "# Versions for all modules listed in MYMETA.json (including optional ones):",
128 "# ",
129 "# === Configure Requires ===",
130 "# ",
131 "# Module Want Have",
132 "# ------------------- ---- ----",
133 "# ExtUtils::MakeMaker 6.17 7.30",
134 "# ",
135 "# === Build Requires ===",
136 "# ",
137 "# Module Want Have",
138 "# ------------------- ---- ----",
139 "# ExtUtils::MakeMaker any 7.30",
140 "# ",
141 "# === Test Requires ===",
142 "# ",
143 "# Module Want Have",
144 "# --------------------- ---- --------",
145 "# Carp any 1.44",
146 "# Exporter any 5.72",
147 "# ExtUtils::MakeMaker any 7.30",
148 "# File::Spec any 3.69",
149 "# Test::Builder::Tester 1.18 1.302120",
150 "# Test::More any 1.302120",
151 "# lib any 0.64",
152 "# ",
153 "# === Test Recommends ===",
154 "# ",
155 "# Module Want Have",
156 "# ---------- -------- --------",
157 "# CPAN::Meta 2.120900 2.150010",
158 "# ",
159 "# === Runtime Requires ===",
160 "# ",
161 "# Module Want Have",
162 "# --------------------- ---- --------",
163 "# Symbol any 1.08",
164 "# Test::Builder::Module 0.86 1.302120",
165 "# strict any 1.11",
166 "# warnings any 1.38",
167 "# ",
168 "t/00-report-prereqs.t .. ok",
169 "Not a GLOB reference at /home/jkeenan/var/tad/testing/perl-5.27.6/.cpanm/work/1513444048.14516/Test-API-0.008/blib/lib/Test/API.pm line 176.",
170 "t/02-public.t .......... ",
171 "Dubious, test returned 255 (wstat 65280, 0xff00)",
172 "Failed 4/11 subtests ",
173 "Not a GLOB reference at /home/jkeenan/var/tad/testing/perl-5.27.6/.cpanm/work/1513444048.14516/Test-API-0.008/blib/lib/Test/API.pm line 176.",
174 "t/03-export.t .......... ",
175 "Dubious, test returned 255 (wstat 65280, 0xff00)",
176 "Failed 8/14 subtests ",
177 "Not a GLOB reference at /home/jkeenan/var/tad/testing/perl-5.27.6/.cpanm/work/1513444048.14516/Test-API-0.008/blib/lib/Test/API.pm line 176.",
178 "t/04-class-ok.t ........ ",
179 "Dubious, test returned 255 (wstat 65280, 0xff00)",
180 "Failed 3/5 subtests ",
181 "",
182 "Test Summary Report",
183 "-------------------",
184 "t/02-public.t (Wstat: 65280 Tests: 7 Failed: 0)",
185 " Non-zero exit status: 255",
186 " Parse errors: Bad plan. You planned 11 tests but ran 7.",
187 "t/03-export.t (Wstat: 65280 Tests: 6 Failed: 0)",
188 " Non-zero exit status: 255",
189 " Parse errors: Bad plan. You planned 14 tests but ran 6.",
190 "t/04-class-ok.t (Wstat: 65280 Tests: 2 Failed: 0)",
191 " Non-zero exit status: 255",
192 " Parse errors: Bad plan. You planned 5 tests but ran 2.",
193 "Files=4, Tests=16, 1 wallclock secs ( 0.03 usr 0.00 sys + 0.36 cusr 0.03 csys = 0.42 CPU)",
194 "Result: FAIL",
195 ],
196 via => "App::cpanminus::reporter 0.17 (1.7043)",
197 }
198  
199 =head1 PREREQUISITES
200  
201 CPAN::cpanminus::reporter::RetainReports and its prerequisites. Data::Dump.
202  
203 =head1 AUTHOR
204  
205 James E Keenan
206 CPAN Id: JKEENAN
207 jkeenan [at] cpan [dot] org
208  
209 =head1 COPYRIGHT
210  
211 Copyright (c) 2017 James E Keenan. All rights reserved.
212 This program is free software; you can redistribute
213 it and/or modify it under the same terms as Perl itself.
214  
215 =head1 SEE ALSO
216  
217 perl(1). CPAN::cpanminus::reporter::RetainReports(3). JSON(3).
218  
219 =cut
220  
221 4 my $decoded;
222 4 ▶if (@ARGV) {
Branch: 1 branch
BranchTrueFalseTotal
if (@ARGV) { } 3 1 4
223 3 for my $lfile (@ARGV) {
224 4 ▶ croak "Cannot locate $lfile" unless (-f $lfile);
Branch: 1 branch
BranchTrueFalseTotal
unless -f $lfile 0 4 4
225 4 my $f = Path::Tiny::path($lfile);
226 4 $decoded = decode_json($f->slurp_utf8);
227 4 display_text($decoded);
228 }
229 }
230 else {
231 1 $decoded = decode_json(<STDIN>);
232 1 display_text($decoded);
233 }
234 4 exit 0;
235  
236 5 ▶sub display_text {
Subroutine display_text: called CC=1 SCAR=0.0
237 5 my $decoded = shift;
238 5 my $reworked = { map { $_ => $decoded->{$_} } sort grep { $_ ne 'test_output' } keys %{$decoded} };
239 5 $reworked->{test_output} = [ split(/\n/, $decoded->{test_output}) ];
240 5 dd($reworked);
241 5 return 1;
242 }
« blib/lib/CPAN/cpanminus/reporter/RetainReports.pm ↑ Summary