From 9d2e477a1763606f6e2d847f78efc463201fc907 Mon Sep 17 00:00:00 2001
From: Jason Etheridge <jason@esilibrary.com>
Date: Thu, 8 Aug 2013 14:08:57 -0400
Subject: [PATCH] within the HTML output, link to first error

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
---
 qa/test_output_filter.pl | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/qa/test_output_filter.pl b/qa/test_output_filter.pl
index c747767ee..cbe479cb7 100755
--- a/qa/test_output_filter.pl
+++ b/qa/test_output_filter.pl
@@ -1,11 +1,12 @@
 #!/usr/bin/perl
 
 my $state = 'skipping';
+my $error_count = 0;
 
 if ($0 =~ /html/) {
     print "<html><head><title>test output</title>";
     print "<link rel='stylesheet' type='text/css' href='test_output.css'>";
-    print "</head><body><pre>\n";
+    print "</head><body><a href='#error'>Jump to first error</a><pre>\n";
 }
 
 while (my $line = <>) {
@@ -26,10 +27,14 @@ while (my $line = <>) {
                 || $line =~ /\. not ok/
             ) {
                 $class .= 'notok ';
+                $error_count++;
             }
             $class .= 'result ' if ($line =~ /^Result:/); 
             $class .= 'pass ' if ($line =~ /^Result: PASS/); 
-            $class .= 'fail ' if ($line =~ /^Result: FAIL/); 
+            if ($line =~ /^Result: FAIL/) {
+                $class .= 'fail ';
+                $error_count++;
+            }
             if ($line =~ /^#/
                 || $line =~ /Checks:/
                 || $line =~ /_\.-~=/
@@ -42,7 +47,12 @@ while (my $line = <>) {
                 $class .= 'comment ';
             }
             chomp $line;
-            print "<span class='$class'>$line</span>\n";
+            my $html_line = "<span class='$class'>$line</span>";
+            if ($error_count == 1) {
+                print "<a name='error'>$html_line</a>\n";
+            } else {
+                print "$html_line\n";
+            }
         } else {
             print $line;
         }
-- 
2.11.0