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

Unified Diff: build/android/pylib/gtest/test_package.py

Issue 12544033: [Android] Rewrite base test result classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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
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..a3a17b233237d84ab9ef8a1a5830533e5d4b2c65 100644
--- a/build/android/pylib/gtest/test_package.py
+++ b/build/android/pylib/gtest/test_package.py
@@ -4,13 +4,13 @@
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 import base_test_result
from pylib.perf_tests_helper import PrintPerfResult
@@ -123,13 +123,14 @@ class TestPackage(object):
def _WatchTestOutput(self, p):
"""Watches the test output.
+
Args:
p: the process generating output as created by pexpect.spawn.
+
+ Returns:
+ A TestRunResults object.
"""
- ok_tests = []
- failed_tests = []
- crashed_tests = []
- timed_out_tests = []
+ results = base_test_result.TestRunResults()
# Test case statuses.
re_run = re.compile('\[ RUN \] ?(.*)\r\n')
@@ -146,7 +147,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 +158,17 @@ 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(base_test_result.BaseTestResult(
+ full_test_name, base_test_result.ResultType.PASS,
+ log=p.before))
elif found == 2: # re_crash
- crashed_tests += [BaseTestResult(full_test_name, p.before)]
+ results.AddResult(base_test_result.BaseTestResult(
+ full_test_name, base_test_result.ResultType.CRASH,
+ log=p.before))
break
else: # re_fail
- failed_tests += [BaseTestResult(full_test_name, p.before)]
+ results.AddResult(base_test_result.BaseTestResult(
+ full_test_name, base_test_result.ResultType.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
@@ -171,13 +176,15 @@ class TestPackage(object):
if not self.adb.IsOnline():
raise errors.DeviceUnresponsiveError('Device %s went offline.' %
self.device)
- elif full_test_name:
- crashed_tests += [BaseTestResult(full_test_name, p.before)]
+ if full_test_name:
+ results.AddResult(base_test_result.BaseTestResult(
+ full_test_name, base_test_result.ResultType.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(base_test_result.BaseTestResult(
+ full_test_name, base_test_result.ResultType.TIMEOUT, log=p.before))
finally:
p.close()
@@ -187,6 +194,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

Powered by Google App Engine
This is Rietveld 408576698