| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::SetupTeardown; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
32627
|
use strict; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
92
|
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
72
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
20
|
use Test::Builder; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
670
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = 0.003; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
|
11
|
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
1
|
1695
|
my $class = shift; |
|
13
|
5
|
|
|
|
|
11
|
my %routines = @_; |
|
14
|
|
|
|
|
|
|
|
|
15
|
5
|
|
|
|
|
32
|
my $self = { tbuilder => Test::Builder->new, |
|
16
|
|
|
|
|
|
|
setup => $routines{setup}, |
|
17
|
|
|
|
|
|
|
teardown => $routines{teardown} }; |
|
18
|
|
|
|
|
|
|
|
|
19
|
5
|
|
|
|
|
56
|
bless $self, $class; |
|
20
|
5
|
|
|
|
|
16
|
return $self; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub run_test { |
|
25
|
|
|
|
|
|
|
|
|
26
|
10
|
|
|
10
|
1
|
4039
|
my ($self, $description, $coderef) = @_; |
|
27
|
10
|
|
|
|
|
14
|
my $exception_while_running_block; |
|
28
|
|
|
|
|
|
|
|
|
29
|
10
|
100
|
100
|
|
|
48
|
if ($ENV{TEST_ST_ONLY} |
|
30
|
|
|
|
|
|
|
and $ENV{TEST_ST_ONLY} ne $description) { |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# TEST_ST_ONLY is set for another test case |
|
33
|
1
|
|
|
|
|
3
|
return; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
9
|
|
|
|
|
42
|
$self->{tbuilder}->note($description); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Run setup() routine before each test |
|
40
|
9
|
100
|
|
|
|
503
|
$self->{setup}->() if $self->{setup}; |
|
41
|
|
|
|
|
|
|
|
|
42
|
9
|
|
|
|
|
17
|
eval { |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Catch all exceptions thrown by the block, to be rethrown |
|
45
|
|
|
|
|
|
|
# later after the teardown has had a chance to run |
|
46
|
9
|
|
|
|
|
23
|
&$coderef; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
}; |
|
49
|
|
|
|
|
|
|
|
|
50
|
9
|
100
|
|
|
|
52
|
if ($@) { |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Stash this for now |
|
53
|
3
|
|
|
|
|
5
|
$exception_while_running_block = $@; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Run teardown routine after each test |
|
58
|
9
|
100
|
|
|
|
38
|
$self->{teardown}->() if $self->{teardown}; |
|
59
|
|
|
|
|
|
|
|
|
60
|
9
|
100
|
|
|
|
29
|
if ($exception_while_running_block) { |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# The teardown has run now, rethrow the exception |
|
63
|
3
|
|
|
|
|
19
|
die $exception_while_running_block; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
|
70
|
|
|
|
|
|
|
__END__ |