Skip to content

Commit

Permalink
Bug 1060765 - Refactor the error parser to make it easier to unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed Morley committed Aug 11, 2015
1 parent 27c024d commit 33b1d44
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions treeherder/log_parser/parsers.py
Expand Up @@ -308,22 +308,24 @@ def add(self, line, lineno):

def parse_line(self, line, lineno):
"""Check a single line for an error. Keeps track of the linenumber"""
if self.is_error_line(line):
self.add(line, lineno)

def is_error_line(self, line):
if self.RE_EXCLUDE_1_SEARCH.search(line):
return
return False

if self.RE_ERR_1_MATCH.match(line):
self.add(line, lineno)
return
return True

# Remove mozharness prefixes prior to matching
trimline = re.sub(self.RE_MOZHARNESS_PREFIX, "", line)

if self.RE_EXCLUDE_2_SEARCH.search(trimline):
return
return False

if any(term for term in self.IN_SEARCH_TERMS if term in trimline) or \
self.RE_ERR_MATCH.match(trimline) or self.RE_ERR_SEARCH.search(trimline):
self.add(line, lineno)
return bool(any(term for term in self.IN_SEARCH_TERMS if term in trimline) or
self.RE_ERR_MATCH.match(trimline) or self.RE_ERR_SEARCH.search(trimline))


class TalosParser(ParserBase):
Expand Down

0 comments on commit 33b1d44

Please sign in to comment.