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

Unified Diff: build/android/pylib/local/device/local_device_instrumentation_test_run.py

Issue 1414403002: Add CommandLineArgumentParameter and use it for WebView tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix-cr-526885-read-nested-annotations
Patch Set: One more test needs to be excluded Created 5 years, 1 month 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
« no previous file with comments | « build/android/pylib/instrumentation/test_runner.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/local/device/local_device_instrumentation_test_run.py
diff --git a/build/android/pylib/local/device/local_device_instrumentation_test_run.py b/build/android/pylib/local/device/local_device_instrumentation_test_run.py
index afae9abcc8acd6c3705a6438d2545c586ab73339..a36c65877f3512c41f0b7172af2368d218f957f0 100644
--- a/build/android/pylib/local/device/local_device_instrumentation_test_run.py
+++ b/build/android/pylib/local/device/local_device_instrumentation_test_run.py
@@ -85,8 +85,7 @@ class LocalDeviceInstrumentationTestRun(
elif not self._test_instance.package_info.cmdline_file:
logging.error("Couldn't set flags: no cmdline_file")
else:
- self._flag_changers[str(dev)] = flag_changer.FlagChanger(
- dev, self._test_instance.package_info.cmdline_file)
+ self._CreateFlagChangerIfNeeded(dev)
logging.debug('Attempting to set flags: %r',
self._test_instance.flags)
self._flag_changers[str(dev)].AddFlags(self._test_instance.flags)
@@ -102,6 +101,11 @@ class LocalDeviceInstrumentationTestRun(
self._env.parallel_devices.pMap(individual_device_tear_down)
+ def _CreateFlagChangerIfNeeded(self, device):
+ if not str(device) in self._flag_changers:
+ self._flag_changers[str(device)] = flag_changer.FlagChanger(
+ device, self._test_instance.package_info.cmdline_file)
+
#override
def _CreateShards(self, tests):
return tests
@@ -114,10 +118,20 @@ class LocalDeviceInstrumentationTestRun(
def _GetTestName(self, test):
return '%s#%s' % (test['class'], test['method'])
+ def _GetTestNameForDisplay(self, test):
+ display_name = self._GetTestName(test)
+ flags = test['flags']
+ if flags.add:
+ display_name = '%s with {%s}' % (display_name, ' '.join(flags.add))
+ if flags.remove:
+ display_name = '%s without {%s}' % (display_name, ' '.join(flags.remove))
+ return display_name
+
#override
def _RunTest(self, device, test):
extras = self._test_instance.GetHttpServerEnvironmentVars()
+ flags = None
if isinstance(test, list):
if not self._test_instance.driver_apk:
raise Exception('driver_apk does not exist. '
@@ -131,6 +145,7 @@ class LocalDeviceInstrumentationTestRun(
test_names, timeouts = zip(*(name_and_timeout(t) for t in test))
test_name = ','.join(test_names)
+ test_display_name = test_name
target = '%s/%s' % (
self._test_instance.driver_package,
self._test_instance.driver_name)
@@ -140,22 +155,36 @@ class LocalDeviceInstrumentationTestRun(
timeout = sum(timeouts)
else:
test_name = self._GetTestName(test)
+ test_display_name = test_name
target = '%s/%s' % (
self._test_instance.test_package, self._test_instance.test_runner)
extras['class'] = test_name
- timeout = self._GetTimeoutFromAnnotations(test['annotations'], test_name)
+ if 'flags' in test:
+ flags = test['flags']
+ test_display_name = self._GetTestNameForDisplay(test)
+ timeout = self._GetTimeoutFromAnnotations(
+ test['annotations'], test_display_name)
- logging.info('preparing to run %s: %s', test_name, test)
+ logging.info('preparing to run %s: %s', test_display_name, test)
- time_ms = lambda: int(time.time() * 1e3)
- start_ms = time_ms()
- output = device.StartInstrumentation(
- target, raw=True, extras=extras, timeout=timeout, retries=0)
- duration_ms = time_ms() - start_ms
+ if flags:
+ self._CreateFlagChangerIfNeeded(device)
+ self._flag_changers[str(device)].PushFlags(
+ add=flags.add, remove=flags.remove)
+
+ try:
+ time_ms = lambda: int(time.time() * 1e3)
+ start_ms = time_ms()
+ output = device.StartInstrumentation(
+ target, raw=True, extras=extras, timeout=timeout, retries=0)
+ duration_ms = time_ms() - start_ms
+ finally:
+ if flags:
+ self._flag_changers[str(device)].Restore()
# TODO(jbudorick): Make instrumentation tests output a JSON so this
# doesn't have to parse the output.
- logging.debug('output from %s:', test_name)
+ logging.debug('output from %s:', test_display_name)
for l in output:
logging.debug(' %s', l)
@@ -163,6 +192,10 @@ class LocalDeviceInstrumentationTestRun(
self._test_instance.ParseAmInstrumentRawOutput(output))
results = self._test_instance.GenerateTestResults(
result_code, result_bundle, statuses, start_ms, duration_ms)
+ if flags:
+ for r in results:
+ if r.GetName() == test_name:
+ r.SetName(test_display_name)
if DidPackageCrashOnDevice(self._test_instance.test_package, device):
for r in results:
if r.GetType() == base_test_result.ResultType.UNKNOWN:
« no previous file with comments | « build/android/pylib/instrumentation/test_runner.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698