line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Mini::Logger; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
17834
|
use 5.006; |
|
4
|
|
|
|
|
11
|
|
4
|
4
|
|
|
4
|
|
18
|
use strict; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
68
|
|
5
|
4
|
|
|
4
|
|
17
|
use warnings; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
94
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
2343
|
use Time::HiRes; |
|
4
|
|
|
|
|
4113
|
|
|
4
|
|
|
|
|
21
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
28
|
|
|
28
|
1
|
408
|
my ($class, %args) = @_; |
11
|
|
|
|
|
|
|
return bless { |
12
|
|
|
|
|
|
|
verbose => 0, |
13
|
|
|
|
|
|
|
buffer => *STDOUT{IO}, |
14
|
28
|
|
|
|
|
199
|
%args, |
15
|
|
|
|
|
|
|
count => {}, |
16
|
|
|
|
|
|
|
times => {}, |
17
|
|
|
|
|
|
|
}, $class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# =========================== |
21
|
|
|
|
|
|
|
# Attribute Accessors |
22
|
|
|
|
|
|
|
# =========================== |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub verbose { |
25
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
26
|
0
|
|
|
|
|
0
|
return $self->{verbose}; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub buffer { |
30
|
87
|
|
|
87
|
1
|
100
|
my ($self) = @_; |
31
|
87
|
|
|
|
|
11110
|
return $self->{buffer}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# =========================== |
35
|
|
|
|
|
|
|
# Output Functions |
36
|
|
|
|
|
|
|
# =========================== |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub print { |
39
|
87
|
|
|
87
|
1
|
164
|
my ($self, @msg) = @_; |
40
|
87
|
|
|
|
|
100
|
print { $self->buffer() } @msg; |
|
87
|
|
|
|
|
169
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub say { |
44
|
82
|
|
|
82
|
1
|
196
|
my ($self, @msg) = @_; |
45
|
82
|
|
|
|
|
240
|
$self->print(join("\n", @msg), "\n"); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# =========================== |
49
|
|
|
|
|
|
|
# Callbacks |
50
|
|
|
|
|
|
|
# =========================== |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Called before the test suite is run. |
53
|
|
|
|
|
|
|
sub begin_test_suite { |
54
|
12
|
|
|
12
|
1
|
79
|
my ($self, %args) = @_; |
55
|
12
|
|
|
|
|
93
|
$self->{times}->{$self} = -Time::HiRes::time(); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Called before each test case is run. |
59
|
|
|
|
|
|
|
sub begin_test_case { |
60
|
9
|
|
|
9
|
1
|
38
|
my ($self, $tc, @tests) = @_; |
61
|
9
|
|
|
|
|
49
|
$self->{times}->{$tc} = -Time::HiRes::time(); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Called before each test is run. |
65
|
|
|
|
|
|
|
sub begin_test { |
66
|
12
|
|
|
12
|
1
|
54
|
my ($self, $tc, $test) = @_; |
67
|
12
|
|
|
|
|
72
|
$self->{times}->{"$tc#$test"} = -Time::HiRes::time(); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Called after each test is run. |
71
|
|
|
|
|
|
|
sub finish_test { |
72
|
64
|
|
|
64
|
1
|
700871
|
my ($self, $tc, $test, $assertions) = @_; |
73
|
64
|
|
|
|
|
135
|
$self->{count}->{test}++; |
74
|
64
|
|
|
|
|
112
|
$self->{count}->{assert} += $assertions; |
75
|
64
|
|
|
|
|
412
|
$self->{times}->{"$tc#$test"} += Time::HiRes::time(); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Called after each test case is run. |
79
|
|
|
|
|
|
|
sub finish_test_case { |
80
|
12
|
|
|
12
|
1
|
68
|
my ($self, $tc, @tests) = @_; |
81
|
12
|
|
|
|
|
28
|
$self->{count}->{test_case}++; |
82
|
12
|
|
|
|
|
72
|
$self->{times}->{$tc} += Time::HiRes::time(); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# Called after each test suite is run. |
86
|
|
|
|
|
|
|
sub finish_test_suite { |
87
|
9
|
|
|
9
|
1
|
32
|
my ($self, $exit_code) = @_; |
88
|
9
|
|
|
|
|
70
|
$self->{times}->{$self} += Time::HiRes::time(); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Called when a test passes. |
92
|
|
|
|
|
|
|
sub pass { |
93
|
4
|
|
|
4
|
1
|
27
|
my ($self, $tc, $test) = @_; |
94
|
4
|
|
|
|
|
24
|
$self->{count}->{pass}++; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Called when a test is skipped. |
98
|
|
|
|
|
|
|
sub skip { |
99
|
2
|
|
|
2
|
1
|
9
|
my ($self, $tc, $test, $e) = @_; |
100
|
2
|
|
|
|
|
9
|
$self->{count}->{skip}++; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# Called when a test fails. |
104
|
|
|
|
|
|
|
sub fail { |
105
|
2
|
|
|
2
|
1
|
18
|
my ($self, $tc, $test, $e) = @_; |
106
|
2
|
|
|
|
|
11
|
$self->{count}->{fail}++; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# Called when a test dies with an error. |
110
|
|
|
|
|
|
|
sub error { |
111
|
4
|
|
|
4
|
1
|
19
|
my ($self, $tc, $test, $e) = @_; |
112
|
4
|
|
|
|
|
15
|
$self->{count}->{error}++; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# =========================== |
116
|
|
|
|
|
|
|
# Statistics |
117
|
|
|
|
|
|
|
# =========================== |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# Accessor for counters. |
120
|
|
|
|
|
|
|
sub count { |
121
|
7
|
|
|
7
|
1
|
13
|
my ($self, $key) = @_; |
122
|
7
|
|
100
|
|
|
47
|
return ($key ? $self->{count}->{$key} : $self->{count}) || 0; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# Accessor for the timing data. |
126
|
|
|
|
|
|
|
sub time { |
127
|
6
|
|
|
6
|
1
|
15
|
my ($self, $key) = @_; |
128
|
6
|
|
|
|
|
29
|
return $self->{times}->{$key}; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
__END__ |