43.1 Read Test Cases
Convention ⊲ 31 ⊳ We have the convention that a
.signatures.as file contains in
its first line the name of the corresponding test domain in a form similar to the
line
if and only if the corresponding .as.nw file is really a test file and not merely a
support file.
See Section 41.4.3 for the generation of .signatures.as files.
561⟨read signatures of testcases 561⟩≡ (559)
open(SF, $TCASFILES) || die "File $TCASFILES not found";
while(<SF>) {
chomp; #remove trailing newline;
if (/testcases /) {
s/.*\///; # strip off ’testcases’ and directory part
#now check whether there is a prefix that must be added
if (/([^ ]+) (\w+)/) {$file=$1;} else {$file=$_;}
$file .= ".signatures.as";
$domain = ’’;
&getSignaturesRecursively(0, $domain, $file, $file);
}
}
close(SF);
⟨get signature data 562⟩
Uses check 353.
We modify the global variable $DATA. However, such a modification is only
done, if the first line in the file $file in $depth zero matches the regular
expression
Otherwise, this signature file is considered to correspond to a test support file and is
therefore skipped completely. Files corresponding to #include lines will recursively
be included so that we get the full exports list.
562⟨get signature data 562⟩≡ (561)
sub getSignaturesRecursively {
my($depth, $domain, $file, $sigfile) = @_;
if ($depth > 100) {die "Signature inclusion: recursion depth > 100";}
my(@lines)=();
open(FILE, "$sigfile") || die "File $sigfile not found";
while(<FILE>) {push @lines, $_}
close(FILE);
my($line);
for $line (@lines) {
if ($depth == 0 && $line =~ /^-- Test(.*)/) {
$domain="Test$1";
$DATA{$file}{’domain’}=$domain;
next;
}
if ($domain eq ’’) {last;}
chomp $line; # remove newline character
if ($line =~ /^#include "(.*)"/) {
&getSignaturesRecursively($depth+1, $domain, $file, $1);
} else {
push @{$DATA{$file}{’lines’}}, $line;
}
}
}