Chromium Code Reviews| Index: build/android/pylib/remote/device/remote_device_instrumentation_test_run.py |
| diff --git a/build/android/pylib/remote/device/remote_device_instrumentation_test_run.py b/build/android/pylib/remote/device/remote_device_instrumentation_test_run.py |
| index 8858b069ce6fdd4bed80cdbef419f7a7e3f32e06..54869f863529e9b8b3dae0001fd8c5360c7b5fb7 100644 |
| --- a/build/android/pylib/remote/device/remote_device_instrumentation_test_run.py |
| +++ b/build/android/pylib/remote/device/remote_device_instrumentation_test_run.py |
| @@ -17,59 +17,82 @@ class RemoteDeviceInstrumentationTestRun( |
| """Run instrumentation tests on a remote device.""" |
| #override |
| - def TestPackage(self): |
| - return self._test_instance.test_package |
| + def _GetAdditionalApks(self): |
|
rnephew (Reviews Here)
2015/10/26 20:42:18
It looks like this is returning the test_apk as we
mikecase (-- gone --)
2015/10/27 01:27:43
Yeah, I don't like this either. So there is an --a
|
| + return [self._test_instance.test_apk] + self._test_instance.additional_apks |
| + |
| + #override |
| + def _GetAppPath(self): |
| + return self._test_instance.apk_under_test |
| + |
| + #override |
| + def _GetTestFramework(self): |
| + if self._env.test_framework: |
| + logging.warning('Ignoring configured test_framework "%s"', |
| + self._env.test_framework) |
| + return 'robotium' |
| + |
| + #override |
| + def _GetTestPath(self): |
| + return self._test_instance.driver_apk |
| + |
| + #override |
| + def _GetTestRunnerName(self): |
|
rnephew (Reviews Here)
2015/10/26 20:42:18
Is this used anywhere else than _GetFrameworkConfi
mikecase (-- gone --)
2015/10/27 01:27:43
Merged!
|
| + return self._test_instance.driver_name |
| + |
| + #override |
| + def _GetFrameworkConfigs(self): |
| + return {'runner': self._GetTestRunnerName()} |
| + # pylint: disable=protected-access |
|
rnephew (Reviews Here)
2015/10/26 20:42:18
Just an idea, feel free to ignore.
Instead of dis
mikecase (-- gone --)
2015/10/27 01:27:43
We decided offline to keep as is.
|
| #override |
| - def _TriggerSetUp(self): |
| - """Set up the triggering of a test run.""" |
| - logging.info('Triggering test run.') |
| - |
| - # pylint: disable=protected-access |
| - with tempfile.NamedTemporaryFile(suffix='.txt') as test_list_file: |
| - tests = self._test_instance.GetTests() |
| - logging.debug('preparing to run %d instrumentation tests remotely:', |
| - len(tests)) |
| + def _GetShardEnvironmentVars(self, num_shards): |
| + """Returns a list of shard specfic environment configs.""" |
| + all_tests = self._test_instance.GetTests() |
| + test_shards = [all_tests[i::num_shards] for i in range(num_shards)] |
| + |
| + shard_env_vars = [] |
| + for i, tests in enumerate(test_shards): |
| + test_list_file = tempfile.NamedTemporaryFile( |
|
jbudorick
2015/10/26 22:23:30
Again, not a huge fan of this. Restructure the cod
mikecase (-- gone --)
2015/10/27 01:27:43
Using a context manager is super awkward when you
|
| + suffix='.txt', dir=self._base_tempfile_dir, delete=False) |
| + self._test_instance._data_deps.append( |
| + (os.path.abspath(test_list_file.name), None)) |
| for t in tests: |
| test_name = '%s#%s' % (t['class'], t['method']) |
| - logging.debug(' %s', test_name) |
| + logging.debug('shard %s: %s', i, test_name) |
| test_list_file.write('%s\n' % test_name) |
| test_list_file.flush() |
| - self._test_instance._data_deps.append( |
| - (os.path.abspath(test_list_file.name), None)) |
| env_vars = self._test_instance.GetDriverEnvironmentVars( |
| test_list_file_path=test_list_file.name) |
| env_vars.update(self._test_instance.GetHttpServerEnvironmentVars()) |
| + shard_env_vars.append(env_vars) |
| - logging.debug('extras:') |
| - for k, v in env_vars.iteritems(): |
| - logging.debug(' %s: %s', k, v) |
| + return shard_env_vars |
| - self._AmInstrumentTestSetup( |
| - self._test_instance.apk_under_test, |
| - self._test_instance.driver_apk, |
| - self._test_instance.driver_name, |
| - environment_variables=env_vars, |
| - extra_apks=([self._test_instance.test_apk] + |
| - self._test_instance.additional_apks)) |
| + #override |
| + def _ShouldShard(self): |
| + return True |
| + |
| + #override |
| + def TestPackage(self): |
| + return self._test_instance.test_package |
| #override |
| - def _ParseTestResults(self): |
| + def _ParseTestResults(self, test_output, results_zip): |
| logging.info('Parsing results from stdout.') |
| - r = base_test_result.TestRunResults() |
| + results = base_test_result.TestRunResults() |
| result_code, result_bundle, statuses = ( |
| self._test_instance.ParseAmInstrumentRawOutput( |
| - self._results['results']['output'].splitlines())) |
| + test_output['results']['output'].splitlines())) |
| result = self._test_instance.GenerateTestResults( |
| result_code, result_bundle, statuses, 0, 0) |
| if isinstance(result, base_test_result.BaseTestResult): |
| - r.AddResult(result) |
| + results.AddResult(result) |
| elif isinstance(result, list): |
| - r.AddResults(result) |
| + results.AddResults(result) |
| else: |
| raise Exception('Unexpected result type: %s' % type(result).__name__) |
| - self._DetectPlatformErrors(r) |
| - return r |
| + self._DetectPlatformErrors(results, test_output, results_zip) |
| + return results |