Chromium Code Reviews| Index: build/android/pylib/gtest/gtest_test_instance.py |
| diff --git a/build/android/pylib/gtest/gtest_test_instance.py b/build/android/pylib/gtest/gtest_test_instance.py |
| index 173628b46134d6c7fe4b5eab246fea610c8836a6..d4132907b982ab4825cdf0fb37821493ee3327ed 100644 |
| --- a/build/android/pylib/gtest/gtest_test_instance.py |
| +++ b/build/android/pylib/gtest/gtest_test_instance.py |
| @@ -206,6 +206,14 @@ class GtestTestInstance(test_instance.TestInstance): |
| self._test_arguments = args.test_arguments |
| + # Crash detection constants. |
| + self._TEST_ERROR_RE = re.compile(r'FAILURES!!! Tests run: \d+,' |
|
jbudorick
2016/03/01 05:05:26
not class-scope constants, top level module-scope
|
| + r' Failures: \d+, Errors: 1') |
| + self._TEST_CURRENTLY_RUNNING_RE = re.compile(r'\[ERROR:.*?\]' |
| + r' Currently running: (.*)') |
| + self._TEST_RUN_RE = re.compile(r'\[ RUN \] (.*)') |
| + self._TEST_CRASH_TAG = '[ CRASHED ]' |
| + |
| @property |
| def activity(self): |
| return self._apk_helper and self._apk_helper.GetActivityName() |
| @@ -343,6 +351,23 @@ class GtestTestInstance(test_instance.TestInstance): |
| return '*-%s' % ':'.join(disabled_filter_items) |
| + def GetCrashedTestCase(self, output): |
| + crash_happened = self._TEST_ERROR_RE.search(output[-1]) |
| + if not crash_happened: |
| + return |
| + # Crashes that will cause output like DCHECK(false). |
| + has_crash = self._TEST_CURRENTLY_RUNNING_RE.search(output[-3]) |
|
jbudorick
2016/03/01 05:05:26
Can we either document this -3 or check for _TEST_
|
| + if has_crash: |
| + return has_crash.group(1) |
| + |
| + # Crashes that will cause output like null pointer dereference. |
| + index = -1 if not self._TEST_CRASH_TAG in output \ |
|
jbudorick
2016/03/01 05:05:26
Do we need to check all of output for _TEST_CRASH_
|
| + else output.index(self._TEST_CRASH_TAG) |
| + if not index == -1: |
| + run_info = self._TEST_RUN_RE.search(output[index-1]) |
|
jbudorick
2016/03/01 05:05:26
I think this should scan up until it finds a match
|
| + if run_info: |
| + return run_info.group(1) |
| + |
| # pylint: disable=no-self-use |
| def ParseGTestOutput(self, output): |
| """Parses raw gtest output and returns a list of results. |
| @@ -377,7 +402,10 @@ class GtestTestInstance(test_instance.TestInstance): |
| log=('\n'.join(log) if log else ''))) |
| log = None |
| result_type = None |
| - |
| + crashed_test_case = self.GetCrashedTestCase(output) |
| + if crashed_test_case: |
| + results.append(base_test_result.BaseTestResult(crashed_test_case, \ |
|
jbudorick
2016/03/01 05:05:26
nit: again, no \
|
| + base_test_result.ResultType.CRASH)) |
| return results |
| #override |