line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Unit::HarnessUnit; |
2
|
|
|
|
|
|
|
# this is a test runner which outputs in the same |
3
|
|
|
|
|
|
|
# format that Test::Harness expects. |
4
|
2
|
|
|
2
|
|
2338
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
381
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
13
|
use base qw(Test::Unit::Runner); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1941
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
12
|
use Test::Unit::TestSuite; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
39
|
|
9
|
2
|
|
|
2
|
|
9
|
use Test::Unit::Loader; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1417
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
2
|
|
|
2
|
0
|
26
|
my $class = shift; |
13
|
2
|
|
|
|
|
7
|
my ($filehandle) = @_; |
14
|
|
|
|
|
|
|
# should really use the IO::Handle package here. |
15
|
|
|
|
|
|
|
# this is very ugly. |
16
|
2
|
50
|
|
|
|
8
|
$filehandle = \*STDOUT unless $filehandle; |
17
|
2
|
|
|
|
|
14
|
bless { _Print_stream => $filehandle }, $class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub print_stream { |
21
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
22
|
0
|
|
|
|
|
0
|
return $self->{_Print_stream}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _print { |
26
|
87
|
|
|
87
|
|
215
|
my $self = shift; |
27
|
87
|
|
|
|
|
398
|
my (@args) = @_; |
28
|
87
|
|
|
|
|
836
|
$self->{_Print_stream}->print( @args); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub start_test { |
32
|
85
|
|
|
85
|
0
|
197
|
my $self=shift; |
33
|
85
|
|
|
|
|
325
|
my $test=shift; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub not_ok { |
37
|
3
|
|
|
3
|
0
|
6
|
my $self = shift; |
38
|
3
|
|
|
|
|
6
|
my ($test, $exception) = @_; |
39
|
3
|
|
|
|
|
17
|
$self->_print("\nnot ok ERROR ", |
40
|
|
|
|
|
|
|
$test->name(), |
41
|
|
|
|
|
|
|
"\n$exception\n"); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub ok { |
45
|
82
|
|
|
82
|
0
|
115
|
my $self = shift; |
46
|
82
|
|
|
|
|
125
|
my ($test) = @_; |
47
|
82
|
|
|
|
|
653
|
$self->_print("ok PASS " . $test->name() . "\n"); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub add_error { |
51
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
52
|
0
|
|
|
|
|
0
|
$self->not_ok(@_); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub add_failure { |
56
|
3
|
|
|
3
|
0
|
10
|
my $self = shift; |
57
|
3
|
|
|
|
|
12
|
$self->not_ok(@_); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub add_pass { |
61
|
82
|
|
|
82
|
0
|
630
|
my $self = shift; |
62
|
82
|
|
|
|
|
310
|
$self->ok(@_); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub end_test { |
66
|
85
|
|
|
85
|
0
|
379
|
my $self = shift; |
67
|
85
|
|
|
|
|
445
|
my ($test) = @_; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub do_run { |
71
|
2
|
|
|
2
|
0
|
6
|
my $self = shift; |
72
|
2
|
|
|
|
|
10
|
my ($suite) = @_; |
73
|
2
|
|
|
|
|
21
|
my $result = $self->create_test_result(); |
74
|
2
|
|
|
|
|
12
|
$result->add_listener($self); |
75
|
2
|
|
|
|
|
12
|
$suite->run($result, $self); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub main { |
79
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
80
|
0
|
|
|
|
|
0
|
my $a_test_runner = __PACKAGE__->new; |
81
|
0
|
|
|
|
|
0
|
$a_test_runner->start(@_); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub run { |
85
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
86
|
0
|
|
|
|
|
0
|
my ($class) = @_; |
87
|
0
|
|
|
|
|
0
|
my $a_test_runner = Test::Unit::TestRunner->new(); |
88
|
0
|
0
|
|
|
|
0
|
if ($class->isa("Test::Unit::Test")) { |
89
|
0
|
|
|
|
|
0
|
$a_test_runner->do_run($class, 0); |
90
|
|
|
|
|
|
|
} else { |
91
|
0
|
|
|
|
|
0
|
$a_test_runner->do_run(Test::Unit::TestSuite->new($class), 0); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub start { |
96
|
2
|
|
|
2
|
0
|
10
|
my $self = shift; |
97
|
2
|
|
|
|
|
8
|
my (@args) = @_; |
98
|
|
|
|
|
|
|
|
99
|
2
|
|
|
|
|
6
|
my $test_case = ""; |
100
|
2
|
|
|
|
|
3
|
my $wait = 0; |
101
|
2
|
|
|
|
|
14
|
my $suite = Test::Unit::Loader::load(@args); |
102
|
2
|
50
|
|
|
|
11
|
if ($suite) { |
103
|
2
|
|
|
|
|
12
|
my $count=$suite->count_test_cases(); |
104
|
2
|
|
|
|
|
19
|
$self->_print("STARTING TEST RUN\n1..$count\n"); |
105
|
2
|
|
|
|
|
64
|
$self->do_run($suite); |
106
|
2
|
|
|
|
|
30
|
exit(0); |
107
|
|
|
|
|
|
|
} else { |
108
|
0
|
|
|
|
|
|
$self->_print("Invalid argument to test runner: $args[0]\n"); |
109
|
0
|
|
|
|
|
|
exit(1); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |
114
|
|
|
|
|
|
|
__END__ |