Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3413)

Unified Diff: build/android/pylib/local/machine/local_machine_junit_test_run.py

Issue 2824863002: Revert of (Reland) Expose resources in Robolectric/JUnit tests. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/pylib/junit/junit_test_instance.py ('k') | build/android/test_runner.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/local/machine/local_machine_junit_test_run.py
diff --git a/build/android/pylib/local/machine/local_machine_junit_test_run.py b/build/android/pylib/local/machine/local_machine_junit_test_run.py
index 3d4d2c0736c929eddc21c7929703206a037821d7..b4ce4a9a4df1a01ad662132997b18daeb9813c39 100644
--- a/build/android/pylib/local/machine/local_machine_junit_test_run.py
+++ b/build/android/pylib/local/machine/local_machine_junit_test_run.py
@@ -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,34 +27,14 @@
#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
- if os.path.exists(resource_zip)])
-
- 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:
@@ -67,22 +45,15 @@
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)
@@ -91,14 +62,12 @@
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)
« no previous file with comments | « build/android/pylib/junit/junit_test_instance.py ('k') | build/android/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698