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

Side by Side Diff: build/android/pylib/remote/device/remote_device_gtest_run.py

Issue 1315743004: [Android] Add a custom pylintrc for build/android/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix appurify_sanitized import-errors Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Run specific test on specific environment.""" 5 """Run specific test on specific environment."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 import tempfile 9 import tempfile
10 10
11 from pylib import constants 11 from pylib import constants
12 from pylib.base import base_test_result 12 from pylib.base import base_test_result
13 from pylib.remote.device import remote_device_test_run 13 from pylib.remote.device import remote_device_test_run
14 from pylib.remote.device import remote_device_helper
15 14
16 15
17 _EXTRA_COMMAND_LINE_FILE = ( 16 _EXTRA_COMMAND_LINE_FILE = (
18 'org.chromium.native_test.NativeTestActivity.CommandLineFile') 17 'org.chromium.native_test.NativeTestActivity.CommandLineFile')
19 18
20 19
21 class RemoteDeviceGtestTestRun(remote_device_test_run.RemoteDeviceTestRun): 20 class RemoteDeviceGtestTestRun(remote_device_test_run.RemoteDeviceTestRun):
22 """Run gtests and uirobot tests on a remote device.""" 21 """Run gtests and uirobot tests on a remote device."""
23 22
24 DEFAULT_RUNNER_PACKAGE = ( 23 DEFAULT_RUNNER_PACKAGE = (
(...skipping 14 matching lines...) Expand all
39 38
40 if not self._env.runner_package: 39 if not self._env.runner_package:
41 runner_package = self.DEFAULT_RUNNER_PACKAGE 40 runner_package = self.DEFAULT_RUNNER_PACKAGE
42 logging.info('Using default runner package: %s', 41 logging.info('Using default runner package: %s',
43 self.DEFAULT_RUNNER_PACKAGE) 42 self.DEFAULT_RUNNER_PACKAGE)
44 else: 43 else:
45 runner_package = self._env.runner_package 44 runner_package = self._env.runner_package
46 45
47 dummy_app_path = os.path.join( 46 dummy_app_path = os.path.join(
48 constants.GetOutDirectory(), 'apks', 'remote_device_dummy.apk') 47 constants.GetOutDirectory(), 'apks', 'remote_device_dummy.apk')
48
49 # pylint: disable=protected-access
49 with tempfile.NamedTemporaryFile(suffix='.flags.txt') as flag_file: 50 with tempfile.NamedTemporaryFile(suffix='.flags.txt') as flag_file:
50 env_vars = {} 51 env_vars = {}
51 filter_string = self._test_instance._GenerateDisabledFilterString(None) 52 filter_string = self._test_instance._GenerateDisabledFilterString(None)
52 if filter_string: 53 if filter_string:
53 flag_file.write('_ --gtest_filter=%s' % filter_string) 54 flag_file.write('_ --gtest_filter=%s' % filter_string)
54 flag_file.flush() 55 flag_file.flush()
55 env_vars[_EXTRA_COMMAND_LINE_FILE] = os.path.basename(flag_file.name) 56 env_vars[_EXTRA_COMMAND_LINE_FILE] = os.path.basename(flag_file.name)
56 self._test_instance._data_deps.append( 57 self._test_instance._data_deps.append(
57 (os.path.abspath(flag_file.name), None)) 58 (os.path.abspath(flag_file.name), None))
58 self._AmInstrumentTestSetup( 59 self._AmInstrumentTestSetup(
59 dummy_app_path, self._test_instance.apk, runner_package, 60 dummy_app_path, self._test_instance.apk, runner_package,
60 environment_variables=env_vars) 61 environment_variables=env_vars)
61 62
62 _INSTRUMENTATION_STREAM_LEADER = 'INSTRUMENTATION_STATUS: stream=' 63 _INSTRUMENTATION_STREAM_LEADER = 'INSTRUMENTATION_STATUS: stream='
63 64
64 #override 65 #override
65 def _ParseTestResults(self): 66 def _ParseTestResults(self):
66 logging.info('Parsing results from stdout.') 67 logging.info('Parsing results from stdout.')
67 results = base_test_result.TestRunResults() 68 results = base_test_result.TestRunResults()
68 output = self._results['results']['output'].splitlines() 69 output = self._results['results']['output'].splitlines()
69 output = (l[len(self._INSTRUMENTATION_STREAM_LEADER):] for l in output 70 output = (l[len(self._INSTRUMENTATION_STREAM_LEADER):] for l in output
70 if l.startswith(self._INSTRUMENTATION_STREAM_LEADER)) 71 if l.startswith(self._INSTRUMENTATION_STREAM_LEADER))
71 results_list = self._test_instance.ParseGTestOutput(output) 72 results_list = self._test_instance.ParseGTestOutput(output)
72 results.AddResults(results_list) 73 results.AddResults(results_list)
73 if self._env.only_output_failures: 74 if self._env.only_output_failures:
74 logging.info('See logcat for more results information.') 75 logging.info('See logcat for more results information.')
75 76
76 self._DetectPlatformErrors(results) 77 self._DetectPlatformErrors(results)
77 return results 78 return results
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698