line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TestLoader; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# Turbo10.com |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
7
|
|
|
|
|
|
|
# All Rights Reserved |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
10
|
|
|
|
|
|
|
# Filename: TestLoader.pm |
11
|
|
|
|
|
|
|
# Description: Load a test from disk to run |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# Date Change |
14
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
# 14/02/2005 Auto generated file |
16
|
|
|
|
|
|
|
# 14/02/2005 Needed to make TestRunner a little simpler |
17
|
|
|
|
|
|
|
# 05/05/2005 Added tcgi for testing CGI scripts |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
############################################################################### |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
9864
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
603
|
use Thing; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use FileUtilities; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
############################################################################### |
28
|
|
|
|
|
|
|
# |
29
|
|
|
|
|
|
|
# load_test - can we run it? - this raises exceptions |
30
|
|
|
|
|
|
|
# |
31
|
|
|
|
|
|
|
############################################################################### |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub load_test { |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my ($filename) = @_; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# print "trying to load ... $filename !!\n"; |
38
|
|
|
|
|
|
|
unless ($filename =~ /\.t?pm$/) { |
39
|
|
|
|
|
|
|
die("$filename is not a valid module."); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $module = $filename; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# strip the path |
45
|
|
|
|
|
|
|
$module =~ s!.*/!!; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# strip the last suffix |
48
|
|
|
|
|
|
|
$module =~ s/\..*$//; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# add the special suffix for module tests |
51
|
|
|
|
|
|
|
$module .= ".tpm"; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# load the module - tried eval in a code block { } but it didn't work |
54
|
|
|
|
|
|
|
# watch this if BUG from evalling twice? |
55
|
|
|
|
|
|
|
eval("require '$filename';"); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
if ($@) { die("Failed to require $module: $@"); } |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$module =~ s/\.tpm$//g; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# calling this ... |
62
|
|
|
|
|
|
|
#print " my $module->new($module); \n"; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $test = $module->new($module); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
unless ($test->isa("Tester")) { |
67
|
|
|
|
|
|
|
die("$module is not a Tester module"); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
unless ($test->can("do")) { |
71
|
|
|
|
|
|
|
die("$module does not contain a do method"); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
return $test; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 NAME |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
TestLoader - Load a test from disk to run |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 SYNOPSIS |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
use TestLoader; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 DESCRIPTION |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 METHODS |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=over |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item load_test |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
can we run it? - this raises exceptions |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=back |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 AUTHOR |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Nigel Hamilton <nigel@turbo10.com> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 SEE ALSO |
112
|
|
|
|
|
|
|
|