From: Don Armstrong Date: Thu, 19 Apr 2012 22:27:43 +0000 (-0700) Subject: add testcover rule; add fake safe for testing coverage X-Git-Tag: release/2.6.0~392 X-Git-Url: https://git.donarmstrong.com/?p=debbugs.git;a=commitdiff_plain;h=428aeea32c686fa2227dd113242d263afba12b8a add testcover rule; add fake safe for testing coverage --- diff --git a/Makefile b/Makefile index e92a5f6..da8de60 100644 --- a/Makefile +++ b/Makefile @@ -34,6 +34,9 @@ build: test: $(PERL) -MTest::Harness -I. -e 'runtests(glob(q(t/*.t)))' +testcover: + PERLLIB=t/cover_lib/ cover -test + clean: if [ -e Makefile.perl ]; then \ $(MAKE) -f Makefile.perl clean; \ diff --git a/t/cover_lib/Safe.pm b/t/cover_lib/Safe.pm new file mode 100644 index 0000000..e3227c2 --- /dev/null +++ b/t/cover_lib/Safe.pm @@ -0,0 +1,31 @@ +# this is a tiny module which basically provides a fake safe for use with Devel::Cover +package Safe; + +sub new { + my $class = shift; + my $self = {root => 'fakeSafe'}; + bless ($self,$class); + return $self; +} + +sub permit { +} + +sub reval { + my ($self,$code) = @_; + eval "package $self->{root}; $code"; +} + +sub root { + my ($self) = @_; + return($self->{root}); +} + +sub varglob { + my ($self,$var) = @_; + no strict 'refs'; + no warnings 'once'; + return *{$self->{root}."::$var"}; +} + +1;