Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make failed tests more clear in the output.
  • Loading branch information
icculus committed Mar 5, 2010
1 parent 42fef0a commit eae869e
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion unit_tests/run_tests.pl
Expand Up @@ -112,6 +112,7 @@ sub compare_files {
my $pass = 0;
my $fail = 0;
my $skip = 0;
my @fails = ();

my $result = '';
chdir($testdir) or die("Failed to chdir('$testdir'): $!\n");
Expand All @@ -126,6 +127,7 @@ sub compare_files {
print(" ... $module / $testtype ...\n");
my $fname = readdir(TESTDIR);
while (defined $fname) {
my $isfail = 0;
my $origfname = $fname;
$fname = readdir(TESTDIR); # set for next iteration.
next if (-d $origfname);
Expand All @@ -136,6 +138,7 @@ sub compare_files {
$result = 'PASS';
$pass++;
} elsif ($rc == 0) {
$isfail = 1;
$result = 'FAIL';
$fail++;
} elsif ($rc == -1) {
Expand All @@ -148,14 +151,30 @@ sub compare_files {
} else {
$reason = '';
}
print("$result ${origfname}${reason}\n");
my $output = "$result ${origfname}${reason}\n";
print($output);
push(@fails, $output) if $isfail;

$totaltests++;
}
closedir(TESTDIR);
}
}

if (scalar(@fails)) {
print("\n\n");
print("*************************************************************\n");
print("*************************************************************\n");
print("** SOME TESTS FAILED! PLEASE CORRECT THE FOLLOWING ISSUES. **\n");
print("*************************************************************\n");
print("*************************************************************\n");
print("\n");
foreach (@fails) {
print $_;
}
print("\n\n");
}

print("\n$totaltests tests, $pass passed, $fail failed, $skip skipped.\n\n");

exit(($fail > 0) ? 1 : 0);
Expand Down

0 comments on commit eae869e

Please sign in to comment.