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

Unified Diff: build/android/pylib/instrumentation/instrumentation_test_instance.py

Issue 951673002: Revert "Pull chromium at 2c3ffb2355a27c32f45e508ef861416b820c823b" (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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/instrumentation/instrumentation_test_instance.py
diff --git a/build/android/pylib/instrumentation/instrumentation_test_instance.py b/build/android/pylib/instrumentation/instrumentation_test_instance.py
index 3f56e6d99f90007caf457e5eb3fde6b608afbecf..45e6ee4d77aed7c27ddd9eb082a93901aad2ff1a 100644
--- a/build/android/pylib/instrumentation/instrumentation_test_instance.py
+++ b/build/android/pylib/instrumentation/instrumentation_test_instance.py
@@ -23,10 +23,6 @@ sys.path.append(
os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib', 'common'))
import unittest_util
-# Ref: http://developer.android.com/reference/android/app/Activity.html
-_ACTIVITY_RESULT_CANCELED = 0
-_ACTIVITY_RESULT_OK = -1
-
_DEFAULT_ANNOTATIONS = [
'Smoke', 'SmallTest', 'MediumTest', 'LargeTest',
'EnormousTest', 'IntegrationTest']
@@ -58,69 +54,48 @@ def ParseAmInstrumentRawOutput(raw_output):
return (code, bundle, statuses)
-def GenerateTestResults(
- result_code, result_bundle, statuses, start_ms, duration_ms):
- """Generate test results from |statuses|.
+def GenerateTestResult(test_name, instr_statuses, start_ms, duration_ms):
+ """Generate the result of |test| from |instr_statuses|.
Args:
- result_code: The overall status code as an integer.
- result_bundle: The summary bundle dump as a dict.
- statuses: A list of 2-tuples containing:
+ test_name: The name of the test as "class#method"
+ instr_statuses: A list of 2-tuples containing:
- the status code as an integer
- the bundle dump as a dict mapping string keys to string values
Note that this is the same as the third item in the 3-tuple returned by
|_ParseAmInstrumentRawOutput|.
start_ms: The start time of the test in milliseconds.
duration_ms: The duration of the test in milliseconds.
-
Returns:
- A list containing an instance of InstrumentationTestResult for each test
- parsed.
+ An InstrumentationTestResult object.
"""
+ log = ''
+ result_type = base_test_result.ResultType.UNKNOWN
- results = []
-
- current_result = None
-
- for status_code, bundle in statuses:
- test_class = bundle.get('class', '')
- test_method = bundle.get('test', '')
- if test_class and test_method:
- test_name = '%s#%s' % (test_class, test_method)
- else:
- continue
-
+ for status_code, bundle in instr_statuses:
if status_code == instrumentation_parser.STATUS_CODE_START:
- if current_result:
- results.append(current_result)
- current_result = test_result.InstrumentationTestResult(
- test_name, base_test_result.ResultType.UNKNOWN, start_ms, duration_ms)
+ pass
+ elif status_code == instrumentation_parser.STATUS_CODE_OK:
+ bundle_test = '%s#%s' % (bundle.get('class', ''), bundle.get('test', ''))
+ skipped = bundle.get('test_skipped', '')
+
+ if (test_name == bundle_test and
+ result_type == base_test_result.ResultType.UNKNOWN):
+ result_type = base_test_result.ResultType.PASS
+ elif skipped.lower() in ('true', '1', 'yes'):
+ result_type = base_test_result.ResultType.SKIP
+ logging.info('Skipped ' + test_name)
else:
- if status_code == instrumentation_parser.STATUS_CODE_OK:
- if bundle.get('test_skipped', '').lower() in ('true', '1', 'yes'):
- current_result.SetType(base_test_result.ResultType.SKIP)
- elif current_result.GetType() == base_test_result.ResultType.UNKNOWN:
- current_result.SetType(base_test_result.ResultType.PASS)
- else:
- if status_code not in (instrumentation_parser.STATUS_CODE_ERROR,
- instrumentation_parser.STATUS_CODE_FAILURE):
- logging.error('Unrecognized status code %d. Handling as an error.',
- status_code)
- current_result.SetType(base_test_result.ResultType.FAIL)
- if 'stack' in bundle:
- current_result.SetLog(bundle['stack'])
-
- if current_result:
- if current_result.GetType() == base_test_result.ResultType.UNKNOWN:
- crashed = (result_code == _ACTIVITY_RESULT_CANCELED
- and any(_NATIVE_CRASH_RE.search(l)
- for l in result_bundle.itervalues()))
- if crashed:
- current_result.SetType(base_test_result.ResultType.CRASH)
-
- results.append(current_result)
+ if status_code not in (instrumentation_parser.STATUS_CODE_ERROR,
+ instrumentation_parser.STATUS_CODE_FAILURE):
+ logging.error('Unrecognized status code %d. Handling as an error.',
+ status_code)
+ result_type = base_test_result.ResultType.FAIL
+ if 'stack' in bundle:
+ log = bundle['stack']
- return results
+ return test_result.InstrumentationTestResult(
+ test_name, result_type, start_ms, duration_ms, log=log)
class InstrumentationTestInstance(test_instance.TestInstance):
@@ -446,14 +421,37 @@ class InstrumentationTestInstance(test_instance.TestInstance):
return inflated_tests
@staticmethod
+ def GenerateMultiTestResult(errors, statuses):
+ results = []
+ skip_counter = 1
+ for status_code, bundle in statuses:
+ if status_code != instrumentation_parser.STATUS_CODE_START:
+ # TODO(rnephew): Make skipped tests still output test name. This is only
+ # there to give skipped tests a unique name so they are counted
+ if 'test_skipped' in bundle:
+ test_name = str(skip_counter)
+ skip_counter += 1
+ else:
+ test_name = '%s#%s' % (bundle.get('class', ''),
+ bundle.get('test', ''))
+
+ results.append(
+ GenerateTestResult(test_name, [(status_code, bundle)], 0, 0))
+ for error in errors.itervalues():
+ if _NATIVE_CRASH_RE.search(error):
+ results.append(
+ base_test_result.BaseTestResult(
+ 'Crash detected', base_test_result.ResultType.CRASH))
+
+ return results
+
+ @staticmethod
def ParseAmInstrumentRawOutput(raw_output):
return ParseAmInstrumentRawOutput(raw_output)
@staticmethod
- def GenerateTestResults(
- result_code, result_bundle, statuses, start_ms, duration_ms):
- return GenerateTestResults(result_code, result_bundle, statuses,
- start_ms, duration_ms)
+ def GenerateTestResult(test_name, instr_statuses, start_ms, duration_ms):
+ return GenerateTestResult(test_name, instr_statuses, start_ms, duration_ms)
#override
def TearDown(self):

Powered by Google App Engine
This is Rietveld 408576698