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