php/inc/GeneralErrorFilter.php
author Ed Morley <emorley@mozilla.com>
Wed, 29 Apr 2015 23:02:40 +0100 (2015-04-29)
changeset 1520 8aff676182f9135bbf0698bebbec23d2dd2f4570
parent 1458 ae716547090e9cf8231c5836a1cb84680987a099
permissions -rw-r--r--
Bug 1054977 - Mention TBPL EOL in README
<?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 explicitly marked as passing/info.
    if (preg_match("/TEST-(?:INFO|PASS) /", $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);
    // Exclude TEST-UNEXPECTED- messages that appear in Android & B2G logcats since
    // they are already printed in the main part of the log.
    if (preg_match("/I[ \/](Gecko|Robocop|TestRunner).*TEST-UNEXPECTED-/", $line))
      return false;
    // Exclude Python exceptions for Marionette timeouts, since a more helpful
    // TEST-UNEXPECTED-FAIL line will be output for them later in the log.
    if (preg_match("/^TimeoutException: /", $line))
      return false;
    // Exclude spammy false positives (these are bugs to some extent, but don't cause the
    // run to fail, so it's best to prevent them being highlighted to avoid confusion).
    if (preg_match("/^ImportError: No module named pygtk$/", $line))
      return false;
    // 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-/", $line)  // . . . . . . . . . . . . . . TEST-UNEXPECTED-{FAIL,PASS,...}
       || preg_match("/^error: TEST FAILED/", $line) //  . . . . . . . . . . . JetPack
       || preg_match("/^g?make(?:\[\d+\])?: \*\*\*/", $line) //. . . . . . . . gmake
       || preg_match("/mozmake\.exe(?:\[\d+\])?: \*\*\*/", $line)  //. . . . . mozmake on Windows
       || preg_match("/fatal error/i", $line) // . . . . . . . . . . . . . . . Link & cases where automation strings are inappropriate
       || 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("/E\/GeckoLinker/", $line) // . . . . . . . . . . . . . . Logcat linker errors
       || preg_match("/SUMMARY: AddressSanitizer/", $line)  // . . . . . . . . AddressSanitizer
       || preg_match("/SUMMARY: LeakSanitizer/", $line)  //. . . . . . . . . . LeakSanitizer
       || preg_match("/ error\([0-9]*\):/", $line)  // . . . . . . . . . . . . C
       || preg_match("/:[0-9]+: error:/", $line)  // . . . . . . . . . . . . . C / C++
       || preg_match("/ error R?C[0-9]*:/", $line) //  . . . . . . . . . . . . MSVC
       || preg_match("/^[A-Za-z.]+Error: /", $line)  // . . . . . . . . . .  . Python exceptions
       || preg_match("/^[A-Za-z.]*Exception: /", $line) // . . . . . . . . . . Python exceptions
       || 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 [45]\d\d:/", $line)  // . . . . . . . . . . . . . eg ftp.m.o 4xx or 5xx 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
      );
  }
}