OLD | NEW |
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 """Dispatches tests, either sharding or replicating them. | 5 """Dispatches tests, either sharding or replicating them. |
6 | 6 |
7 To dispatch, performs the following steps: | 7 To dispatch, performs the following steps: |
8 * Create a test collection factory, using the given tests | 8 * Create a test collection factory, using the given tests |
9 - If sharding: test collection factory returns the same shared test collection | 9 - If sharding: test collection factory returns the same shared test collection |
10 to all test runners | 10 to all test runners |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 328 |
329 if len(attached_devices) > 1 and wait_for_debugger: | 329 if len(attached_devices) > 1 and wait_for_debugger: |
330 logging.warning('Debugger can not be sharded, using first available device') | 330 logging.warning('Debugger can not be sharded, using first available device') |
331 attached_devices = attached_devices[:1] | 331 attached_devices = attached_devices[:1] |
332 | 332 |
333 return attached_devices | 333 return attached_devices |
334 | 334 |
335 | 335 |
336 def RunTests(tests, runner_factory, wait_for_debugger, test_device, | 336 def RunTests(tests, runner_factory, wait_for_debugger, test_device, |
337 shard=True, | 337 shard=True, |
338 build_type='Debug', | |
339 test_timeout=DEFAULT_TIMEOUT, | 338 test_timeout=DEFAULT_TIMEOUT, |
340 setup_timeout=DEFAULT_TIMEOUT, | 339 setup_timeout=DEFAULT_TIMEOUT, |
341 num_retries=2): | 340 num_retries=2): |
342 """Run all tests on attached devices, retrying tests that don't pass. | 341 """Run all tests on attached devices, retrying tests that don't pass. |
343 | 342 |
344 Args: | 343 Args: |
345 tests: List of tests to run. | 344 tests: List of tests to run. |
346 runner_factory: Callable that takes a device and index and returns a | 345 runner_factory: Callable that takes a device and index and returns a |
347 TestRunner object. | 346 TestRunner object. |
348 wait_for_debugger: True if this test is using a debugger. | 347 wait_for_debugger: True if this test is using a debugger. |
349 test_device: A specific device to run tests on, or None. | 348 test_device: A specific device to run tests on, or None. |
350 shard: True if we should shard, False if we should replicate tests. | 349 shard: True if we should shard, False if we should replicate tests. |
351 - Sharding tests will distribute tests across all test runners through a | 350 - Sharding tests will distribute tests across all test runners through a |
352 shared test collection. | 351 shared test collection. |
353 - Replicating tests will copy all tests to each test runner through a | 352 - Replicating tests will copy all tests to each test runner through a |
354 unique test collection for each test runner. | 353 unique test collection for each test runner. |
355 build_type: Either 'Debug' or 'Release'. | |
356 test_timeout: Watchdog timeout in seconds for running tests. | 354 test_timeout: Watchdog timeout in seconds for running tests. |
357 setup_timeout: Watchdog timeout in seconds for creating and cleaning up | 355 setup_timeout: Watchdog timeout in seconds for creating and cleaning up |
358 test runners. | 356 test runners. |
359 num_retries: Number of retries for a test. | 357 num_retries: Number of retries for a test. |
360 | 358 |
361 Returns: | 359 Returns: |
362 A tuple of (base_test_result.TestRunResults object, exit code). | 360 A tuple of (base_test_result.TestRunResults object, exit code). |
363 """ | 361 """ |
364 if not tests: | 362 if not tests: |
365 logging.error('No tests to run.') | 363 logging.error('No tests to run.') |
(...skipping 18 matching lines...) Expand all Loading... |
384 logging.info('Will run %d tests (%s): %s', len(tests), log_string, str(tests)) | 382 logging.info('Will run %d tests (%s): %s', len(tests), log_string, str(tests)) |
385 runners = _CreateRunners(runner_factory, devices, setup_timeout) | 383 runners = _CreateRunners(runner_factory, devices, setup_timeout) |
386 try: | 384 try: |
387 return _RunAllTests(runners, test_collection_factory, | 385 return _RunAllTests(runners, test_collection_factory, |
388 num_retries, test_timeout, tag_results_with_device) | 386 num_retries, test_timeout, tag_results_with_device) |
389 finally: | 387 finally: |
390 try: | 388 try: |
391 _TearDownRunners(runners, setup_timeout) | 389 _TearDownRunners(runners, setup_timeout) |
392 except android_commands.errors.DeviceUnresponsiveError as e: | 390 except android_commands.errors.DeviceUnresponsiveError as e: |
393 logging.warning('Device unresponsive during TearDown: [%s]', e) | 391 logging.warning('Device unresponsive during TearDown: [%s]', e) |
OLD | NEW |