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