Make failed tests more clear in the output.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 04 Mar 2010 23:15:10 -0800
changeset 888 3f13aefabfce
parent 887 d2ed72e046ad
child 889 d3ecff60a3f5
Make failed tests more clear in the output.
unit_tests/run_tests.pl
--- a/unit_tests/run_tests.pl	Thu Mar 04 23:08:13 2010 -0800
+++ b/unit_tests/run_tests.pl	Thu Mar 04 23:15:10 2010 -0800
@@ -112,6 +112,7 @@
 my $pass = 0;
 my $fail = 0;
 my $skip = 0;
+my @fails = ();
 
 my $result = '';
 chdir($testdir) or die("Failed to chdir('$testdir'): $!\n");
@@ -126,6 +127,7 @@
         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);
@@ -136,6 +138,7 @@
                 $result = 'PASS';
                 $pass++;
             } elsif ($rc == 0) {
+                $isfail = 1;
                 $result = 'FAIL';
                 $fail++;
             } elsif ($rc == -1) {
@@ -148,7 +151,9 @@
             } else {
                 $reason = '';
             }
-            print("$result ${origfname}${reason}\n");
+            my $output = "$result ${origfname}${reason}\n";
+            print($output);
+            push(@fails, $output) if $isfail;
 
             $totaltests++;
         }
@@ -156,6 +161,20 @@
     }
 }
 
+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);