Bug 1001441 - Reftest analyser & tinderboxprint log excerpt lines shouldn't be truncated; r=RyanVM
authorEd Morley <emorley@mozilla.com>
Fri, 25 Apr 2014 15:56:15 +0100
changeset 1409 89669a90d278bd62f7c0b3ec39b1ea3ee280b49c
parent 1408 79597a29ab41af5fdd6f955ff31214d09322aa01
child 1410 a4ecc816058384aa99870939e00721c50228f42b
push id795
push useremorley@mozilla.com
push dateFri, 25 Apr 2014 14:56:51 +0000
reviewersRyanVM
bugs1001441
Bug 1001441 - Reftest analyser & tinderboxprint log excerpt lines shouldn't be truncated; r=RyanVM
php/inc/LogParser.php
--- a/php/inc/LogParser.php
+++ b/php/inc/LogParser.php
@@ -33,33 +33,37 @@ class LogParser implements LogGenerator 
     if (substr($text, -1) == "\r")
       $text = substr($text, 0, -1);
     return '<a href="'.$target.'">'.htmlspecialchars($text)."</a>\n";
   }
 
   public function getExcerpt($asHTML = false) {
     // Keep in sync with AnnotatedSummaryGenerator.php's $maxParsedFailures
     $maxParsedFailures = 100;
+    $maxLineLength = 500;
+    $type = $this->lineFilter->getType();
+    // The TinderboxPrint and reftest analyser scrape lines must remain untouched.
+    $canTruncate = ($type != "tinderbox_print" && $type != "reftest");
     $lines = $this->getLines();
     $matchedLineNumbers = $this->getMatchedLineNumbers();
     $excerptLines = array();
     foreach ($matchedLineNumbers as $i => $lineNumber) {
       // Only display the first N failures
       if ($i >= $maxParsedFailures) {
         $totalFailures = count($matchedLineNumbers);
         $excerptLines[] = "First $maxParsedFailures of $totalFailures failures shown.\n";
         break;
       }
       // Remove mozharness timestamp/log level prefixes to avoid annotated summary bloat
       // and to allow for bug suggestions when searching for the whole failure line.
       $mozharnessPrefixRE = "/^\d+:\d+:\d+[ ]+(?:DEBUG|INFO|WARNING|ERROR|CRITICAL|FATAL) - [ ]?/";
       $matchedline = preg_replace($mozharnessPrefixRE, '', $lines[$lineNumber]);
-      if (strlen($matchedline) > 500) {
+      if ($canTruncate && strlen($matchedline) > $maxLineLength) {
         // Cap the line length to avoid hanging the browser in extreme cases.
-        $matchedline = rtrim(substr($matchedline, 0, 500)) . "... [exceeded max length]\n";
+        $matchedline = rtrim(substr($matchedline, 0, $maxLineLength)) . "... [exceeded max length]\n";
       }
       $excerptLines[] = $asHTML ? $this->linkLine('#error'.$i, $matchedline) : $matchedline;
     }
     return implode('', $excerptLines);
   }
 
   public function getLines() {
     if ($this->lines === null) {