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

Side by Side Diff: build/android/pylib/gtest/setup.py

Issue 21008004: Changes argument passing to use options objects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebases and fixes some issues Created 7 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 """Generates test runner factory and tests for GTests.""" 5 """Generates test runner factory and tests for GTests."""
6 6
7 import fnmatch 7 import fnmatch
8 import glob 8 import glob
9 import logging 9 import logging
10 import os 10 import os
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 tests, bool(gtest_filter), bool(gtest_filter)) 250 tests, bool(gtest_filter), bool(gtest_filter))
251 tests = unittest_util.FilterTestNames( 251 tests = unittest_util.FilterTestNames(
252 tests, _GetDisabledTestsFilterFromFile(suite_name)) 252 tests, _GetDisabledTestsFilterFromFile(suite_name))
253 253
254 if gtest_filter: 254 if gtest_filter:
255 tests = unittest_util.FilterTestNames(tests, gtest_filter) 255 tests = unittest_util.FilterTestNames(tests, gtest_filter)
256 256
257 return tests 257 return tests
258 258
259 259
260 def Setup(suite_name, test_arguments, timeout, 260 def Setup(test_options):
261 cleanup_test_files, tool, build_type, push_deps,
262 gtest_filter):
263 """Create the test runner factory and tests. 261 """Create the test runner factory and tests.
264 262
265 Args: 263 Args:
266 suite_name: The suite name specified on the command line. 264 test_options: A GTestOptions object containing all options relevant to
267 test_arguments: Additional arguments to pass to the test binary. 265 running gtests.
268 timeout: Timeout for each test.
269 cleanup_test_files: Whether or not to cleanup test files on device.
270 tool: Name of the Valgrind tool.
271 build_type: 'Release' or 'Debug'.
272 push_deps: If True, push all dependencies to the device.
273 gtest_filter: Filter for tests.
274 266
275 Returns: 267 Returns:
276 A tuple of (TestRunnerFactory, tests). 268 A tuple of (TestRunnerFactory, tests).
277 """ 269 """
278 270
271 suite_name = test_options.suite_name
272 build_type = test_options.build_type
273 gtest_filter = test_options.gtest_filter
274
279 if not ports.ResetTestServerPortAllocation(): 275 if not ports.ResetTestServerPortAllocation():
280 raise Exception('Failed to reset test server port.') 276 raise Exception('Failed to reset test server port.')
281 277
282 test_package = test_package_apk.TestPackageApk(suite_name, build_type) 278 test_package = test_package_apk.TestPackageApk(suite_name, build_type)
283 if not os.path.exists(test_package.suite_path): 279 if not os.path.exists(test_package.suite_path):
284 test_package = test_package_exe.TestPackageExecutable( 280 test_package = test_package_exe.TestPackageExecutable(
285 suite_name, build_type) 281 suite_name, build_type)
286 if not os.path.exists(test_package.suite_path): 282 if not os.path.exists(test_package.suite_path):
287 raise Exception( 283 raise Exception(
288 'Did not find %s target. Ensure it has been built.' % suite_name) 284 'Did not find %s target. Ensure it has been built.' % suite_name)
289 logging.warning('Found target %s', test_package.suite_path) 285 logging.warning('Found target %s', test_package.suite_path)
290 286
291 _GenerateDepsDirUsingIsolate(suite_name, build_type) 287 _GenerateDepsDirUsingIsolate(suite_name, build_type)
292 288
293 # Constructs a new TestRunner with the current options. 289 # Constructs a new TestRunner with the current options.
294 def TestRunnerFactory(device, shard_index): 290 def TestRunnerFactory(device, shard_index):
295 return test_runner.TestRunner( 291 return test_runner.TestRunner(
292 test_options,
296 device, 293 device,
297 test_package, 294 test_package)
298 test_arguments,
299 timeout,
300 cleanup_test_files,
301 tool,
302 build_type,
303 push_deps)
304 295
305 attached_devices = android_commands.GetAttachedDevices() 296 attached_devices = android_commands.GetAttachedDevices()
306 tests = _GetTestsFiltered(suite_name, gtest_filter, 297 tests = _GetTestsFiltered(suite_name, gtest_filter,
307 TestRunnerFactory, attached_devices) 298 TestRunnerFactory, attached_devices)
308 # Coalesce unit tests into a single test per device 299 # Coalesce unit tests into a single test per device
309 if suite_name != 'content_browsertests': 300 if suite_name != 'content_browsertests':
310 num_devices = len(attached_devices) 301 num_devices = len(attached_devices)
311 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] 302 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)]
312 tests = [t for t in tests if t] 303 tests = [t for t in tests if t]
313 304
314 return (TestRunnerFactory, tests) 305 return (TestRunnerFactory, tests)
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/gtest/test_runner.py » ('j') | build/android/pylib/instrumentation/test_runner.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698