From 7b6cac068be3443af84a045a2e661a8948b4156e Mon Sep 17 00:00:00 2001 From: agrieve Date: Fri, 22 Apr 2016 07:57:00 -0700 Subject: [PATCH] Generate Android .isolate files used for test()s Tests use write_runtime_deps to have GN write out all runtime_deps, then use a new script "generate_isolate.py" to filter the files and create a .isolate. TBR=vollick BUG=589318 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1904823003 Cr-Original-Commit-Position: refs/heads/master@{#389105} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 964da0f3923afb10a52dfe81484d7f3dcb18bad6 --- android/pylib/gtest/gtest_test_instance.py | 4 +++- .../pylib/instrumentation/instrumentation_test_instance.py | 4 +++- android/pylib/utils/isolator.py | 6 ++++++ config/android/internal_rules.gni | 6 +++--- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/android/pylib/gtest/gtest_test_instance.py b/android/pylib/gtest/gtest_test_instance.py index c21ef7b4b..282b81d20 100644 --- a/android/pylib/gtest/gtest_test_instance.py +++ b/android/pylib/gtest/gtest_test_instance.py @@ -12,6 +12,7 @@ from pylib import constants from pylib.constants import host_paths from pylib.base import base_test_result from pylib.base import test_instance +from pylib.utils import isolator with host_paths.SysPath(host_paths.BUILD_COMMON_PATH): import unittest_util # pylint: disable=import-error @@ -196,7 +197,8 @@ class GtestTestInstance(test_instance.TestInstance): args.isolate_file_path = os.path.join( host_paths.DIR_SOURCE_ROOT, default_isolate_file_path) - if args.isolate_file_path: + if (args.isolate_file_path and + not isolator.IsIsolateEmpty(args.isolate_file_path)): self._isolate_abs_path = os.path.abspath(args.isolate_file_path) self._isolate_delegate = isolate_delegate self._isolated_abs_path = os.path.join( diff --git a/android/pylib/instrumentation/instrumentation_test_instance.py b/android/pylib/instrumentation/instrumentation_test_instance.py index e9c33f1c5..9f1e439ca 100644 --- a/android/pylib/instrumentation/instrumentation_test_instance.py +++ b/android/pylib/instrumentation/instrumentation_test_instance.py @@ -17,6 +17,7 @@ from pylib.base import test_instance from pylib.constants import host_paths from pylib.instrumentation import test_result from pylib.instrumentation import instrumentation_parser +from pylib.utils import isolator from pylib.utils import proguard with host_paths.SysPath(host_paths.BUILD_COMMON_PATH): @@ -292,7 +293,8 @@ class InstrumentationTestInstance(test_instance.TestInstance): def _initializeDataDependencyAttributes(self, args, isolate_delegate): self._data_deps = [] - if args.isolate_file_path: + if (args.isolate_file_path and + not isolator.IsIsolateEmpty(args.isolate_file_path)): if os.path.isabs(args.isolate_file_path): self._isolate_abs_path = args.isolate_file_path else: diff --git a/android/pylib/utils/isolator.py b/android/pylib/utils/isolator.py index c1281ff17..68faa38bd 100644 --- a/android/pylib/utils/isolator.py +++ b/android/pylib/utils/isolator.py @@ -54,6 +54,12 @@ def DefaultConfigVariables(): } +def IsIsolateEmpty(isolate_path): + """Returns whether there are no files in the .isolate.""" + with open(isolate_path) as f: + return "'files': []" in f.read() + + class Isolator(object): """Manages calls to isolate.py for the android test runner scripts.""" diff --git a/config/android/internal_rules.gni b/config/android/internal_rules.gni index 61e5f9732..17c976f96 100644 --- a/config/android/internal_rules.gni +++ b/config/android/internal_rules.gni @@ -2095,6 +2095,7 @@ template("test_runner_script") { depfile = "$target_gen_dir/$target_name.d" data_deps += [ "//build/android:test_runner_py" ] + data = [] test_runner_args = [ _test_type, @@ -2179,6 +2180,7 @@ template("test_runner_script") { } } if (defined(invoker.isolate_file)) { + data += [ invoker.isolate_file ] test_runner_args += [ "--isolate-file-path", rebase_path(invoker.isolate_file, root_build_dir), @@ -2209,9 +2211,7 @@ template("test_runner_script") { depfile, generated_script, ] - data = [ - generated_script, - ] + data += [ generated_script ] args = [ "--depfile",