def Setup(test_options, devices): """Create and return the test runner factory and tests. Args: test_options: An InstrumentationOptions object. Returns: A tuple of (TestRunnerFactory, tests). """ if (test_options.coverage_dir and not os.path.exists(test_options.coverage_dir)): os.makedirs(test_options.coverage_dir) test_pkg = test_package.TestPackage( test_options.test_apk_path, test_options.test_apk_jar_path, test_options.test_support_apk_path, additional_apks=test_options.additional_apks, apk_under_test=test_options.apk_under_test, test_apk_incremental_install_script=test_options. test_apk_incremental_install_script, apk_under_test_incremental_install_script=test_options. apk_under_test_incremental_install_script) tests = test_pkg.GetAllMatchingTests(test_options.annotations, test_options.exclude_annotations, test_options.test_filter, devices) if not tests: logging.error('No instrumentation tests to run with current args.') if test_options.test_data: device_utils.DeviceUtils.parallel(devices).pMap( _PushDataDeps, test_options) if test_options.isolate_file_path: isolator = base_setup.GenerateDepsDirUsingIsolate( test_options.test_apk, test_options.isolate_file_path, ISOLATE_FILE_PATHS, DEPS_EXCLUSION_LIST) def push_data_deps_to_device_dir(device): base_setup.PushDataDeps(device, isolator.isolate_deps_dir, device.GetExternalStoragePath(), test_options) device_utils.DeviceUtils.parallel(devices).pMap( push_data_deps_to_device_dir) if isolator: isolator.Clear() device_utils.DeviceUtils.parallel(devices).pMap(_PushExtraSuiteDataDeps, test_options.test_apk) def TestRunnerFactory(device, shard_index): return test_runner.TestRunner(test_options, device, shard_index, test_pkg) return (TestRunnerFactory, tests)
def Setup(test_options, devices): """Create the test runner factory and tests. Args: test_options: A GTestOptions object. devices: A list of attached devices. Returns: A tuple of (TestRunnerFactory, tests). """ test_package = test_package_apk.TestPackageApk(test_options.suite_name) if not os.path.exists(test_package.suite_path): exe_test_package = test_package_exe.TestPackageExecutable( test_options.suite_name) if not os.path.exists(exe_test_package.suite_path): raise Exception( 'Did not find %s target. Ensure it has been built.\n' '(not found at %s or %s)' % (test_options.suite_name, test_package.suite_path, exe_test_package.suite_path)) test_package = exe_test_package logging.warning('Found target %s', test_package.suite_path) base_setup.GenerateDepsDirUsingIsolate(test_options.suite_name, test_options.isolate_file_path, ISOLATE_FILE_PATHS, DEPS_EXCLUSION_LIST) def push_data_deps_to_device_dir(device): device_dir = (constants.TEST_EXECUTABLE_DIR if test_package.suite_name == 'breakpad_unittests' else device.GetExternalStoragePath()) base_setup.PushDataDeps(device, device_dir, test_options) device_utils.DeviceUtils.parallel(devices).pMap(push_data_deps_to_device_dir) tests = _GetTests(test_options, test_package, devices) # Constructs a new TestRunner with the current options. def TestRunnerFactory(device, _shard_index): return test_runner.TestRunner( test_options, device, test_package) if test_options.run_disabled: test_options = test_options._replace( test_arguments=('%s --gtest_also_run_disabled_tests' % test_options.test_arguments)) else: tests = _FilterDisabledTests(tests, test_options.suite_name, bool(test_options.gtest_filter)) if test_options.gtest_filter: tests = unittest_util.FilterTestNames(tests, test_options.gtest_filter) # Coalesce unit tests into a single test per device if test_options.suite_name != 'content_browsertests': num_devices = len(devices) tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] tests = [t for t in tests if t] return (TestRunnerFactory, tests)