I am "require"ing a file but Devel::Cover is not logging the statements, only the sub, use, and eval portions.
I tried a do(filename.pl) to no help. I tried adding -subs_only off (and on) to no effect. Any suggestions? (source can be found at https://sourceforge.net/u/jpyeron/logwatch/ci/master/tree/) -JasonTitle: File Coverage: scripts/logwatch.pl
File Coverage
File: | scripts/logwatch.pl |
Coverage: | 48.1% |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | #!/usr/bin/perl -w | ||||||
2 | 25 25 25 | 0 0 4000 | use strict; | ||||
3 | ########################################################################## | ||||||
4 | ########################################################################## | ||||||
5 | # Most current version can always be found at: | ||||||
6 | # ftp://ftp.logwatch.org/pub/linux (tarball) | ||||||
7 | # ftp://ftp.logwatch.org/pub/redhat/RPMS (RPMs) | ||||||
8 | |||||||
9 | ######################################################## | ||||||
10 | # Specify version and build-date: | ||||||
11 | my $Version = '7.4.3'; | ||||||
12 | my $VDate = '04/27/16'; | ||||||
13 | |||||||
14 | ####################################################### | ||||||
15 | # Logwatch was written and is maintained by: | ||||||
16 | # Kirk Bauer <k...@kaybee.org> | ||||||
17 | # | ||||||
18 | # Unless otherwise specified, Logwatch and all bundled filter scripts | ||||||
19 | # are Copyright (c) Kirk Bauer and covered under the included MIT/X | ||||||
20 | # Consortium license. | ||||||
21 | # | ||||||
22 | # Please send all comments, suggestions, bug reports, | ||||||
23 | # etc, to logwa...@logwatch.org. | ||||||
24 | # | ||||||
25 | ######################################################## | ||||||
26 | |||||||
27 | ############################################################################ | ||||||
28 | # ENV SETTINGS: | ||||||
29 | # About the locale: some functions use locale information. In particular, | ||||||
30 | # Logwatch makes use of strftime, which makes use of LC_TIME variable. Other | ||||||
31 | # functions may also use locale information. | ||||||
32 | # | ||||||
33 | # Because the parsing must be in the same locale as the logged information, | ||||||
34 | # and this appears to be "C", "POSIX", or "en_US", we set LC_ALL for | ||||||
35 | # this and other scripts invoked by this script. We use "C" because it | ||||||
36 | # is always (?) available, whereas POSIX or en_US may not. They all use | ||||||
37 | # the same time formats and rely on the ASCII character set. | ||||||
38 | # | ||||||
39 | # Variables REAL_LANG and REAL_LC_ALL keep the original values for use by | ||||||
40 | # scripts that need native language. | ||||||
41 | $ENV{'REAL_LANG'}=$ENV{'LANG'} if $ENV{'LANG'}; | ||||||
42 | $ENV{'REAL_LC_ALL'}=$ENV{'LC_ALL'} if $ENV{'LC_ALL'}; | ||||||
43 | |||||||
44 | # Setting ENV for scripts invoked by this script. | ||||||
45 | $ENV{'LC_ALL'} = "C"; | ||||||
46 | # Using setlocale to set locale for this script. | ||||||
47 | 25 25 25 | 44003 212011 0 | use POSIX qw(locale_h); | ||||
48 | setlocale(LC_ALL, "C"); | ||||||
49 | |||||||
50 | my $BaseDir = "/usr/share/logwatch"; | ||||||
51 | my $ConfigDir = "/etc/logwatch"; | ||||||
52 | my $PerlVersion = "$^X"; | ||||||
53 | |||||||
54 | ############################################################################# | ||||||
55 | |||||||
56 | ############################################################################# | ||||||
57 | # SET LIBS, GLOBALS, and DEFAULTS | ||||||
58 | 25 25 25 | 87002 255014 1000 | use Getopt::Long; | ||||
59 | 25 25 25 | 2000 0 0 | use POSIX qw(uname); | ||||
60 | 25 25 25 | 57003 284021 339017 | use File::Temp qw/ tempdir /; | ||||
61 | |||||||
62 | my (%Config, @ServiceList, @LogFileList, %ServiceData, %LogFileData); | ||||||
63 | my (@AllShared, @AllLogFiles, @FileList); | ||||||
64 | # These need to not be global variables one day | ||||||
65 | my (@ReadConfigNames, @ReadConfigValues); | ||||||
66 | |||||||
67 | my @argvClone = @ARGV; | ||||||
68 | my $gop = Getopt::Long::Parser->new; | ||||||
69 | $gop->configure("pass_through"); | ||||||
70 | $gop->getoptionsfromarray(\@argvClone, | ||||||
71 | "confdir=s" => \$ConfigDir, | ||||||
72 | "basedir=s" => \$BaseDir, | ||||||
73 | "debug=s" => \$Config{'debug'}, | ||||||
74 | ); | ||||||
75 | |||||||
76 | 25 25 25 | 42002 16002 1000 | eval "use lib \"$BaseDir/lib\";"; | ||||
77 | 25 25 25 | 144006 0 4000 | eval "use Logwatch \':dates\'"; | ||||
78 | |||||||
79 | # Default config here... | ||||||
80 | $Config{'detail'} = 0; | ||||||
81 | # if MAILTO is set in the environment, grab it, as it may be used by cron | ||||||
82 | # or anacron | ||||||
83 | if ($ENV{'MAILTO'}) { | ||||||
84 | $Config{'mailto'} = $ENV{'MAILTO'}; | ||||||
85 | } else { | ||||||
86 | $Config{'mailto'} = "root"; | ||||||
87 | } | ||||||
88 | $Config{'mailfrom'} = "Logwatch"; | ||||||
89 | $Config{'subject'} = ""; | ||||||
Snipped to make file smaller | |||||||
1527 | sub output { | ||||||
1528 | 1798 | 1000 | my ($index, $text, $type) = @_; | ||||
1529 | #Types are start stop header line ref | ||||||
1530 | |||||||
1531 | 1798 | 2000 | if ( $type eq "ref_extra" ) { | ||||
1532 | 0 | 0 | $out_reference .= "$text\n"; | ||||
1533 | } | ||||||
1534 | |||||||
1535 | 1798 | 2000 | if ( $type eq "ref" ) { | ||||
1536 | 0 | 0 | $out_reference .= " <li><a href=""> | ||||
1537 | } | ||||||
1538 | |||||||
1539 | 1798 | 1000 | if ( $type eq "start" ) { | ||||
1540 | 71 | 1000 | $reports[$index] = "$text"; | ||||
1541 | #SERVICE table headers if ( $index eq 'E' ) { #never happens change out_body from hash back to array | ||||||
1542 | 71 | 2000 | if ( $Config{'format'} eq "html" ) { | ||||
1543 | 0 | 0 | $out_body{$index} .= | ||||
1544 | "<div class=service> | ||||||
1545 | <table border=1 width=100%> | ||||||
1546 | <tr><th> | ||||||
1547 | <h2><a name=\"$index\">$reports[$index]</a></h2> | ||||||
1548 | </tr></th>\n"; | ||||||
1549 | } | ||||||
1550 | } | ||||||
1551 | |||||||
1552 | 1798 | 1000 | if ( $type eq "stop" ) { | ||||
1553 | 71 | 0 | if ( $Config{'format'} eq "html" ) { | ||||
1554 | 0 | 0 | $out_body{$index} .= " </table></div>\n"; | ||||
1555 | 0 | 0 | $out_body{$index} .= " <div class=return_link><p><a href="" to Top</a></p></div>\n"; | ||||
1556 | } | ||||||
1557 | } | ||||||
1558 | |||||||
1559 | 1798 | 3000 | if ( $type eq "header" ) { | ||||
1560 | 0 | 0 | if ( $Config{'format'} eq "text" ) { | ||||
1561 | 0 | 0 | $out_body{$index} .= "$text \n"; | ||||
1562 | } elsif ( $Config{'format'} eq "html" ) { | ||||||
1563 | #Covert spaces | ||||||
1564 | 0 | 0 | $text =~ s/ / \ /go; | ||||
1565 | #Covert tabs 1 to 4 ratio | ||||||
1566 | 0 | 0 | $text =~ s/\t/ \ \;\ \;\ \;\ \;/go; | ||||
1567 | #Filters | ||||||
1568 | 0 | 0 | $text =~ s/ $//go; | ||||
1569 | 0 | 0 | $text = ' ' if ( $text eq '' ); | ||||
1570 | #This will make sure no unbroken string is longer then x characters | ||||||
1571 | 0 | 0 | $text =~ s/(\S{$Config{html_wrap}})/$1 /g; | ||||
1572 | 0 | 0 | $out_body{$index} .= "<tr>\n <th>$text</th>\n </tr>\n"; | ||||
1573 | } else { #fixme what is this formatted? | ||||||
1574 | 0 | 0 | $out_body{$index} .= | ||||
1575 | sprintf( substr( $text, 0, $format[0] ) . ' ' x( $format[0] - length($text) ) . " \n" ); | ||||||
1576 | } | ||||||
1577 | } | ||||||
1578 | |||||||
1579 | 1798 | 4001 | if ( $type eq "line" ) { | ||||
1580 | 1656 | 3000 | if ( $Config{'format'} eq "text" ) { | ||||
1581 | 1656 | 13609779 | $out_body{$index} .= " $text"; | ||||
1582 | } elsif ( $Config{'format'} eq "html" ) { | ||||||
1583 | #Covert spaces | ||||||
1584 | 0 | $text =~ s/ / \ /go; | |||||
1585 | #Covert tabs 1 to 4 ratio | ||||||
1586 | 0 | $text =~ s/\t/ \ \;\ \;\ \;\ \;/go; | |||||
1587 | #Filters | ||||||
1588 | 0 | $text =~ s/ $//go; | |||||
1589 | 0 | $text =~ s/</\<\;/go; | |||||
1590 | 0 | $text =~ s/>/\>\;/go; | |||||
1591 | #This will make sure no unbroken string is longer then x characters | ||||||
1592 | 0 | $text =~ s/(\S{$Config{html_wrap}})/$1 /g; | |||||
1593 | #Grey background for spaced output | ||||||
1594 | 0 | if ( $text =~ m/^ / ) { | |||||
1595 | 0 | $out_body{$index} .= " <tr>\n <td bgcolor=#dddddd>$text</td>\n </tr>\n"; | |||||
1596 | } else { | ||||||
1597 | 0 | $out_body{$index} .= " <tr>\n <th align=left>$text</th>\n </tr>\n"; | |||||
1598 | } | ||||||
1599 | } else { #fixme formatted? | ||||||
1600 | 0 | if ( length($text) > $format[0] ) { | |||||
1601 | 0 | $out_body{$index} .= | |||||
1602 | sprintf( $text . "\n" . ' ' x $format[0] . ' ' ); | ||||||
1603 | } else { | ||||||
1604 | 0 | $out_body{$index} .= | |||||
1605 | sprintf( $text . ' ' x ( $format[0] - length($text) ) . ' ' ); | ||||||
1606 | } | ||||||
1607 | } | ||||||
1608 | } | ||||||
1609 | } | ||||||
1610 | ########################################################################### | ||||||
1611 | #END sub output | ||||||
1612 | ########################################################################### | ||||||
1613 | # vi: shiftwidth=3 tabstop=3 et | ||||||
1614 | # Local Variables: | ||||||
1615 | # mode: perl | ||||||
1616 | # perl-indent-level: 3 | ||||||
1617 | # indent-tabs-mode: nil | ||||||
1618 | # End: |
File Coverage
File: | tests/script/test.pl |
Coverage: | 100.0% |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | #!/usr/bin/perl | ||||||
2 | |||||||
3 | use Devel::Cover qw(-silent 1); | ||||||
4 | |||||||
5 | *CORE::GLOBAL::umask=sub | ||||||
6 | { | ||||||
7 | 1 | 0 | return 1; | ||||
8 | 1 | 84004 | }; | ||||
9 | |||||||
10 | 1 | 0 | $^X="$^X -MDevel::Cover=-silent,1"; | ||||
11 | |||||||
12 | 1 | 1000 | require "./scripts/logwatch.pl"; |