Add --test-jar arg to test_runner to explicitly specify its path.

Review-Url: https://codereview.chromium.org/2536373005
Cr-Original-Commit-Position: refs/heads/master@{#435444}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 4a1ddc199e19988c803fa8d85f1f26b929e390bf
This commit is contained in:
mikecase 2016-11-30 14:19:57 -08:00 коммит произвёл Commit bot
Родитель e062165ec8
Коммит d684b36397
5 изменённых файлов: 22 добавлений и 10 удалений

Просмотреть файл

@ -64,6 +64,7 @@ def main(args):
group.add_argument('--output-directory')
group.add_argument('--runtime-deps-path')
group.add_argument('--test-apk')
group.add_argument('--test-jar')
group.add_argument('--test-apk-incremental-install-script')
group.add_argument('--coverage-dir')
args, test_runner_args = parser.parse_known_args(
@ -109,6 +110,9 @@ def main(args):
if args.test_apk:
test_runner_path_args.append(
('--test-apk', RelativizePathToScript(args.test_apk)))
if args.test_jar:
test_runner_path_args.append(
('--test-jar', RelativizePathToScript(args.test_jar)))
if args.test_apk_incremental_install_script:
test_runner_path_args.append(
('--test-apk-incremental-install-script',

Просмотреть файл

@ -487,16 +487,14 @@ class InstrumentationTestInstance(test_instance.TestInstance):
assert self._suite.endswith('_incremental')
self._suite = self._suite[:-len('_incremental')]
self._test_jar = os.path.join(
constants.GetOutDirectory(), constants.SDK_BUILD_TEST_JAVALIB_DIR,
'%s.jar' % self._suite)
self._test_jar = args.test_jar
self._test_support_apk = apk_helper.ToHelper(os.path.join(
constants.GetOutDirectory(), constants.SDK_BUILD_TEST_JAVALIB_DIR,
'%sSupport.apk' % self._suite))
if not os.path.exists(self._test_apk.path):
error_func('Unable to find test APK: %s' % self._test_apk.path)
if not os.path.exists(self._test_jar):
if not self._test_jar or not os.path.exists(self._test_jar):
error_func('Unable to find test JAR: %s' % self._test_jar)
self._test_package = self._test_apk.GetPackageName()

Просмотреть файл

@ -346,6 +346,8 @@ def AddInstrumentationTestOptions(parser):
help='Path or name of the apk containing the tests '
'(name is without the .apk extension; '
'e.g. "ContentShellTest").')
group.add_argument('--test-jar', required=True,
help='Path of jar containing test java files.')
group.add_argument('--test-apk-incremental-install-script',
type=os.path.realpath,
help='Path to install script for the --test-apk.')

Просмотреть файл

@ -514,7 +514,11 @@ template("test_runner_script") {
if (_incremental_install) {
_test_apk = "@FileArg($_rebased_apk_build_config:deps_info:incremental_apk_path)"
}
test_runner_args += [ "--test-apk=$_test_apk" ]
test_runner_args += [
"--test-apk=$_test_apk",
"--test-jar",
rebase_path(invoker.test_jar, root_build_dir),
]
if (defined(invoker.apk_under_test)) {
deps += [ "${invoker.apk_under_test}__build_config" ]
_apk_under_test_build_config =

Просмотреть файл

@ -1346,7 +1346,7 @@ if (enable_java_templates) {
# android_manifest: Path to AndroidManifest.xml.
# android_manifest_dep: Target that generates AndroidManifest (if applicable)
# chromium_code: If true, extra analysis warning/errors will be enabled.
# create_dist_ijar: Whether to define the "${target_name}_dist_ijar" target
# dist_ijar_path: Path to create "${target_name}_dist_ijar" target
# (used by instrumentation_test_apk).
# data_deps: List of dependencies needed at runtime. These will be built but
# won't change the generated .apk in any way (in fact they may be built
@ -1794,9 +1794,8 @@ if (enable_java_templates) {
# TODO(cjhopman): This is only ever needed to calculate the list of tests to
# run. See build/android/pylib/instrumentation/test_jar.py. We should be
# able to just do that calculation at build time instead.
if (defined(invoker.create_dist_ijar) && invoker.create_dist_ijar) {
_dist_ijar_path = "$root_build_dir/test.lib.java/" +
get_path_info(_final_apk_path, "name") + ".jar"
if (defined(invoker.dist_ijar_path)) {
_dist_ijar_path = invoker.dist_ijar_path
action("${_template_name}_dist_ijar") {
script = "//build/android/gyp/create_dist_jar.py"
depfile = "$target_gen_dir/$target_name.d"
@ -2259,10 +2258,13 @@ if (enable_java_templates) {
# ]
# }
template("instrumentation_test_apk") {
assert(defined(invoker.apk_name))
testonly = true
_apk_target_name = "${target_name}__apk"
_test_runner_target_name = "${target_name}__test_runner_script"
_install_script_name = "install_$target_name"
_dist_ijar_path =
"$root_build_dir/test.lib.java/" + invoker.apk_name + ".jar"
test_runner_script(_test_runner_target_name) {
forward_variables_from(invoker,
@ -2278,6 +2280,7 @@ if (enable_java_templates) {
test_name = invoker.target_name
test_type = "instrumentation"
apk_target = ":$_apk_target_name"
test_jar = _dist_ijar_path
}
test_runner_script("${_test_runner_target_name}_incremental") {
@ -2294,6 +2297,7 @@ if (enable_java_templates) {
test_name = "${invoker.target_name}_incremental"
test_type = "instrumentation"
apk_target = ":$_apk_target_name"
test_jar = _dist_ijar_path
incremental_install = true
}
@ -2324,7 +2328,7 @@ if (enable_java_templates) {
proguard_configs += [ "//testing/android/proguard_for_test.flags" ]
}
create_dist_ijar = true
dist_ijar_path = _dist_ijar_path
if (defined(invoker.run_findbugs_override)) {
# Only allow findbugs when there are java files.
run_findbugs_override =