line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Unit::Debug; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Test::Unit::Debug - framework debugging control |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package MyRunner; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Test::Unit::Debug qw(debug_to_file debug_pkg); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
debug_to_file('foo.log'); |
14
|
|
|
|
|
|
|
debug_pkg('Test::Unit::TestCase'); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
2
|
|
654
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
220
|
|
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
2
|
|
11
|
use base 'Exporter'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
247
|
|
21
|
2
|
|
|
2
|
|
12
|
use vars qw(@EXPORT_OK); |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
963
|
|
22
|
|
|
|
|
|
|
@EXPORT_OK = qw(debug debug_to_file |
23
|
|
|
|
|
|
|
debug_pkg no_debug_pkg debug_pkgs no_debug_pkgs debugged); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my %DEBUG = (); |
26
|
|
|
|
|
|
|
my $out = \*STDERR; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 ROUTINES |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 debug_to_file($file) |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Switch debugging to C<$file>. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub debug_to_file { |
37
|
0
|
|
|
0
|
1
|
0
|
my ($file) = @_; |
38
|
0
|
0
|
|
|
|
0
|
open(DEBUG, ">$file") or die "Couldn't open $file for writing"; |
39
|
0
|
|
|
|
|
0
|
$out = \*DEBUG; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 debug_to_stderr() |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Switch debugging to STDERR (this is the default). |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub debug_to_stderr { |
49
|
0
|
|
|
0
|
1
|
0
|
$out = \*STDERR; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub debug { |
53
|
2002
|
|
|
2002
|
0
|
6518
|
my ($package, $filename, $line) = caller(); |
54
|
2002
|
50
|
|
|
|
7827
|
print $out @_ if $DEBUG{$package}; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 debug_pkg($pkg) |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Enable debugging in package C<$pkg>. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub debug_pkg { |
64
|
0
|
|
|
0
|
1
|
|
$DEBUG{$_[0]} = 1; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 debug_pkgs(@pkgs) |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Enable debugging in the packages C<@pkgs>. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub debug_pkgs { |
74
|
0
|
|
|
0
|
1
|
|
$DEBUG{$_} = 1 foreach @_; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 debug_pkg($pkg) |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Enable debugging in package C<$pkg>. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub no_debug_pkg { |
84
|
0
|
|
|
0
|
0
|
|
$DEBUG{$_[0]} = 0; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 debug_pkgs(@pkgs) |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Disable debugging in the packages C<@pkgs>. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub no_debug_pkgs { |
94
|
0
|
|
|
0
|
0
|
|
$DEBUG{$_} = 0 foreach @_; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub debugged { |
98
|
0
|
|
|
0
|
0
|
|
my ($package, $filename, $line) = caller(); |
99
|
0
|
|
0
|
|
|
|
return $DEBUG{$_[0] || $package}; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 AUTHOR |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Copyright (c) 2000-2002, 2005 the PerlUnit Development Team |
106
|
|
|
|
|
|
|
(see L or the F file included in this |
107
|
|
|
|
|
|
|
distribution). |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
All rights reserved. This program is free software; you can |
110
|
|
|
|
|
|
|
redistribute it and/or modify it under the same terms as Perl itself. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 SEE ALSO |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
L |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; |