add language detection and skipping; --debug as arg; more minor manual linting
This commit is contained in:
parent
253b892267
commit
6f6c894c08
106
autoTest.pl
106
autoTest.pl
|
|
@ -11,6 +11,9 @@ $TIME="time -p";
|
|||
$os = `uname`;
|
||||
|
||||
$debug=0;
|
||||
if ($ARGV[0] eq "--debug") {
|
||||
$debug = 1;
|
||||
}
|
||||
|
||||
@langs = ("cgcc", "cclang", "asm",
|
||||
# Uncomment for alternat C algorithms
|
||||
|
|
@ -366,7 +369,7 @@ sub checkValid {
|
|||
print "Checking outputed results for validity...\n";
|
||||
local(@res) = `wc primes.*.txt`;
|
||||
local($i);
|
||||
for($i=0; $i < $#res; $i++) {
|
||||
for($i=0; $i < $#res; $i++) {
|
||||
$arr[$i][0] = `echo \"$res[$i]\" | awk '{print \$2}'`;
|
||||
chomp($arr[$i][0]);
|
||||
chomp($arr[$i][0]);
|
||||
|
|
@ -379,8 +382,7 @@ sub checkValid {
|
|||
$pt = 0;
|
||||
for($i=0; $i<=$#arr; $i++) {
|
||||
$arr[$i][2] = 0;
|
||||
for($p=0; $p <= $#arr; $p++)
|
||||
{
|
||||
for($p=0; $p <= $#arr; $p++) {
|
||||
if($p==$i) { next; }
|
||||
if($arr[$i][0] == $arr[$p][0]) { $arr[$i][2]++; }
|
||||
}
|
||||
|
|
@ -391,8 +393,7 @@ sub checkValid {
|
|||
|
||||
if($pt != $#arr ) {
|
||||
print "Differences detected in ".(($#arr+1)-($pt+1)) ." output files:\n";
|
||||
for($i=0; $i<= $#arr; $i++)
|
||||
{
|
||||
for($i=0; $i<= $#arr; $i++) {
|
||||
if($arr[$i][2] < $pt || $pt == 0) {
|
||||
print "\t". $arr[$i][1]."\n";
|
||||
}
|
||||
|
|
@ -435,10 +436,19 @@ sub parseTimes {
|
|||
}
|
||||
|
||||
sub getByLocate {
|
||||
my $locatep = `locate -v locate`;
|
||||
if ($locatep eq "") {
|
||||
return "";
|
||||
}
|
||||
|
||||
local($where) = `locate $_[0] | grep bin | grep -v cgi | grep -v port | grep -v src`;
|
||||
($where) = $where =~ /(.*\/$_[0])\n.*$/;
|
||||
#print "WHERE: '$where'\n";
|
||||
if($where eq "") { return ""; } else { return $where; }
|
||||
if($where eq "") {
|
||||
return "";
|
||||
} else {
|
||||
return $where;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -451,7 +461,7 @@ sub getInterp {
|
|||
else {
|
||||
return "/usr/bin/env $_[0]";
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
local($t1, $t2) = split(":", $where);
|
||||
chomp($t2);
|
||||
if($t2 ne "") {
|
||||
|
|
@ -462,6 +472,52 @@ sub getInterp {
|
|||
}
|
||||
}
|
||||
|
||||
sub isTestable {
|
||||
my $l = $_[0];
|
||||
my $compileable = 1;
|
||||
my $interpB = 0;
|
||||
my $testable = 1;
|
||||
my $cp;
|
||||
if( $data{$l}{"compiler0"}) {
|
||||
$compileable = 0;
|
||||
|
||||
my $ccount = 1;
|
||||
if($data{$l}{'compiler'}) {
|
||||
$ccount = $data{$l}{'compiler'};
|
||||
}
|
||||
|
||||
for($cp = 0; $cp < $ccount; $cp++) {
|
||||
|
||||
if($data{$l}{"compiler$cp"} eq "interpB") {
|
||||
$interpB = 1;
|
||||
$compileable = 1;
|
||||
last;
|
||||
}
|
||||
$comp = getInterp($data{$l}{"compiler$cp"});
|
||||
if($comp ne "") {
|
||||
$compileable = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $data{$l}{"interp0"} or $interpB) {
|
||||
$testable = 0;
|
||||
my $interpc = 1;
|
||||
if($data{$l}{'interp'}) {
|
||||
$interpc = $data{$l}{'interp'};
|
||||
}
|
||||
for($cp = 0 ; $cp < $interpc; $cp++) {
|
||||
my $interp = getInterp($data{$l}{"interp$cp"});
|
||||
if ($interp ne "") {
|
||||
$testable = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $testable && $compileable
|
||||
}
|
||||
|
||||
# HEADER
|
||||
|
||||
open(results, ">".$RESULTS) || die("Cannot open $RESULTS\n");
|
||||
|
|
@ -492,10 +548,18 @@ foreach $l (@langs) {
|
|||
if($data{$l}{'osreprompt'} && $os =~ $data{$l}{'oswarn'}) {
|
||||
$data{$l}{'warn'} = $data{$l}{'oswarnmsg'};
|
||||
}
|
||||
|
||||
if($yesall == 0 || $data{$l}{'reprompt'}) {
|
||||
|
||||
# Determine if testable
|
||||
$testable = isTestable($l);
|
||||
if (! $testable) {
|
||||
print "Skipping ". $data{$l}{"name"} . ": Test appears unrunnable, could not find language in environment!\n"
|
||||
}
|
||||
$query = "";
|
||||
if($testable && ($yesall == 0 || $data{$l}{'reprompt'})) {
|
||||
print "($item/$llen) Run ".$data{$l}{"name"}." test\n";
|
||||
if($data{$l}{'warn'} && !$data{$l}{"reprompt"}) { print "WARNING: $data{$l}{'warn'}\n";}
|
||||
if($data{$l}{'warn'} && !$data{$l}{"reprompt"}) {
|
||||
print "WARNING: $data{$l}{'warn'}\n";
|
||||
}
|
||||
|
||||
if($data{$l}{'reprompt'}) {
|
||||
print "RE-PROMPT: WARNING: ";
|
||||
|
|
@ -514,9 +578,11 @@ foreach $l (@langs) {
|
|||
if($query eq "a" || $query eq "A") {
|
||||
$yesall = 1;
|
||||
}
|
||||
if(($yesall == 1 && !$data{$l}{'reprompt'}) || $query eq "y" || $query eq "Y" ) {
|
||||
if($testable && (($yesall == 1 && !$data{$l}{'reprompt'}) || $query eq "y" || $query eq "Y" )) {
|
||||
if($yesall == 1) {
|
||||
if($query eq "n" || $query eq "N") { $query = "y";}
|
||||
if($query eq "n" || $query eq "N") {
|
||||
$query = "y";
|
||||
}
|
||||
}
|
||||
if($query eq "Y") {$query eq "y"; }
|
||||
if($yesall == 1 && $query eq "y" && !$data{$l}{'reprompt'}) {
|
||||
|
|
@ -531,14 +597,14 @@ foreach $l (@langs) {
|
|||
|
||||
print results "($item/$llen) ". $data{$l}{"name"}." results:\n";
|
||||
|
||||
if( $data{$l}{'osfilter'} and $os =~ $data{$l}{'osfilter'}) {
|
||||
if( $data{$l}{'osfilter'} and $os =~ $data{$l}{'osfilter'}) {
|
||||
print "ERROR: This language is flagged as incompatible with this operating system\n\n";
|
||||
print results "ERROR: This language is flagged as incompatible with this operating system\n\n";
|
||||
next;
|
||||
}
|
||||
|
||||
$cmd="";
|
||||
if( $data{$l}{"compiler0"}) {
|
||||
if( $data{$l}{"compiler0"}) {
|
||||
print "Compiling";
|
||||
print results "Compile";
|
||||
if($l ne "java" && $l ne "m3") {$rcmd = "rm -f $data{$l}{'prog'}";}
|
||||
|
|
@ -548,15 +614,12 @@ foreach $l (@langs) {
|
|||
$cmd .= "-c \"" .$TIME . " bash -c \\\"";
|
||||
|
||||
$cp = 0;
|
||||
if(! $data{$l}{'compiler'})
|
||||
{
|
||||
if(! $data{$l}{'compiler'}) {
|
||||
$data{$l}{'compiler'} = 1;
|
||||
}
|
||||
|
||||
for(; $cp < $data{$l}{'compiler'}; $cp++)
|
||||
{
|
||||
if($data{$l}{"compiler$cp"} eq "interpB")
|
||||
{
|
||||
for(; $cp < $data{$l}{'compiler'}; $cp++) {
|
||||
if($data{$l}{"compiler$cp"} eq "interpB") {
|
||||
$cp = $data{$l}{'compiler'};
|
||||
$interpB = 1;
|
||||
last;
|
||||
|
|
@ -566,8 +629,7 @@ foreach $l (@langs) {
|
|||
}
|
||||
if($cp == $data{$l}{'compiler'}) {
|
||||
$clist = "";
|
||||
for($p=0;$p<$data{$l}{'compiler'};$p++)
|
||||
{
|
||||
for($p=0;$p<$data{$l}{'compiler'};$p++) {
|
||||
last if($data{$l}{"compiler$p"} eq "interpB");
|
||||
$clist .= "\t\t\t($p) ". $data{$l}{"compiler$p"}."\n";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue