blib/lib/Devel/Trace/Cwd.pm

filter: Statementstmt 45.9% 17 / 37 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 62.5% 5 / 8 Podpod 50.0% 1 / 2 totaltotal 38.3% 23 / 60 CC 7 SCAR 21.3
CC
7
Cov
35%
DB
20.0
import
7.1
trace
6.0
CRAP 8.4
↑ Summary
1 package Devel::Trace::Cwd;
2 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 $Devel::Trace::Cwd::VERSION = '0.02';
4 }
5  
6 #ABSTRACT: Print out each line before it is executed and track cwd changes
7  
8 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Cwd ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 our $TRACE = 1;
13 1 our $CWD;
14  
15 # This is the important part. The rest is just fluff.
16 0 ▶sub DB::DB {
Subroutine DB: not called CC=4 SCAR=30.0
Pod undocumented
17 0 ▶ return unless $TRACE;
Branch: 1 branch
BranchTrueFalseTotal
unless $Devel::Trace::Cwd::TRACE 0 0 0
18 0 my ($p, $f, $l) = caller;
19 0 my $code = \@{"::_<$f"};
20 0 print STDERR ">> $f:$l: $code->[$l]";
21 0 my $ctmp = Cwd::getcwd();
22 0 ▶ if ( !$CWD or $CWD ne $ctmp ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $Devel::Trace::Cwd::CWD or $Devel::Trace::Cwd::CWD ne $ctmp) 0 0 0
Condition0%0/3
not $Devel::Trace::Cwd::CWD or $Devel::Trace::Cwd::CWD ne $ctmp
l!l&&r!l&&!r
000
MC/DC0%0/2
not $Devel::Trace::Cwd::CWD or $Devel::Trace::Cwd::CWD ne $ctmp
not $Devel::Trace::Cwd::CWD $Devel::Trace::Cwd::CWD ne $ctmp
Truth table0%0/3
not(A) or B
A= not $Devel::Trace::Cwd::CWDB= $Devel::Trace::Cwd::CWD ne $ctmp
ABresult
1X1
011
000
23 0 $CWD = $ctmp;
24 0 print STDERR "CWD: '$CWD'\n";
25 }
26 }
27  
28  
29 0 ▶sub import {
Subroutine import: not called CC=3 SCAR=19.6
30 0 my $package = shift;
31 0 foreach (@_) {
32 0 ▶ if ($_ eq 'trace') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ eq 'trace') { } 0 0 0
33 0 my $caller = caller;
34 0 *{$caller . '::trace'} = \&{$package . '::trace'};
35 } else {
36 1 ▶ use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 0 croak "Package $package does not export `$_'; aborting";
38 }
39 }
40 }
41  
42 1 my %tracearg = ('on' => 1, 'off' => 0);
43 0 ▶sub trace {
Subroutine trace: not called CC=2 SCAR=17.9
Pod documented
44 0 my $arg = shift;
45 0 ▶ $arg = $tracearg{$arg} while exists $tracearg{$arg};
Branch: 1 branch
BranchTrueFalseTotal
exists $tracearg{$arg} and do { $arg = $tracearg{$arg} } 0 0 0
46 0 $TRACE = $arg;
47 }
48  
49 1 1;
50  
51  
52  
53 __END__
↑ Summary