Skip to content

Commit

Permalink
import Devel::Cover 0.46
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcj committed Nov 3, 2004
1 parent b768db3 commit 4116963
Show file tree
Hide file tree
Showing 44 changed files with 439 additions and 225 deletions.
8 changes: 8 additions & 0 deletions CHANGES
Expand Up @@ -304,3 +304,11 @@ Release 0.45 - 27th May 2004
- Allow Devel::Cover to be used under mod_perl (Philippe M. Chiasson). - Allow Devel::Cover to be used under mod_perl (Philippe M. Chiasson).
- Handle $x ||= 1 and friends nicely, including subs and *foo{THING}. - Handle $x ||= 1 and friends nicely, including subs and *foo{THING}.
- Allow uncoverable code to be specified. (Unfinished) - Allow uncoverable code to be specified. (Unfinished)

Release 0.46 - 23rd June 2004
- Don't lose data merging DBs.
- Work with Safe.pm, by not covering it.
- Swap Profiling_op for Profiling_key to avoid accessing freed memory.
- Rename -file and -exclude options in cover to -select and -ignore.
- Fully cover conditions and branches when the condition calls a sub in
an ignored file.
39 changes: 23 additions & 16 deletions Cover.xs
Expand Up @@ -27,7 +27,7 @@ extern "C" {
#endif #endif


#define PDEB(a) a #define PDEB(a) a
#define NDEB(a) #define NDEB(a) ;
#define D PerlIO_printf #define D PerlIO_printf
#define L Perl_debug_log #define L Perl_debug_log
#define svdump(sv) do_sv_dump(0, L, (SV *)sv, 0, 10, 1, 0); #define svdump(sv) do_sv_dump(0, L, (SV *)sv, 0, 10, 1, 0);
Expand Down Expand Up @@ -56,8 +56,6 @@ static HV *Cover,


static AV *Ends; static AV *Ends;


static OP *Profiling_op = 0;

struct unique /* Well, we'll be fairly unlucky if it's not */ struct unique /* Well, we'll be fairly unlucky if it's not */
{ {
OP *addr; OP *addr;
Expand All @@ -72,6 +70,8 @@ union sequence /* Hack, hack, hackety hack. */
char ch[CH_SZ + 1]; char ch[CH_SZ + 1];
}; };


static char Profiling_key[CH_SZ + 1];

#ifdef HAS_GETTIMEOFDAY #ifdef HAS_GETTIMEOFDAY


#ifdef __cplusplus #ifdef __cplusplus
Expand Down Expand Up @@ -163,7 +163,8 @@ static char *get_key(OP *o)
*/ */


for (i = 0; i < CH_SZ; i++) for (i = 0; i < CH_SZ; i++)
/* if (uniq.ch[i] < 32 || uniq.ch[i] > 126 ) */ /* for printing */ /* for printing */
/* if (uniq.ch[i] < 32 || uniq.ch[i] > 126 ) */
if (!uniq.ch[i]) if (!uniq.ch[i])
uniq.ch[i] = '-'; uniq.ch[i] = '-';


Expand Down Expand Up @@ -474,31 +475,32 @@ static void cover_time()
{ {
SV **count; SV **count;
NV c; NV c;
char *ch;


if (collecting(Time)) if (collecting(Time))
{ {
/* /*
* Profiling information is stored against Profiling_op, the one * Profiling information is stored against Profiling_key, the
* we have just run. * key for the op we have just run.
*/ */


NDEB(D(L, "Cop at %p, op at %p, timing %p\n", PL_curcop, PL_op, Profiling_op)); NDEB(D(L, "Cop at %p, op at %p\n", PL_curcop, PL_op));


if (Profiling_op) if (*Profiling_key)
{ {
ch = get_key(Profiling_op); count = hv_fetch(Times, Profiling_key, CH_SZ, 1);
count = hv_fetch(Times, ch, CH_SZ, 1);
c = (SvTRUE(*count) ? SvNV(*count) : 0) + c = (SvTRUE(*count) ? SvNV(*count) : 0) +
#if defined HAS_GETTIMEOFDAY #if defined HAS_GETTIMEOFDAY
elapsed(); elapsed();
#else #else
cpu(); cpu();
#endif #endif
sv_setnv(*count, c); sv_setnv(*count, c);
NDEB(D(L, "Adding time: sum %f at %p\n", c, Profiling_op)); NDEB(D(L, "Adding time: sum %f to <%s>\n", c, Profiling_key));
} }
Profiling_op = PL_op; if (PL_op)
strcpy(Profiling_key, get_key(PL_op));
else
*Profiling_key = 0;
} }
} }


Expand Down Expand Up @@ -548,6 +550,7 @@ static int runops_cover(pTHX)
*tmp = newRV_inc((SV*) Modules); *tmp = newRV_inc((SV*) Modules);


Pending_conditionals = newHV(); Pending_conditionals = newHV();
*Profiling_key = 0;
} }


if (!module) if (!module)
Expand Down Expand Up @@ -583,7 +586,8 @@ static int runops_cover(pTHX)
{ {
SV **f = hv_fetch(Files, file, strlen(file), 0); SV **f = hv_fetch(Files, file, strlen(file), 0);
collecting_here = f ? SvIV(*f) : 1; collecting_here = f ? SvIV(*f) : 1;
NDEB(D(L, "File: %s [%d]\n", file, collecting_here)); NDEB(D(L, "File: %s:%ld [%d]\n",
file, CopLINE(cCOP), collecting_here));
} }
lastfile = file; lastfile = file;
} }
Expand Down Expand Up @@ -620,8 +624,12 @@ static int runops_cover(pTHX)
{ {
#if CAN_PROFILE #if CAN_PROFILE
cover_time(); cover_time();
Profiling_op = 0; *Profiling_key = 0;
#endif #endif
if (PL_op->op_type == OP_LEAVESUB)
collecting_here = 1;
/* Match OP_LEAVESUBLV, OP_LEAVE or others? */

goto call_fptr; goto call_fptr;
} }


Expand Down Expand Up @@ -683,7 +691,6 @@ static int runops_cover(pTHX)
{ {
#if CAN_PROFILE #if CAN_PROFILE
cover_time(); cover_time();
Profiling_op = 0;
#endif #endif
break; break;
} }
Expand Down
4 changes: 3 additions & 1 deletion MANIFEST
Expand Up @@ -101,7 +101,6 @@ test_output/cover/dynamic_subs.5.008001
test_output/cover/eval1.5.006001 test_output/cover/eval1.5.006001
test_output/cover/eval1.5.008 test_output/cover/eval1.5.008
test_output/cover/fork.5.006001 test_output/cover/fork.5.006001
test_output/cover/fork.5.008
test_output/cover/if.5.006001 test_output/cover/if.5.006001
test_output/cover/if.5.008 test_output/cover/if.5.008
test_output/cover/module1.5.006001 test_output/cover/module1.5.006001
Expand All @@ -110,6 +109,9 @@ test_output/cover/module1.5.008001
test_output/cover/module2.5.006001 test_output/cover/module2.5.006001
test_output/cover/module2.5.008 test_output/cover/module2.5.008
test_output/cover/module2.5.008001 test_output/cover/module2.5.008001
test_output/cover/module_ignore.5.006001
test_output/cover/module_ignore.5.008
test_output/cover/module_ignore.5.008001
test_output/cover/module_import.5.006001 test_output/cover/module_import.5.006001
test_output/cover/module_import.5.008 test_output/cover/module_import.5.008
test_output/cover/module_import.5.008001 test_output/cover/module_import.5.008001
Expand Down
2 changes: 1 addition & 1 deletion META.yml
@@ -1,7 +1,7 @@
# http://module-build.sourceforge.net/META-spec.html # http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Devel-Cover name: Devel-Cover
version: 0.45 version: 0.46
version_from: version_from:
installdirs: site installdirs: site
requires: requires:
Expand Down
4 changes: 2 additions & 2 deletions Makefile.PL
Expand Up @@ -19,8 +19,8 @@ use File::Copy;


$| = 1; $| = 1;


my $Version = "0.45"; my $Version = "0.46";
my $Date = "27th May 2004"; my $Date = "23rd June 2004";
my $Author = 'pjcj@cpan.org'; my $Author = 'pjcj@cpan.org';


my @perlbug = ("perlbug", "-a", $Author, my @perlbug = ("perlbug", "-a", $Author,
Expand Down
5 changes: 3 additions & 2 deletions README
Expand Up @@ -50,8 +50,9 @@ DESCRIPTION
REQUIREMENTS REQUIREMENTS
* Perl 5.6.1 or greater * Perl 5.6.1 or greater
Perl 5.7.0 is unsupported. Perl 5.8.1 or greater is recommended. Perl 5.7.0 is unsupported. Perl 5.8.1 or greater is recommended.
Whilst Perl 5.6 should work you will probably miss out on coverage Whilst Perl 5.6 should mostly work you will probably miss out on
information which would be available using a more modern version. coverage information which would be available using a more modern
version and will likely run into bugs in perl.


* The ability to compile XS extensions. * The ability to compile XS extensions.
This means a working compiler and make program at least. This means a working compiler and make program at least.
Expand Down
3 changes: 2 additions & 1 deletion TODO
Expand Up @@ -28,4 +28,5 @@
- Overhaul test system. Include patt? - Overhaul test system. Include patt?
- Tests for INIT and END blocks included in required files when the - Tests for INIT and END blocks included in required files when the
files are used in some runs. files are used in some runs.
- Make all environment variables consistent and document them. - Sort out "ignoring extra subroutine" and friends.
- Fix up make text and friends for module_ignore.
32 changes: 16 additions & 16 deletions cover
Expand Up @@ -12,9 +12,9 @@ require 5.6.1;
use strict; use strict;
use warnings; use warnings;


our $VERSION = "0.45"; our $VERSION = "0.46";


use Devel::Cover::DB 0.45; use Devel::Cover::DB 0.46;


use Cwd "abs_path"; use Cwd "abs_path";
use Data::Dumper; use Data::Dumper;
Expand All @@ -26,8 +26,8 @@ my $Options =
{ {
coverage => [], coverage => [],
delete => 0, delete => 0,
exclude => [], ignore => [],
file => [], select => [],
report => "", report => "",
summary => 1, summary => 1,
uncoverable => [], uncoverable => [],
Expand All @@ -47,9 +47,9 @@ sub get_options
coverage=s coverage=s
delete! delete!
dump_db! dump_db!
exclude=s ignore=s
help|h! help|h!
file=s select=s
info|i! info|i!
outputdir=s outputdir=s
report=s report=s
Expand Down Expand Up @@ -167,10 +167,10 @@ sub main


# use Data::Dumper; $Data::Dumper::Indent = 1; print Dumper $db->cover; # use Data::Dumper; $Data::Dumper::Indent = 1; print Dumper $db->cover;


my %f = map { $_ => 1 } (@{$Options->{file}} my %f = map { $_ => 1 } (@{$Options->{select}}
? map glob, @{$Options->{file}} ? map glob, @{$Options->{select}}
: $db->cover->items); : $db->cover->items);
delete @f{map glob, @{$Options->{exclude}}}; delete @f{map glob, @{$Options->{ignore}}};
@{$Options->{file}} = sort grep exists $db->{summary}{$_}, keys %f; @{$Options->{file}} = sort grep exists $db->{summary}{$_}, keys %f;


$format->report($db, $Options) $format->report($db, $Options)
Expand All @@ -188,7 +188,7 @@ cover - report coverage statistics
cover -help -info -version cover -help -info -version
-summary -report report_format -outputdir dir -summary -report report_format -outputdir dir
-file filename -exclude filname -select filename -ignore filname
-write [db] -delete -dump_db -write [db] -delete -dump_db
-silent -silent
-coverage criterion -coverage criterion
Expand Down Expand Up @@ -220,8 +220,8 @@ The following command line options are supported:
-report report_format - report format required (default html) -report report_format - report format required (default html)
-outputdir - directory for output (default db) -outputdir - directory for output (default db)
-file filename - only report on the file (default all) -select filename - only report on the file (default all)
-exclude filename - don't report on the file (default none) -ignore filename - don't report on the file (default none)
-write [db] - write the merged database (default off) -write [db] - write the merged database (default off)
-delete - drop database(s) (default off) -delete - drop database(s) (default off)
-dump_db - dump database(s) (for debugging) (default off) -dump_db - dump database(s) (for debugging) (default off)
Expand All @@ -242,9 +242,9 @@ given for the new database, the first database read in will be
overwritten. When this option is used no reports are generated by overwritten. When this option is used no reports are generated by
default. default.
Specify -file options to report on specific files. Specify -coverage Specify -select and -ignore options to report on specific files.
options to report on specific criteria. By default all available Specify -coverage options to report on specific criteria. By default
information on all criteria in all files will be reported. all available information on all criteria in all files will be reported.
=head1 EXIT STATUS =head1 EXIT STATUS
Expand All @@ -266,7 +266,7 @@ See the BUGS file.
=head1 VERSION =head1 VERSION
Version 0.45 - 27th May 2004 Version 0.46 - 23rd June 2004
=head1 LICENCE =head1 LICENCE
Expand Down
12 changes: 6 additions & 6 deletions cpancover
Expand Up @@ -12,17 +12,17 @@ require 5.6.1;
use strict; use strict;
use warnings; use warnings;


our $VERSION = "0.45"; our $VERSION = "0.46";


use Devel::Cover::DB 0.45; use Devel::Cover::DB 0.46;


use Cwd (); use Cwd ();
use File::Find (); use File::Find ();
use Getopt::Long; use Getopt::Long;
use Pod::Usage; use Pod::Usage;
use Template 2.00; use Template 2.00;


use Carp; $SIG{__DIE__} = \&Carp::confess; # use Carp; $SIG{__DIE__} = \&Carp::confess;


my $Template; my $Template;


Expand Down Expand Up @@ -309,7 +309,7 @@ package Devel::Cover::Cpancover::Template::Provider;
use strict; use strict;
use warnings; use warnings;


our $VERSION = "0.45"; our $VERSION = "0.46";


use base "Template::Provider"; use base "Template::Provider";


Expand Down Expand Up @@ -345,7 +345,7 @@ $Templates{html} = <<'EOT';
<!-- <!--
This file was generated by Devel::Cover Version 0.45 This file was generated by Devel::Cover Version 0.46
Devel::Cover is copyright 2001-2004, Paul Johnson (pjcj@cpan.org) Devel::Cover is copyright 2001-2004, Paul Johnson (pjcj@cpan.org)
Expand Down Expand Up @@ -455,7 +455,7 @@ The following exit values are returned:
=head1 VERSION =head1 VERSION
Version 0.45 - 27th May 2004 Version 0.46 - 23rd June 2004
=head1 LICENCE =head1 LICENCE
Expand Down
4 changes: 2 additions & 2 deletions create_gold
Expand Up @@ -12,11 +12,11 @@ require 5.6.1;
use strict; use strict;
use warnings; use warnings;


our $VERSION = "0.45"; our $VERSION = "0.46";


use blib; use blib;


use Devel::Cover::Test 0.45; use Devel::Cover::Test 0.46;


my @tests = @ARGV; my @tests = @ARGV;


Expand Down
6 changes: 3 additions & 3 deletions gcov2perl
Expand Up @@ -12,9 +12,9 @@ require 5.6.1;
use strict; use strict;
use warnings; use warnings;


our $VERSION = "0.45"; our $VERSION = "0.46";


use Devel::Cover::DB 0.45; use Devel::Cover::DB 0.46;


use Getopt::Long; use Getopt::Long;
use Pod::Usage; use Pod::Usage;
Expand Down Expand Up @@ -135,7 +135,7 @@ Huh?
=head1 VERSION =head1 VERSION
Version 0.45 - 27th May 2004 Version 0.46 - 23rd June 2004
=head1 LICENCE =head1 LICENCE
Expand Down

0 comments on commit 4116963

Please sign in to comment.