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

Side by Side Diff: build/android/pylib/host_driven/run_python_tests.py

Issue 15942016: Creates a new test running script test_runner.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Several more fixes Created 7 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 """Runs the Python tests (relies on using the Java test runner).""" 5 """Runs the Python tests (relies on using the Java test runner)."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 import sys 9 import sys
10 import types 10 import types
11 11
12 from pylib import android_commands 12 from pylib import android_commands
13 from pylib import constants 13 from pylib import constants
14 from pylib.base import base_test_result 14 from pylib.base import base_test_result
15 from pylib.instrumentation import test_package 15 from pylib.instrumentation import test_package
16 from pylib.instrumentation import test_runner 16 from pylib.instrumentation import test_runner
17 from pylib.utils import report_results
17 18
18 import python_test_base 19 import python_test_base
19 from python_test_caller import CallPythonTest 20 from python_test_caller import CallPythonTest
20 from python_test_sharder import PythonTestSharder 21 from python_test_sharder import PythonTestSharder
21 from test_info_collection import TestInfoCollection 22 from test_info_collection import TestInfoCollection
22 23
23 24
24 def _GetPythonFiles(root, files): 25 def _GetPythonFiles(root, files):
25 """Returns all files from |files| that end in 'Test.py'. 26 """Returns all files from |files| that end in 'Test.py'.
26 27
(...skipping 27 matching lines...) Expand all
54 Args: 55 Args:
55 options: command line options. 56 options: command line options.
56 57
57 Returns: 58 Returns:
58 A list of test results. 59 A list of test results.
59 """ 60 """
60 61
61 attached_devices = android_commands.GetAttachedDevices() 62 attached_devices = android_commands.GetAttachedDevices()
62 if not attached_devices: 63 if not attached_devices:
63 raise Exception('You have no devices attached or visible!') 64 raise Exception('You have no devices attached or visible!')
64 if options.device: 65 if options.test_device:
65 attached_devices = [options.device] 66 attached_devices = [options.test_device]
66 67
67 test_collection = TestInfoCollection() 68 test_collection = TestInfoCollection()
68 all_tests = _GetAllTests(options.python_test_root, options.official_build) 69 all_tests = _GetAllTests(options.python_test_root, options.official_build)
69 test_collection.AddTests(all_tests) 70 test_collection.AddTests(all_tests)
70 test_names = [t.qualified_name for t in all_tests] 71 test_names = [t.qualified_name for t in all_tests]
71 logging.debug('All available tests: ' + str(test_names)) 72 logging.debug('All available tests: ' + str(test_names))
72 73
73 available_tests = test_collection.GetAvailableTests( 74 available_tests = test_collection.GetAvailableTests(
74 options.annotations, options.exclude_annotations, options.test_filter) 75 options.annotations, options.exclude_annotations, options.test_filter)
75 76
(...skipping 18 matching lines...) Expand all
94 logging.warning('Debugger can not be sharded, ' 95 logging.warning('Debugger can not be sharded, '
95 'using first available device') 96 'using first available device')
96 attached_devices = attached_devices[:1] 97 attached_devices = attached_devices[:1]
97 logging.debug('Running Python tests') 98 logging.debug('Running Python tests')
98 sharder = PythonTestSharder(attached_devices, available_tests, options) 99 sharder = PythonTestSharder(attached_devices, available_tests, options)
99 test_results = sharder.RunShardedTests() 100 test_results = sharder.RunShardedTests()
100 101
101 return test_results 102 return test_results
102 103
103 104
105 def Dispatch(options):
106 """Wraps DispatchPythonTests to log and return the number of failed tests."""
107
108 results = DispatchPythonTests(options)
109 report_results.LogFull(
110 results=results,
111 test_type='HostDriven',
112 test_package=os.path.basename(options.test_apk),
113 annotation=options.annotations,
114 build_type=options.build_type,
115 flakiness_server=options.flakiness_dashboard_server)
frankf 2013/06/13 23:17:48 Verify this works
gkanwar 2013/06/17 21:04:43 Done.
116 return len(results.GetNotPass())
117
118
104 def _GetTestModules(python_test_root, is_official_build): 119 def _GetTestModules(python_test_root, is_official_build):
105 """Retrieve a sorted list of pythonDrivenTests. 120 """Retrieve a sorted list of pythonDrivenTests.
106 121
107 Walks the location of pythonDrivenTests, imports them, and provides the list 122 Walks the location of pythonDrivenTests, imports them, and provides the list
108 of imported modules to the caller. 123 of imported modules to the caller.
109 124
110 Args: 125 Args:
111 python_test_root: the path to walk, looking for pythonDrivenTests 126 python_test_root: the path to walk, looking for pythonDrivenTests
112 is_official_build: whether to run only those tests marked 'official' 127 is_official_build: whether to run only those tests marked 'official'
113 128
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 Returns: 213 Returns:
199 List of test case objects for all available test methods. 214 List of test case objects for all available test methods.
200 """ 215 """
201 if not test_root: 216 if not test_root:
202 return [] 217 return []
203 all_tests = [] 218 all_tests = []
204 test_module_list = _GetTestModules(test_root, is_official_build) 219 test_module_list = _GetTestModules(test_root, is_official_build)
205 for module in test_module_list: 220 for module in test_module_list:
206 all_tests.extend(_GetTestClassesFromModule(module)) 221 all_tests.extend(_GetTestClassesFromModule(module))
207 return all_tests 222 return all_tests
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698