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) _GenerateDepsDirUsingIsolate(test_options.suite_name, test_options.isolate_file_path) 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)
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)