From 5b8b874d28684a10668beda666e773eca48cb872 Mon Sep 17 00:00:00 2001 From: "kkimlabs@chromium.org" Date: Thu, 22 May 2014 08:18:50 +0000 Subject: [PATCH] Added --isolate-file-path option to android test_runner. Currently, .isolate file list is hard-coded in build/android/pylib/gtest/setup.py so for downstream to provide .isolate file, we need to modify the upstream setup.py file. So add --isolate-file-path option so that downstream can provide their own .isolate file if they want. BUG=368034 Review URL: https://codereview.chromium.org/294033003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272137 0039d316-1c4b-4281-b951-d872f2087c98 --- build/android/pylib/gtest/setup.py | 24 +++++++++++++++++------- build/android/pylib/gtest/test_options.py | 1 + build/android/test_runner.py | 6 ++++++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/build/android/pylib/gtest/setup.py b/build/android/pylib/gtest/setup.py index 097e283f8007..4c7677875110 100644 --- a/build/android/pylib/gtest/setup.py +++ b/build/android/pylib/gtest/setup.py @@ -92,21 +92,30 @@ _ISOLATE_SCRIPT = os.path.join( constants.DIR_SOURCE_ROOT, 'tools', 'swarming_client', 'isolate.py') -def _GenerateDepsDirUsingIsolate(suite_name): +def _GenerateDepsDirUsingIsolate(suite_name, isolate_file_path=None): """Generate the dependency dir for the test suite using isolate. Args: suite_name: Name of the test suite (e.g. base_unittests). + isolate_file_path: .isolate file path to use. If there is a default .isolate + file path for the suite_name, this will override it. """ if os.path.isdir(constants.ISOLATE_DEPS_DIR): shutil.rmtree(constants.ISOLATE_DEPS_DIR) - isolate_rel_path = _ISOLATE_FILE_PATHS.get(suite_name) - if not isolate_rel_path: - logging.info('Did not find an isolate file for the test suite.') - return + if isolate_file_path: + if os.path.isabs(isolate_file_path): + isolate_abs_path = isolate_file_path + else: + isolate_abs_path = os.path.join(constants.DIR_SOURCE_ROOT, + isolate_file_path) + else: + isolate_rel_path = _ISOLATE_FILE_PATHS.get(suite_name) + if not isolate_rel_path: + logging.info('Did not find an isolate file for the test suite.') + return + isolate_abs_path = os.path.join(constants.DIR_SOURCE_ROOT, isolate_rel_path) - isolate_abs_path = os.path.join(constants.DIR_SOURCE_ROOT, isolate_rel_path) isolated_abs_path = os.path.join( constants.GetOutDirectory(), '%s.isolated' % suite_name) assert os.path.exists(isolate_abs_path) @@ -309,7 +318,8 @@ def Setup(test_options, devices): % test_options.suite_name) logging.warning('Found target %s', test_package.suite_path) - _GenerateDepsDirUsingIsolate(test_options.suite_name) + _GenerateDepsDirUsingIsolate(test_options.suite_name, + test_options.isolate_file_path) tests = _GetTests(test_options, test_package, devices) diff --git a/build/android/pylib/gtest/test_options.py b/build/android/pylib/gtest/test_options.py index 4cc291d06130..6f7df0d779ff 100644 --- a/build/android/pylib/gtest/test_options.py +++ b/build/android/pylib/gtest/test_options.py @@ -14,4 +14,5 @@ GTestOptions = collections.namedtuple('GTestOptions', [ 'run_disabled', 'test_arguments', 'timeout', + 'isolate_file_path', 'suite_name']) diff --git a/build/android/test_runner.py b/build/android/test_runner.py index 45df772c2f40..a0c3b72fe03e 100755 --- a/build/android/test_runner.py +++ b/build/android/test_runner.py @@ -117,6 +117,11 @@ def AddGTestOptions(option_parser): help='Timeout to wait for each test', type='int', default=60) + option_parser.add_option('--isolate_file_path', + '--isolate-file-path', + dest='isolate_file_path', + help='.isolate file path to override the default ' + 'path') # TODO(gkanwar): Move these to Common Options once we have the plumbing # in our other test types to handle these commands AddCommonOptions(option_parser) @@ -505,6 +510,7 @@ def _RunGTests(options, devices): options.run_disabled, options.test_arguments, options.timeout, + options.isolate_file_path, suite_name) runner_factory, tests = gtest_setup.Setup(gtest_options, devices) -- 2.11.4.GIT