38 |
|
#some local working variables |
39 |
|
my $testmodule; |
40 |
|
my $module; |
41 |
< |
my $dir; |
41 |
> |
my $dir=""; |
42 |
|
if ( $fullmodule=~/\// ) { |
43 |
|
($dir=$fullmodule)=~s/(.*\/)(.*)/$1/; |
44 |
|
} |
52 |
|
$self->{class}=$module; |
53 |
|
$self->{"datadir"}=$datadir; |
54 |
|
$self->{filenumber}=0; |
55 |
+ |
$self->{temparea}="/tmp/SCRAMtest"; |
56 |
+ |
use File::Path; |
57 |
+ |
mkpath ($self->{temparea},0, 0777); |
58 |
|
|
59 |
|
# Now setup a new testobject of the appropriate type |
60 |
|
require $testmodule."\.pm"; |
86 |
|
my $self=shift; |
87 |
|
my $string=shift; |
88 |
|
$self->{testnumber}++; |
89 |
< |
$self->_testout(); |
89 |
> |
$self->_testout(""); |
90 |
|
$self->_testout("---------------------------* Test $self->{testnumber}". |
91 |
|
" *------------------------------"); |
92 |
|
$self->_testout("| $string "); |
126 |
|
my $name=shift; |
127 |
|
|
128 |
|
if ( -d "$name" ) { |
129 |
< |
$self->testpass(); |
129 |
> |
$self->testpass(""); |
130 |
|
} |
131 |
|
else { |
132 |
|
$self->testfail("Directory $name does not exist"); |
202 |
|
$self->{classname}=$module; |
203 |
|
($self->{class}=$module)=~s/.*\///g; |
204 |
|
$self->{classfile}=$ENV{SCRAM_HOME}."/src/".$self->{classname}."\.pm"; |
202 |
– |
$self->{testclassfile}=$path."/test/".$self->{testclass}."\.pm"; |
205 |
|
$self->init(@_); |
206 |
|
$self->analyseInterface(); |
207 |
|
delete $self->{expect}; |
221 |
|
$self->_testout(">Trying interface $subname "); |
222 |
|
my $args=join ', ', @_; |
223 |
|
$self->_testout( " (".$args.")" ); |
224 |
+ |
$num=0; |
225 |
|
if ( exists $self->{expect} ) { |
226 |
< |
@myreturn=($self->{object}->$subname(@_)); |
227 |
< |
if ( "@myreturn" eq $self->{expect} ) { |
228 |
< |
$self->testpass("OK - returned as expected"); |
229 |
< |
} |
230 |
< |
else { |
228 |
< |
$self->testfail("Expecting $self->{expect}, got @myreturn"); |
226 |
> |
@mylist=eval { $self->{object}->$subname(@_); }; |
227 |
> |
die "Test Failed $@\n" if $@; |
228 |
> |
for $myreturn ( @mylist ) { |
229 |
> |
if ( \$myreturn=~/HASH/ ) { |
230 |
> |
print "Hash Refreturned\n"; |
231 |
|
} |
232 |
< |
return @myreturn; |
232 |
> |
elsif ( \$myreturn=~/CODE/ ) { |
233 |
> |
print "Code Ref returned\n"; |
234 |
> |
} |
235 |
> |
elsif ( \$myreturn=~/ARRAY/ ) { |
236 |
> |
print "Array Ref returned\n"; |
237 |
> |
} |
238 |
> |
else { |
239 |
> |
my $expected=$self->{expect}[$num++]; |
240 |
> |
if ( $myreturn eq $expected ) { #simple return case |
241 |
> |
$self->testpass("OK - returned as expected ($expected)"); |
242 |
> |
} |
243 |
> |
else { |
244 |
> |
$self->testfail("Expecting $expected, got ". |
245 |
> |
$myreturn); |
246 |
> |
} |
247 |
> |
} |
248 |
> |
} |
249 |
> |
return @mylist; |
250 |
|
} |
251 |
|
else { |
252 |
|
return ($self->{object}->$subname(@_)); |
260 |
|
my $self=shift; |
261 |
|
my $string=shift; |
262 |
|
|
263 |
< |
$self->{expect}=$string; |
263 |
> |
push @{$self->{expect}}, $string; |
264 |
|
} |
265 |
|
|
266 |
|
sub clearexpect { |