| 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 """Generates test runner factory and tests for instrumentation tests.""" | 5 """Generates test runner factory and tests for instrumentation tests.""" |
| 6 | 6 |
| 7 import logging | 7 import logging |
| 8 import os |
| 8 | 9 |
| 9 import test_package | 10 import test_package |
| 10 import test_runner | 11 import test_runner |
| 11 | 12 |
| 12 | 13 |
| 13 def Setup(test_options): | 14 def Setup(test_options): |
| 14 """Create and return the test runner factory and tests. | 15 """Create and return the test runner factory and tests. |
| 15 | 16 |
| 16 Args: | 17 Args: |
| 17 test_options: An InstrumentationOptions object. | 18 test_options: An InstrumentationOptions object. |
| 18 | 19 |
| 19 Returns: | 20 Returns: |
| 20 A tuple of (TestRunnerFactory, tests). | 21 A tuple of (TestRunnerFactory, tests). |
| 21 """ | 22 """ |
| 23 if (test_options.coverage_dir and not |
| 24 os.path.exists(test_options.coverage_dir)): |
| 25 os.makedirs(test_options.coverage_dir) |
| 26 |
| 22 test_pkg = test_package.TestPackage(test_options.test_apk_path, | 27 test_pkg = test_package.TestPackage(test_options.test_apk_path, |
| 23 test_options.test_apk_jar_path) | 28 test_options.test_apk_jar_path) |
| 24 tests = test_pkg._GetAllMatchingTests( | 29 tests = test_pkg._GetAllMatchingTests( |
| 25 test_options.annotations, | 30 test_options.annotations, |
| 26 test_options.exclude_annotations, | 31 test_options.exclude_annotations, |
| 27 test_options.test_filter) | 32 test_options.test_filter) |
| 28 if not tests: | 33 if not tests: |
| 29 logging.error('No instrumentation tests to run with current args.') | 34 logging.error('No instrumentation tests to run with current args.') |
| 30 | 35 |
| 31 def TestRunnerFactory(device, shard_index): | 36 def TestRunnerFactory(device, shard_index): |
| 32 return test_runner.TestRunner(test_options, device, shard_index, | 37 return test_runner.TestRunner(test_options, device, shard_index, |
| 33 test_pkg, []) | 38 test_pkg, []) |
| 34 | 39 |
| 35 return (TestRunnerFactory, tests) | 40 return (TestRunnerFactory, tests) |
| OLD | NEW |