Hello, dear esteemed monks!

I have made a test script that makes cover -t include untested modules into the summary, thus lowering the overall coverage level and the developer's exaggerated ego.

Not even sure how I didn't come up with something like that earlier. So... Here it is:

dallaylaen/todo.t

UPDATE The script doesn't spawn more processes now and runs on Windows. No warnings issued.

#!/usr/bin/env perl # This script tests nothing (except the fact that modules load w/o war +nings). # However, it tries to load them all. # This means that untested modules would also be included into # code coverage summary, lowering total coverage to its actual value. # I.e. having a well-covered module and a totally uncovered one will r +esult # in 50% coverage which is probably closer to truth. use strict; use warnings; use Test::More; use FindBin qw($Bin); use File::Basename qw(dirname); use File::Find; # Try to load EVERY module in t/../lib my $path = dirname($Bin)."/lib"; my @files; find (sub { /\.pm$/ or return; -f $File::Find::name or return; $File::Find::name =~ s#^\Q$path\E[/\\]##; push @files, $File::Find::name; }, $path); # Save warnings for later my @warn; foreach my $file (@files) { # This sub suppresses warnings but saves them for later display local $SIG{__WARN__} = sub { push @warn, "$file: $_[0]"; }; ok ( eval{ require $file }, "$file loaded" ) or diag "Error in $file: $@"; }; # print report foreach (@warn) { diag "WARN: $_"; }; # If you are concerned about cover -t, then probably warnings during l +oad # are not OK with you is( scalar @warn, 0, "No warnings during load" ); done_testing;

Suggestions, improvements are welcome!


In reply to A unit-test script that causes remorse by Dallaylaen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.