-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunTests.pl
executable file
·45 lines (40 loc) · 1.11 KB
/
runTests.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/perl
sub toInt($) {
my $param = shift();
return ($param) ? 1 : 0;
}
# -dirname
# -filename
sub runTest($$) {
my ($dir, $file) = @_;
my $path = "$dir/$file";
my $output = `scala -cp scala-parser-combinators.jar:. Checker $path 2>&1`;
my $isErr = toInt($output =~ /Illtyped/m);
my $isGood = toInt($output =~ /well\-typed/m);
my $expectedErr = toInt($file =~ /^bad/);
print "$path: ";
if (($isGood == 0 && $isErr == 1) ||
($isGood == 1 && $isErr == 0)) {
if ($expectedErr == $isErr) {
print "pass!\n";
} else {
print "----FAIL----\n";
}
} else {
print "----UNKNOWN (Consider Failure)----\n";
}
}
# Given the name of a directory, runs all tests in that directory
sub runTests($) {
my $dirName = shift();
my $fd;
opendir($fd, $dirName) or die "Could not open tests directory: '$dirName'";
while (my $file = readdir($fd)) {
if ($file =~/^(good|bad).*\.fun$/) {
runTest($dirName, $file);
}
}
closedir($fd);
}
runTests("basic_tests");
runTests("big_tests");