Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(703)

Unified Diff: scripts/common/gtest_utils.py

Issue 10636008: Convert runtest to have a built-in annotator. (Closed) Base URL: http://git.chromium.org/chromium/tools/build.git@master
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | scripts/slave/gtest/test_result.py » ('j') | scripts/slave/runtest.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/common/gtest_utils.py
diff --git a/scripts/common/gtest_utils.py b/scripts/common/gtest_utils.py
index b1128bbf217a788da6ce722171ca575e737f5f68..7aade61d713ae3920815855eb3bc1561ddf9007c 100755
--- a/scripts/common/gtest_utils.py
+++ b/scripts/common/gtest_utils.py
@@ -11,6 +11,7 @@ class GTestLogParser(object):
def __init__(self):
# State tracking for log parsing
+ self.completed = False
self._current_test = ''
self._failure_description = []
self._current_suppression_hash = ''
@@ -44,10 +45,14 @@ class GTestLogParser(object):
# This regexp also matches SomeName.SomeTest/1, which should be harmless.
test_name_regexp = r'((\w+/)?\w+\.\w+(/\d+)?)'
+ self._master_name_re = re.compile('\[Running for master: "([^"]*)"')
+ self.master_name = ''
+
self._test_name = re.compile(test_name_regexp)
self._test_start = re.compile('\[\s+RUN\s+\] ' + test_name_regexp)
self._test_ok = re.compile('\[\s+OK\s+\] ' + test_name_regexp)
self._test_fail = re.compile('\[\s+FAILED\s+\] ' + test_name_regexp)
+ self._test_passed = re.compile('\[\s+PASSED\s+\] \d+ tests?.')
self._test_timeout = re.compile(
'Test timeout \([0-9]+ ms\) exceeded for ' + test_name_regexp)
self._disabled = re.compile(' YOU HAVE (\d+) DISABLED TEST')
@@ -60,6 +65,9 @@ class GTestLogParser(object):
self._retry_message = re.compile('RETRYING FAILED TESTS:')
self.retrying_failed = False
+ def GetCurrentTest(self):
+ return self._current_test
+
def _StatusOfTest(self, test):
"""Returns the status code for the given test, or 'not known'."""
test_status = self._test_status.get(test, ('not known', []))
@@ -158,6 +166,18 @@ class GTestLogParser(object):
"""
return self._suppressions.get(suppression_hash, [])
+ def CompletedWithoutFailure(self):
+ """Returns True if all tests completed and no tests failed unexpectedly."""
+
cmp 2012/06/28 19:14:16 nit: remove empty line
+ if not self.completed:
+ return False
+
+ # don't count FAILS and FLAKY here
+ if self.FailedTests():
+ return False
+
+ return True
cmp 2012/06/28 19:14:16 let's condense lines 172-179 to one line: return
+
def ProcessLine(self, line):
"""This is called once with each line of the test log."""
@@ -168,6 +188,19 @@ class GTestLogParser(object):
# multiple times, so this will only show the most recent values (but they
# should all be the same anyway).
+ # Is it a line listing the master name?
+ if not self.master_name:
+ results = self._master_name_re.search(line)
+ if results:
+ self.master_name = results.group(1)
+
+ # Is it a line declaring all tests passed?
+ results = self._test_passed.search(line)
+ if results:
+ self.completed = True
+ self._current_test = ''
+ return
+
# Is it a line reporting disabled tests?
results = self._disabled.search(line)
if results:
« no previous file with comments | « no previous file | scripts/slave/gtest/test_result.py » ('j') | scripts/slave/runtest.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698