Revert of Expose resources in Robolectric/JUnit tests. (patchset #12 id:220001 of https://codereview.chromium.org/2767613002/ )
Reason for revert:
crbug/711372
Original issue's description:
> Expose resources in Robolectric/JUnit tests.
>
> BUG=693573
>
> Review-Url: https://codereview.chromium.org/2767613002
> Cr-Commit-Position: refs/heads/master@{#464422}
> Committed: 0d81d90a4b
TBR=agrieve@chromium.org,dgn@chromium.org,jbudorick@chromium.org,nyquist@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=693573
Review-Url: https://codereview.chromium.org/2819593002
Cr-Original-Commit-Position: refs/heads/master@{#464486}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b67ca3636e3ec5dc8f38a1ffd9db79a1208620e9
This commit is contained in:
Родитель
04e8679421
Коммит
f16469fa2c
|
@ -60,7 +60,6 @@ def main(args):
|
|||
"the action's first output.")
|
||||
parser.add_argument('--test-runner-path',
|
||||
help='Path to test_runner.py (optional).')
|
||||
|
||||
# We need to intercept any test runner path arguments and make all
|
||||
# of the paths relative to the output script directory.
|
||||
group = parser.add_argument_group('Test runner path arguments.')
|
||||
|
@ -79,9 +78,6 @@ def main(args):
|
|||
group.add_argument('--test-jar')
|
||||
group.add_argument('--test-apk-incremental-install-script')
|
||||
group.add_argument('--coverage-dir')
|
||||
group.add_argument('--android-manifest-path')
|
||||
group.add_argument('--resource-zips')
|
||||
group.add_argument('--robolectric-runtime-deps-dir')
|
||||
args, test_runner_args = parser.parse_known_args(
|
||||
build_utils.ExpandFileArgs(args))
|
||||
|
||||
|
@ -140,18 +136,6 @@ def main(args):
|
|||
if args.coverage_dir:
|
||||
test_runner_path_args.append(
|
||||
('--coverage-dir', RelativizePathToScript(args.coverage_dir)))
|
||||
if args.android_manifest_path:
|
||||
test_runner_path_args.append(
|
||||
('--android-manifest-path',
|
||||
RelativizePathToScript(args.android_manifest_path)))
|
||||
if args.resource_zips:
|
||||
test_runner_path_args.extend(
|
||||
('--resource-zip', RelativizePathToScript(r))
|
||||
for r in build_utils.ParseGnList(args.resource_zips))
|
||||
if args.robolectric_runtime_deps_dir:
|
||||
test_runner_path_args.append(
|
||||
('--robolectric-runtime-deps-dir',
|
||||
RelativizePathToScript(args.robolectric_runtime_deps_dir)))
|
||||
|
||||
with open(args.script_output_path, 'w') as script:
|
||||
script.write(SCRIPT_TEMPLATE.format(
|
||||
|
|
|
@ -344,7 +344,6 @@ def main(argv):
|
|||
'dist_jar': ['build_config'],
|
||||
'resource_rewriter': ['build_config'],
|
||||
'group': ['build_config'],
|
||||
'junit_binary': ['build_config'],
|
||||
}
|
||||
required_options = required_options_map.get(options.type)
|
||||
if not required_options:
|
||||
|
@ -541,8 +540,7 @@ def main(argv):
|
|||
deps_info['owned_resources_dirs'] = list(owned_resource_dirs)
|
||||
deps_info['owned_resources_zips'] = list(owned_resource_zips)
|
||||
|
||||
if options.type in (
|
||||
'android_resources', 'android_apk', 'junit_binary', 'resource_rewriter'):
|
||||
if options.type in ('android_resources','android_apk', 'resource_rewriter'):
|
||||
config['resources'] = {}
|
||||
config['resources']['dependency_zips'] = [
|
||||
c['resources_zip'] for c in all_resources_deps]
|
||||
|
|
|
@ -10,12 +10,8 @@ class JunitTestInstance(test_instance.TestInstance):
|
|||
def __init__(self, args, _):
|
||||
super(JunitTestInstance, self).__init__()
|
||||
|
||||
self._android_manifest_path = args.android_manifest_path
|
||||
self._coverage_dir = args.coverage_dir
|
||||
self._package_filter = args.package_filter
|
||||
self._package_name = args.package_name
|
||||
self._resource_zips = args.resource_zips
|
||||
self._robolectric_runtime_deps_dir = args.robolectric_runtime_deps_dir
|
||||
self._runner_filter = args.runner_filter
|
||||
self._test_filter = args.test_filter
|
||||
self._test_suite = args.test_suite
|
||||
|
@ -32,10 +28,6 @@ class JunitTestInstance(test_instance.TestInstance):
|
|||
def TearDown(self):
|
||||
pass
|
||||
|
||||
@property
|
||||
def android_manifest_path(self):
|
||||
return self._android_manifest_path
|
||||
|
||||
@property
|
||||
def coverage_dir(self):
|
||||
return self._coverage_dir
|
||||
|
@ -44,18 +36,6 @@ class JunitTestInstance(test_instance.TestInstance):
|
|||
def package_filter(self):
|
||||
return self._package_filter
|
||||
|
||||
@property
|
||||
def package_name(self):
|
||||
return self._package_name
|
||||
|
||||
@property
|
||||
def resource_zips(self):
|
||||
return self._resource_zips
|
||||
|
||||
@property
|
||||
def robolectric_runtime_deps_dir(self):
|
||||
return self._robolectric_runtime_deps_dir
|
||||
|
||||
@property
|
||||
def runner_filter(self):
|
||||
return self._runner_filter
|
||||
|
|
|
@ -4,15 +4,13 @@
|
|||
|
||||
import json
|
||||
import os
|
||||
import zipfile
|
||||
import tempfile
|
||||
|
||||
from devil.utils import cmd_helper
|
||||
from devil.utils import reraiser_thread
|
||||
from pylib import constants
|
||||
from pylib.base import base_test_result
|
||||
from pylib.base import test_run
|
||||
from pylib.results import json_results
|
||||
from py_utils import tempfile_ext
|
||||
|
||||
|
||||
class LocalMachineJunitTestRun(test_run.TestRun):
|
||||
|
@ -29,33 +27,14 @@ class LocalMachineJunitTestRun(test_run.TestRun):
|
|||
|
||||
#override
|
||||
def RunTests(self):
|
||||
with tempfile_ext.NamedTemporaryDirectory() as temp_dir:
|
||||
json_file_path = os.path.join(temp_dir, 'results.json')
|
||||
|
||||
# Extract resources needed for test.
|
||||
# TODO(mikecase): Investigate saving md5sums of zipfiles, and only
|
||||
# extract zipfiles when they change.
|
||||
def extract_resource_zip(resource_zip):
|
||||
def helper():
|
||||
extract_dest = os.path.join(
|
||||
temp_dir, os.path.splitext(os.path.basename(resource_zip))[0])
|
||||
with zipfile.ZipFile(resource_zip, 'r') as zf:
|
||||
zf.extractall(extract_dest)
|
||||
return extract_dest
|
||||
return helper
|
||||
|
||||
resource_dirs = reraiser_thread.RunAsync(
|
||||
[extract_resource_zip(resource_zip)
|
||||
for resource_zip in self._test_instance.resource_zips])
|
||||
|
||||
java_script = os.path.join(
|
||||
constants.GetOutDirectory(), 'bin', 'helper',
|
||||
self._test_instance.suite)
|
||||
with tempfile.NamedTemporaryFile() as json_file:
|
||||
java_script = os.path.join(constants.GetOutDirectory(), 'bin', 'helper',
|
||||
self._test_instance.suite)
|
||||
command = [java_script]
|
||||
|
||||
# Add Jar arguments.
|
||||
jar_args = ['-test-jars', self._test_instance.suite + '.jar',
|
||||
'-json-results-file', json_file_path]
|
||||
'-json-results-file', json_file.name]
|
||||
if self._test_instance.test_filter:
|
||||
jar_args.extend(['-gtest-filter', self._test_instance.test_filter])
|
||||
if self._test_instance.package_filter:
|
||||
|
@ -66,22 +45,15 @@ class LocalMachineJunitTestRun(test_run.TestRun):
|
|||
command.extend(['--jar-args', '"%s"' % ' '.join(jar_args)])
|
||||
|
||||
# Add JVM arguments.
|
||||
jvm_args = ['-Drobolectric.dependency.dir=%s' %
|
||||
self._test_instance.robolectric_runtime_deps_dir,
|
||||
'-Ddir.source.root=%s' % constants.DIR_SOURCE_ROOT,]
|
||||
|
||||
if self._test_instance.android_manifest_path:
|
||||
jvm_args += ['-Dchromium.robolectric.manifest=%s' %
|
||||
self._test_instance.android_manifest_path]
|
||||
|
||||
if self._test_instance.package_name:
|
||||
jvm_args += ['-Dchromium.robolectric.package.name=%s' %
|
||||
self._test_instance.package_name]
|
||||
|
||||
if resource_dirs:
|
||||
jvm_args += ['-Dchromium.robolectric.resource.dirs=%s' %
|
||||
':'.join(resource_dirs)]
|
||||
|
||||
jvm_args = []
|
||||
# TODO(mikecase): Add a --robolectric-dep-dir arg to test runner.
|
||||
# Have this arg set by GN in the generated test runner scripts.
|
||||
jvm_args += [
|
||||
'-Drobolectric.dependency.dir=%s' % os.path.join(
|
||||
constants.GetOutDirectory(), 'lib.java', 'third_party',
|
||||
'robolectric'),
|
||||
'-Ddir.source.root=%s' % constants.DIR_SOURCE_ROOT,
|
||||
]
|
||||
if self._test_instance.coverage_dir:
|
||||
if not os.path.exists(self._test_instance.coverage_dir):
|
||||
os.makedirs(self._test_instance.coverage_dir)
|
||||
|
@ -90,14 +62,12 @@ class LocalMachineJunitTestRun(test_run.TestRun):
|
|||
jvm_args.append('-Demma.coverage.out.file=%s' % os.path.join(
|
||||
self._test_instance.coverage_dir,
|
||||
'%s.ec' % self._test_instance.suite))
|
||||
|
||||
if jvm_args:
|
||||
command.extend(['--jvm-args', '"%s"' % ' '.join(jvm_args)])
|
||||
|
||||
cmd_helper.RunCmd(command)
|
||||
with open(json_file_path, 'r') as f:
|
||||
results_list = json_results.ParseResultsFromJson(
|
||||
json.loads(f.read()))
|
||||
results_list = json_results.ParseResultsFromJson(
|
||||
json.loads(json_file.read()))
|
||||
|
||||
test_run_results = base_test_result.TestRunResults()
|
||||
test_run_results.AddResults(results_list)
|
||||
|
|
|
@ -469,21 +469,6 @@ def AddJUnitTestOptions(parser):
|
|||
dest='test_suite', required=True,
|
||||
help='JUnit test suite to run.')
|
||||
|
||||
# These arguments are for Android Robolectric tests.
|
||||
parser.add_argument(
|
||||
'--android-manifest-path',
|
||||
help='Path to Android Manifest to configure Robolectric.')
|
||||
parser.add_argument(
|
||||
'--package-name',
|
||||
help='Default app package name for Robolectric tests.')
|
||||
parser.add_argument(
|
||||
'--resource-zip',
|
||||
action='append', dest='resource_zips', default=[],
|
||||
help='Path to resource zips to configure Robolectric.')
|
||||
parser.add_argument(
|
||||
'--robolectric-runtime-deps-dir',
|
||||
help='Path to runtime deps for Robolectric.')
|
||||
|
||||
|
||||
def AddLinkerTestOptions(parser):
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
../../third_party/catapult/common/py_utils/py_utils/cloud_storage_global_lock.py
|
||||
../../third_party/catapult/common/py_utils/py_utils/contextlib_ext.py
|
||||
../../third_party/catapult/common/py_utils/py_utils/lock.py
|
||||
../../third_party/catapult/common/py_utils/py_utils/tempfile_ext.py
|
||||
../../third_party/catapult/dependency_manager/dependency_manager/__init__.py
|
||||
../../third_party/catapult/dependency_manager/dependency_manager/archive_info.py
|
||||
../../third_party/catapult/dependency_manager/dependency_manager/base_config.py
|
||||
|
|
|
@ -87,7 +87,7 @@ template("write_build_config") {
|
|||
type == "android_resources" || type == "deps_dex" ||
|
||||
type == "dist_jar" || type == "android_assets" ||
|
||||
type == "resource_rewriter" || type == "java_binary" ||
|
||||
type == "group" || type == "java_prebuilt" || type == "junit_binary")
|
||||
type == "group" || type == "java_prebuilt")
|
||||
|
||||
forward_variables_from(invoker,
|
||||
[
|
||||
|
@ -564,40 +564,10 @@ template("test_runner_script") {
|
|||
}
|
||||
} else if (_test_type == "junit") {
|
||||
assert(defined(invoker.test_suite))
|
||||
|
||||
test_runner_args += [
|
||||
"--test-suite",
|
||||
invoker.test_suite,
|
||||
]
|
||||
if (defined(invoker.android_manifest_path)) {
|
||||
test_runner_args += [
|
||||
"--android-manifest-path",
|
||||
rebase_path(invoker.android_manifest_path, root_build_dir),
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(invoker.package_name)) {
|
||||
test_runner_args += [
|
||||
"--package-name",
|
||||
invoker.package_name,
|
||||
]
|
||||
|
||||
deps += [ ":${invoker.test_suite}__build_config" ]
|
||||
_junit_binary_build_config =
|
||||
"${target_gen_dir}/${invoker.test_suite}.build_config"
|
||||
_rebased_build_config =
|
||||
rebase_path("$_junit_binary_build_config", root_build_dir)
|
||||
test_runner_args += [
|
||||
"--resource-zips",
|
||||
"@FileArg($_rebased_build_config:resources:dependency_zips)",
|
||||
]
|
||||
}
|
||||
|
||||
test_runner_args += [
|
||||
"--robolectric-runtime-deps-dir",
|
||||
rebase_path("$root_build_dir/lib.java/third_party/robolectric",
|
||||
root_build_dir),
|
||||
]
|
||||
} else if (_test_type == "linker") {
|
||||
test_runner_args += [
|
||||
"--test-apk",
|
||||
|
|
|
@ -898,7 +898,6 @@ if (enable_java_templates) {
|
|||
|
||||
grit_target_name = "${target_name}__grit"
|
||||
grit_output_dir = "$target_gen_dir/$extra_output_path"
|
||||
|
||||
grit(grit_target_name) {
|
||||
forward_variables_from(invoker, [ "deps" ])
|
||||
grit_flags = [
|
||||
|
@ -1059,27 +1058,11 @@ if (enable_java_templates) {
|
|||
_java_binary_target_name = "${target_name}__java_binary"
|
||||
_test_runner_target_name = "${target_name}__test_runner_script"
|
||||
|
||||
_build_config = "$target_gen_dir/$target_name.build_config"
|
||||
_build_config_target_name = "${target_name}__build_config"
|
||||
|
||||
write_build_config(_build_config_target_name) {
|
||||
type = "junit_binary"
|
||||
build_config = _build_config
|
||||
if (defined(invoker.deps)) {
|
||||
possible_config_deps = invoker.deps
|
||||
}
|
||||
}
|
||||
|
||||
test_runner_script(_test_runner_target_name) {
|
||||
test_name = invoker.target_name
|
||||
test_suite = invoker.target_name
|
||||
test_type = "junit"
|
||||
ignore_all_data_deps = true
|
||||
forward_variables_from(invoker,
|
||||
[
|
||||
"android_manifest_path",
|
||||
"package_name",
|
||||
])
|
||||
}
|
||||
|
||||
java_binary(_java_binary_target_name) {
|
||||
|
@ -1099,7 +1082,6 @@ if (enable_java_templates) {
|
|||
}
|
||||
group(target_name) {
|
||||
public_deps = [
|
||||
":$_build_config_target_name",
|
||||
":$_java_binary_target_name",
|
||||
":$_test_runner_target_name",
|
||||
]
|
||||
|
|
Загрузка…
Ссылка в новой задаче