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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 test_timeout: Watchdog timeout in seconds for running tests. | 357 test_timeout: Watchdog timeout in seconds for running tests. |
358 setup_timeout: Watchdog timeout in seconds for creating and cleaning up | 358 setup_timeout: Watchdog timeout in seconds for creating and cleaning up |
359 test runners. | 359 test runners. |
360 num_retries: Number of retries for a test. | 360 num_retries: Number of retries for a test. |
361 | 361 |
362 Returns: | 362 Returns: |
363 A tuple of (base_test_result.TestRunResults object, exit code). | 363 A tuple of (base_test_result.TestRunResults object, exit code). |
364 """ | 364 """ |
365 if not tests: | 365 if not tests: |
366 logging.error('No tests to run.') | 366 logging.error('No tests to run.') |
367 return (base_test_result.TestRunResults(), constants.ERROR_EXIT_CODE) | 367 return (base_test_result.TestRunResults(), 0) |
Yaron
2013/07/23 23:45:37
Sorry for not being specific. While I'm fine with
| |
368 | 368 |
369 if shard: | 369 if shard: |
370 # Generate a shared _TestCollection object for all test runners, so they | 370 # Generate a shared _TestCollection object for all test runners, so they |
371 # draw from a common pool of tests. | 371 # draw from a common pool of tests. |
372 shared_test_collection = _TestCollection([_Test(t) for t in tests]) | 372 shared_test_collection = _TestCollection([_Test(t) for t in tests]) |
373 test_collection_factory = lambda: shared_test_collection | 373 test_collection_factory = lambda: shared_test_collection |
374 tag_results_with_device = False | 374 tag_results_with_device = False |
375 else: | 375 else: |
376 # Generate a unique _TestCollection object for each test runner, but use | 376 # Generate a unique _TestCollection object for each test runner, but use |
377 # the same set of tests. | 377 # the same set of tests. |
378 test_collection_factory = lambda: _TestCollection([_Test(t) for t in tests]) | 378 test_collection_factory = lambda: _TestCollection([_Test(t) for t in tests]) |
379 tag_results_with_device = True | 379 tag_results_with_device = True |
380 | 380 |
381 devices = _GetAttachedDevices(wait_for_debugger, test_device) | 381 devices = _GetAttachedDevices(wait_for_debugger, test_device) |
382 | 382 |
383 logging.info('Will run %d tests: %s', len(tests), str(tests)) | 383 logging.info('Will run %d tests: %s', len(tests), str(tests)) |
384 forwarder.Forwarder.KillHost(build_type) | 384 forwarder.Forwarder.KillHost(build_type) |
385 runners = _CreateRunners(runner_factory, devices, setup_timeout) | 385 runners = _CreateRunners(runner_factory, devices, setup_timeout) |
386 try: | 386 try: |
387 return _RunAllTests(runners, test_collection_factory, | 387 return _RunAllTests(runners, test_collection_factory, |
388 num_retries, test_timeout, tag_results_with_device) | 388 num_retries, test_timeout, tag_results_with_device) |
389 finally: | 389 finally: |
390 try: | 390 try: |
391 _TearDownRunners(runners, setup_timeout) | 391 _TearDownRunners(runners, setup_timeout) |
392 except android_commands.errors.DeviceUnresponsiveError as e: | 392 except android_commands.errors.DeviceUnresponsiveError as e: |
393 logging.warning('Device unresponsive during TearDown: [%s]', e) | 393 logging.warning('Device unresponsive during TearDown: [%s]', e) |
394 finally: | 394 finally: |
395 forwarder.Forwarder.KillHost(build_type) | 395 forwarder.Forwarder.KillHost(build_type) |
OLD | NEW |