php/inc/GeneralErrorFilter.php
author Nicholas Nethercote <nnethercote@mozilla.com>
Mon, 06 Jan 2014 13:53:05 -0800
changeset 1345 3c03d7a0962b680238b010558f9d7af8c33993fe
parent 1259 eb85b76b7b527d8ad40632164b6e71fdde8c481d
child 1346 79c4207d52881fb5b9e64cbde5d51544c0c81d78
permissions -rw-r--r--
Bug 952605 - Highlight Valgrind's "ERROR SUMMARY" line when a non-zero number of errors are present. r=edmorley.

<?php
/* -*- Mode: PHP; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=2 et tw=80 : */

/**
 * This class is used for finding errors in logs. It's used when generating
 * parsed logs with summaries at the top, and for the "general error" summary
 * that's displayed in a blue box on TBPL.
 */

require_once 'inc/LineFilter.php';

class GeneralErrorFilter implements LineFilter {

  public function getType() {
    return "general_error";
  }

  public function matchLine($fullLine) {
    // Exclude test harness output explictly marked as passing/info
    if (preg_match("/TEST-(?:INFO|PASS) /", $fullLine))
      return false;
    // Exclude known spammy false positives for now (these are real bugs,
    // but currently don't cause the run to fail.
    if (preg_match("/ReferenceError: gApp is not defined/", $fullLine))
      return false;
    // mozharness-style prefixed log output for failures
    if (preg_match("/^\d+:\d+:\d+[ ]+(?:ERROR|CRITICAL|FATAL) - /", $fullLine))
      return true;
    // Non-error mozharness prefixes (if present) are removed before attempting to match.
    $mozharnessPrefixRE = "/^\d+:\d+:\d+[ ]+(?:DEBUG|INFO|WARNING) -[ ]+/";
    $line = preg_replace($mozharnessPrefixRE, '', $fullLine);
    // Copied from
    // http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/webtools/tinderbox/ep_unittest.pl&rev=1.7#28
    // minus CVS errors
    return
      (preg_match("/TEST-UNEXPECTED-(?:PASS|FAIL) /", $line)  // . . . . . . . new unified error output
       || preg_match("/^error: TEST FAILED/", $line) //  . . . . . . . . . . . JetPack
       || preg_match("/^g?make(?:\[\d+\])?: \*\*\*/", $line) //. . . . . . . . gmake
       || preg_match("/fatal error/", $line)  // . . . . . . . . . . . . . . . Link
       || preg_match("/PROCESS-CRASH/", $line)  // . . . . . . . . . . . . . . crash
       || preg_match("/Assertion failure:/", $line) // . . . . . . . . . . . . MOZ_ASSERT failures
       || preg_match("/Assertion failed:/", $line)  // . . . . . . . . . . . . assert() failures
       || preg_match("/###!!! ABORT:/", $line)  // . . . . . . . . . . . . . . NS_ABORT
       || preg_match("/ error\([0-9]*\):/", $line)  // . . . . . . . . . . . . C
       || preg_match("/ error R?C[0-9]*:/", $line) //  . . . . . . . . . . . . MSVC
       || preg_match("/^[A-Za-z]+Error:/", $line)  // . . . . . . . . . .  . . Python exceptions
       || preg_match("/^BaseException:/", $line) // . . . . . . . . . .  . . . Python exception
       || preg_match("/ERROR SUMMARY: [1-9]\d* errors from \d+ contexts/", $line) // Valgrind errors
       || preg_match("/Automation Error:/", $line)  // . . . . . . . . . . . . Release Automation
       || preg_match("/Remote Device Error:/", $line) // . . . . . . . . . . . Release Automation (eg sut_tools)
       || preg_match("/command timed out:/", $line) // . . . . . . . . . . . . buildbot/mock timeout
       || preg_match("/^remoteFailed:/", $line) // . . . . . . . . . . . . . . buildbot (eg twisted.internet.error.ConnectionLost)
       || preg_match("/^rm: cannot /", $line) // . . . . . . . . . . . . . . . failures of type bug 692715
       || preg_match("/^abort:/", $line)  // . . . . . . . . . . . . . . . . . hg errors
       || preg_match("/ERROR (?:500|503):/", $line) // . . . . . . . . . . . . eg ftp.m.o errors
       || preg_match("/wget: unable /", $line)  // . . . . . . . . . . . . . . eg ftp.m.o errors
       || preg_match("/^Output exceeded \d+ bytes/", $line) // . . . . . . . . Log exceeded buildbot limit
       || preg_match("/^The web-page 'stop build' button was pressed/", $line) // Cancelled by self-serve
      );
  }
}