Chromium Code Reviews| Index: build/android/pylib/gtest/test_package.py |
| diff --git a/build/android/pylib/gtest/test_package.py b/build/android/pylib/gtest/test_package.py |
| index c1172c882409c2e1e00094e2bddadd42deaaaa27..037909b56b44f52a69f08d86195b9f005fabf739 100644 |
| --- a/build/android/pylib/gtest/test_package.py |
| +++ b/build/android/pylib/gtest/test_package.py |
| @@ -4,13 +4,15 @@ |
| import logging |
| -import re |
| import os |
| +import re |
| from pylib import constants |
| from pylib import pexpect |
| from pylib.android_commands import errors |
| -from pylib.base.test_result import BaseTestResult, TestResults |
| +from pylib.base.base_test_result import BaseTestResult |
|
craigdh
2013/03/23 00:41:39
import modules, not classes
frankf
2013/03/23 01:32:59
Done.
|
| +from pylib.base.base_test_result import TestRunResults |
| +from pylib.base.base_test_result import TestType |
| from pylib.perf_tests_helper import PrintPerfResult |
| @@ -123,13 +125,11 @@ class TestPackage(object): |
| def _WatchTestOutput(self, p): |
| """Watches the test output. |
| + |
| Args: |
| p: the process generating output as created by pexpect.spawn. |
| """ |
| - ok_tests = [] |
| - failed_tests = [] |
| - crashed_tests = [] |
| - timed_out_tests = [] |
| + results = TestRunResults() |
| # Test case statuses. |
| re_run = re.compile('\[ RUN \] ?(.*)\r\n') |
| @@ -146,7 +146,6 @@ class TestPackage(object): |
| try: |
| while True: |
| full_test_name = None |
| - |
| found = p.expect([re_run, re_passed, re_runner_fail], |
| timeout=self.timeout) |
| if found == 1: # re_passed |
| @@ -158,12 +157,15 @@ class TestPackage(object): |
| found = p.expect([re_ok, re_fail, re_crash], timeout=self.timeout) |
| if found == 0: # re_ok |
| if full_test_name == p.match.group(1).replace('\r', ''): |
| - ok_tests += [BaseTestResult(full_test_name, p.before)] |
| + results.AddResult(BaseTestResult( |
| + full_test_name, TestType.PASS, log=p.before)) |
| elif found == 2: # re_crash |
| - crashed_tests += [BaseTestResult(full_test_name, p.before)] |
| + results.AddResult(BaseTestResult( |
| + full_test_name, TestType.CRASH, log=p.before)) |
| break |
| else: # re_fail |
| - failed_tests += [BaseTestResult(full_test_name, p.before)] |
| + results.AddResult(BaseTestResult( |
| + full_test_name, TestType.FAIL, log=p.before)) |
| except pexpect.EOF: |
| logging.error('Test terminated - EOF') |
| # We're here because either the device went offline, or the test harness |
| @@ -172,12 +174,14 @@ class TestPackage(object): |
| raise errors.DeviceUnresponsiveError('Device %s went offline.' % |
| self.device) |
| elif full_test_name: |
| - crashed_tests += [BaseTestResult(full_test_name, p.before)] |
| + results.AddResult( |
| + BaseTestResult(full_test_name, TestType.CRASH, log=p.before)) |
| except pexpect.TIMEOUT: |
| logging.error('Test terminated after %d second timeout.', |
| self.timeout) |
| if full_test_name: |
| - timed_out_tests += [BaseTestResult(full_test_name, p.before)] |
| + results.AddResult( |
| + BaseTestResult(full_test_name, TestType.TIMEOUT, log=p.before)) |
| finally: |
| p.close() |
| @@ -187,6 +191,4 @@ class TestPackage(object): |
| 'gtest exit code: %d\npexpect.before: %s\npexpect.after: %s', |
| ret_code, p.before, p.after) |
| - # Create TestResults and return |
| - return TestResults.FromRun(ok=ok_tests, failed=failed_tests, |
| - crashed=crashed_tests, timed_out=timed_out_tests) |
| + return results |