Chromium Code Reviews| Index: build/android/pylib/browsertests/setup.py |
| diff --git a/build/android/pylib/browsertests/dispatch.py b/build/android/pylib/browsertests/setup.py |
| similarity index 44% |
| rename from build/android/pylib/browsertests/dispatch.py |
| rename to build/android/pylib/browsertests/setup.py |
| index dcd864882dca0e1c44d18e321c76c34bf62b13c7..d0570a022cfb7515435bc3b644098a762c11af59 100644 |
| --- a/build/android/pylib/browsertests/dispatch.py |
| +++ b/build/android/pylib/browsertests/setup.py |
| @@ -2,7 +2,7 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| -"""Dispatches content_browsertests.""" |
| +"""Generate test runner factory and tests for content_browsertests.""" |
| import logging |
| import os |
| @@ -14,8 +14,7 @@ from pylib import cmd_helper |
| from pylib import constants |
| from pylib import ports |
| from pylib.base import base_test_result |
| -from pylib.base import shard |
| -from pylib.gtest import dispatch as gtest_dispatch |
| +from pylib.gtest import setup as gtest_setup |
| from pylib.gtest import test_runner |
| from pylib.utils import report_results |
| @@ -24,85 +23,66 @@ sys.path.insert(0, |
| from common import unittest_util |
| -def Dispatch(options): |
| - """Dispatches all content_browsertests. |
| +def Setup(test_arguments, timeout, cleanup_test_files, tool, build_type, |
| + webkit, push_deps, gtest_filter): |
| + """Create the test runner factory and tests. |
| Args: |
| - options: optparse.Options object containing command-line options |
| + test_arguments: Additional arguments to pass to the test binary. |
| + timeout: Timeout for each test. |
| + cleanup_test_files: Whether or not to cleanup test files on device. |
| + tool: Name of the Valgrind tool. |
| + build_type: 'Release' or 'Debug'. |
| + webkit: Whether the suite is being run from a WebKit checkout. |
| + push_deps: If True, push all dependencies to the device. |
| + gtest_filter: filter for tests. |
| + |
| Returns: |
| - A tuple of (base_test_result.TestRunResults object, exit code). |
| - Raises: |
| - Exception: Failed to reset the test server port. |
| + A tuple of (TestRunnerFactory, tests). |
| """ |
| - attached_devices = [] |
| - if options.test_device: |
| - attached_devices = [options.test_device] |
| - else: |
| - attached_devices = android_commands.GetAttachedDevices() |
| - |
| - if not attached_devices: |
| - logging.critical('A device must be attached and online.') |
| - return (base_test_result.TestRunResults(), constants.ERROR_EXIT_CODE) |
| - |
| - # Reset the test port allocation. It's important to do it before starting |
| - # to dispatch any tests. |
| if not ports.ResetTestServerPortAllocation(): |
| raise Exception('Failed to reset test server port.') |
| - test_suite_dir = os.path.join(cmd_helper.OutDirectory.get(), |
| - options.build_type) |
| - options.test_suite = os.path.join(test_suite_dir, |
| - 'apks', |
| - constants.BROWSERTEST_SUITE_NAME + '.apk') |
| + suite_dir = os.path.join(cmd_helper.OutDirectory.get(), build_type) |
|
frankf
2013/07/17 21:08:41
Get rid of intermediate var
gkanwar
2013/07/17 21:16:50
Done.
|
| + suite_path = os.path.join(suite_dir, 'apks', |
| + constants.BROWSERTEST_SUITE_NAME + '.apk') |
| gtest_dispatch._GenerateDepsDirUsingIsolate( |
| constants.BROWSERTEST_SUITE_NAME, options.build_type) |
| # Constructs a new TestRunner with the current options. |
| - def RunnerFactory(device, shard_index): |
| + def TestRunnerFactory(device, shard_index): |
| return test_runner.TestRunner( |
| device, |
| - options.test_suite, |
| - options.test_arguments, |
| - options.timeout, |
| - options.cleanup_test_files, |
| - options.tool, |
| - options.build_type, |
| - options.webkit, |
| - options.push_deps, |
| + suite_path, |
| + test_arguments, |
| + timeout, |
| + cleanup_test_files, |
| + tool, |
| + build_type, |
| + webkit, |
| + push_deps, |
| constants.BROWSERTEST_TEST_PACKAGE_NAME, |
| constants.BROWSERTEST_TEST_ACTIVITY_NAME, |
| constants.BROWSERTEST_COMMAND_LINE_FILE) |
| + # TODO(gkanwar): This breaks the abstraction of having test_dispatcher.py deal |
| + # entirely with the devices. Can we do this another way? |
| + attached_devices = android_commands.GetAttachedDevices() |
| # Get tests and split them up based on the number of devices. |
| - all_enabled = gtest_dispatch.GetAllEnabledTests(RunnerFactory, |
| - attached_devices) |
| - if options.test_filter: |
| + all_enabled = gtest_setup.GetAllEnabledTests(TestRunnerFactory, |
| + attached_devices) |
| + if gtest_filter: |
| all_tests = unittest_util.FilterTestNames(all_enabled, |
| - options.test_filter) |
| + gtest_filter) |
| else: |
| all_tests = _FilterTests(all_enabled) |
| - # Run tests. |
| - # TODO(nileshagrawal): remove this abnormally long setup timeout once fewer |
| - # files are pushed to the devices for content_browsertests: crbug.com/138275 |
| - setup_timeout = 20 * 60 # 20 minutes |
| - test_results, exit_code = shard.ShardAndRunTests( |
| - RunnerFactory, attached_devices, all_tests, options.build_type, |
| - setup_timeout=setup_timeout, test_timeout=None, |
| - num_retries=options.num_retries) |
| - report_results.LogFull( |
| - results=test_results, |
| - test_type='Unit test', |
| - test_package=constants.BROWSERTEST_SUITE_NAME, |
| - build_type=options.build_type, |
| - flakiness_server=options.flakiness_dashboard_server) |
| - |
| if os.path.isdir(constants.ISOLATE_DEPS_DIR): |
| shutil.rmtree(constants.ISOLATE_DEPS_DIR) |
| - return (test_results, exit_code) |
| + return (TestRunnerFactory, all_tests) |
| def _FilterTests(all_enabled_tests): |