]> git.donarmstrong.com Git - debbugs.git/commitdiff
add testcover rule; add fake safe for testing coverage
authorDon Armstrong <don@donarmstrong.com>
Thu, 19 Apr 2012 22:27:43 +0000 (15:27 -0700)
committerDon Armstrong <don@donarmstrong.com>
Thu, 19 Apr 2012 22:27:43 +0000 (15:27 -0700)
Makefile
t/cover_lib/Safe.pm [new file with mode: 0644]

index e92a5f603d8e31a27c6106252e2691196b202486..da8de6085d0c1fc8611bdd633d77350c9d003bd0 100644 (file)
--- 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 (file)
index 0000000..e3227c2
--- /dev/null
@@ -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;