| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
|
2
|
|
|
|
|
|
|
# -*- Mode: cperl; mode: folding; -*- |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package TestRunner; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
############################################################################### |
|
7
|
|
|
|
|
|
|
# Nigel Hamilton |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
|
10
|
|
|
|
|
|
|
# All Rights Reserved |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
|
13
|
|
|
|
|
|
|
# Filename: TestRunner.pm |
|
14
|
|
|
|
|
|
|
# Description: Run test scripts |
|
15
|
|
|
|
|
|
|
# |
|
16
|
|
|
|
|
|
|
# Date Change |
|
17
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
18
|
|
|
|
|
|
|
# 08/02/2005 Auto generated file |
|
19
|
|
|
|
|
|
|
# 08/02/2005 Needed to improve software quality |
|
20
|
|
|
|
|
|
|
# 09/02/2005 Added a prompter to stop |
|
21
|
|
|
|
|
|
|
# 11/02/2005 Need to run multiple tests in a cronjob arrangement |
|
22
|
|
|
|
|
|
|
# 09/08/2005 Added a run method for integration with Goo 2 |
|
23
|
|
|
|
|
|
|
# |
|
24
|
|
|
|
|
|
|
############################################################################### |
|
25
|
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
|
5333
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
42
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
423
|
use Object; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use Prompter; |
|
30
|
|
|
|
|
|
|
use TestMaker; |
|
31
|
|
|
|
|
|
|
use PerlCoder; |
|
32
|
|
|
|
|
|
|
use TestLoader; |
|
33
|
|
|
|
|
|
|
use base qw(Object); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
############################################################################### |
|
37
|
|
|
|
|
|
|
# |
|
38
|
|
|
|
|
|
|
# run_test - run a single test, interactively |
|
39
|
|
|
|
|
|
|
# |
|
40
|
|
|
|
|
|
|
############################################################################### |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub run_test { |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my ($this, $filename) = @_; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $test = TestLoader::load_test($filename); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# run the test!! |
|
49
|
|
|
|
|
|
|
$test->do(); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# display the final result |
|
52
|
|
|
|
|
|
|
$test->show_results(); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
############################################################################### |
|
58
|
|
|
|
|
|
|
# |
|
59
|
|
|
|
|
|
|
# run_all_tests - run all the tests in a given directory |
|
60
|
|
|
|
|
|
|
# |
|
61
|
|
|
|
|
|
|
############################################################################### |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub run_all_tests { |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my ($directory) = @_; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $results = ""; |
|
68
|
|
|
|
|
|
|
my $module_count; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
foreach my $filename (FileUtilities::get_file_list($directory . "/*.tpm")) { |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# strip any preceding directory |
|
73
|
|
|
|
|
|
|
$filename =~ s!^.*/!!; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# print "Testing --- $filename\n"; |
|
76
|
|
|
|
|
|
|
$module_count++; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my $test = TestLoader::load_test($filename); |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# run the test!! |
|
81
|
|
|
|
|
|
|
$test->do(); |
|
82
|
|
|
|
|
|
|
$results .= $test->get_results() . "\n"; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# only show module level detail |
|
87
|
|
|
|
|
|
|
my @passes = grep { $_ =~ /passed:/ } split(/\n/, $results); |
|
88
|
|
|
|
|
|
|
my @fails = grep { $_ =~ /failed:/ } split(/\n/, $results); |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $pass_report = join("\n", @passes); |
|
91
|
|
|
|
|
|
|
my $fail_report = join("\n", @fails); |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
return <<REPORT; |
|
94
|
|
|
|
|
|
|
Passed Tests |
|
95
|
|
|
|
|
|
|
------------ |
|
96
|
|
|
|
|
|
|
$pass_report |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Failed Tests |
|
100
|
|
|
|
|
|
|
------------ |
|
101
|
|
|
|
|
|
|
$fail_report |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
REPORT |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
############################################################################### |
|
109
|
|
|
|
|
|
|
# |
|
110
|
|
|
|
|
|
|
# run - run a test |
|
111
|
|
|
|
|
|
|
# |
|
112
|
|
|
|
|
|
|
############################################################################### |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub run { |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
my ($this, $thing) = @_; |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
my $filename = $thing->get_filename(); |
|
119
|
|
|
|
|
|
|
my $full_path = $thing->get_full_path(); |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# Prompter::notify($thing->to_string()); |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
if ($filename =~ /\.tpm$/) { |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# this is a test file run it! |
|
126
|
|
|
|
|
|
|
$this->run_test($full_path); |
|
127
|
|
|
|
|
|
|
Prompter::notify("Completed test(s) for $filename. Press a key."); |
|
128
|
|
|
|
|
|
|
return; |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# match parts of the path |
|
133
|
|
|
|
|
|
|
$full_path =~ /(.*)\/(.*)\.pm$/; |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
my $test_filename = $2 . "Test.tpm"; |
|
136
|
|
|
|
|
|
|
my $test_full_path = $1 . "/test/" . $test_filename; |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# is there a test file already? |
|
139
|
|
|
|
|
|
|
unless (-e $test_full_path) { |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# Prompter::notify(" making this --- $full_path "); |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# make a new test |
|
144
|
|
|
|
|
|
|
my $maker = TestMaker->new(); |
|
145
|
|
|
|
|
|
|
$maker->create_test_for_module($full_path); |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
my $pc = PerlCoder->new({ filename => $full_path }); |
|
148
|
|
|
|
|
|
|
$pc->add_change_log("Created test file: $test_filename"); |
|
149
|
|
|
|
|
|
|
$pc->save(); |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# Prompter::notify("goo loader loading ... $test_filename "); |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# switch to this test |
|
156
|
|
|
|
|
|
|
my $test_thing = Goo::Loader::load($test_full_path); |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
# show a profile of the test |
|
159
|
|
|
|
|
|
|
$test_thing->do_action("P"); |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
1; |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
__END__ |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 NAME |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
TestRunner - Run test scripts |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
use TestRunner; |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 METHODS |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=over |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item run_test |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
run a single test, interactively |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=item run_all_tests |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
run all the tests in a given directory |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=item run |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
run a test |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=back |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 AUTHOR |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Nigel Hamilton <nigel@turbo10.com> |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
206
|
|
|
|
|
|
|
|