diff --git a/tools/quality_tracking/tgrid_parser.py b/tools/quality_tracking/tgrid_parser.py index 2b674d526b..0889e0c462 100644 --- a/tools/quality_tracking/tgrid_parser.py +++ b/tools/quality_tracking/tgrid_parser.py @@ -19,9 +19,18 @@ class FailedToParseBuildStatus(Exception): pass +def _map_status(status): + if status == 'exception': + return 'failed' + return status + + def _parse_builds(revision, html): """Parses the bot list, which is a sequence of lines. + See contract for parse_tgrid_page for more information on how this function + behaves. + Example input: OK The first regular expression group captures Android, second 119, third OK. @@ -29,10 +38,12 @@ def _parse_builds(revision, html): result = {} for match in re.finditer('.*?' - '(OK|failed|building|warnings).*?', + '(OK|failed|building|warnings|exception)' + '.*?', html, re.DOTALL): revision_and_bot_name = revision + "--" + match.group(1) - build_number_and_status = match.group(2) + "--" + match.group(3) + build_number_and_status = match.group(2) + "--" + _map_status( + match.group(3)) result[revision_and_bot_name] = build_number_and_status @@ -56,7 +67,8 @@ def parse_tgrid_page(html): Returns: A dictionary with -- mapped to --, where status is either OK, failed, - building or warnings. + building or warnings. The status may be 'exception' in the input, but + we simply map that to failed. """ result = {} diff --git a/tools/quality_tracking/tgrid_parser_test.py b/tools/quality_tracking/tgrid_parser_test.py index 8b15c90c0e..d427945be8 100755 --- a/tools/quality_tracking/tgrid_parser_test.py +++ b/tools/quality_tracking/tgrid_parser_test.py @@ -133,6 +133,15 @@ make chrome """ +MINIMAL_EXCEPTION = """ + +1576 + +exception
+Sync + +""" + class TGridParserTest(unittest.TestCase): def test_parser_throws_exception_on_empty_html(self): self.assertRaises(tgrid_parser.FailedToParseBuildStatus, @@ -165,7 +174,7 @@ class TGridParserTest(unittest.TestCase): self.assertEqual('1576--Win32Debug', first_mapping[0]) self.assertEqual('434--building', first_mapping[1]) - def test_parser_finds_warned_bot(self): + def test_parser_finds_warnings(self): result = tgrid_parser.parse_tgrid_page(MINIMAL_WARNED) self.assertEqual(1, len(result), 'There is only one bot in the sample.') @@ -174,6 +183,16 @@ class TGridParserTest(unittest.TestCase): self.assertEqual('1576--Chrome', first_mapping[0]) self.assertEqual('109--warnings', first_mapping[1]) + def test_parser_finds_exception_and_maps_to_failed(self): + result = tgrid_parser.parse_tgrid_page(MINIMAL_EXCEPTION) + + self.assertEqual(1, len(result), 'There is only one bot in the sample.') + first_mapping = result.items()[0] + + self.assertEqual('1576--Chrome', first_mapping[0]) + self.assertEqual('109--failed', first_mapping[1]) + + def test_parser_finds_all_bots_and_revisions(self): result = tgrid_parser.parse_tgrid_page(SAMPLE_FILE)