• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3# found in the LICENSE file.
4
5"""Generates test runner factory and tests for instrumentation tests."""
6
7import logging
8import os
9
10from pylib.instrumentation import test_package
11from pylib.instrumentation import test_runner
12
13
14def Setup(test_options):
15  """Create and return the test runner factory and tests.
16
17  Args:
18    test_options: An InstrumentationOptions object.
19
20  Returns:
21    A tuple of (TestRunnerFactory, tests).
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
27  test_pkg = test_package.TestPackage(test_options.test_apk_path,
28                                      test_options.test_apk_jar_path,
29                                      test_options.test_support_apk_path)
30  tests = test_pkg.GetAllMatchingTests(
31      test_options.annotations,
32      test_options.exclude_annotations,
33      test_options.test_filter)
34  if not tests:
35    logging.error('No instrumentation tests to run with current args.')
36
37  def TestRunnerFactory(device, shard_index):
38    return test_runner.TestRunner(test_options, device, shard_index,
39                                  test_pkg)
40
41  return (TestRunnerFactory, tests)
42