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

Unified Diff: build/android/pylib/local/device/local_device_instrumentation_test_run.py

Issue 2889663003: Add --render-results-dir arg to store render results locally. (Closed)
Patch Set: Add --render-results-dir arg to store render results locally. Created 3 years, 7 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/instrumentation/instrumentation_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/device/local_device_instrumentation_test_run.py
diff --git a/build/android/pylib/local/device/local_device_instrumentation_test_run.py b/build/android/pylib/local/device/local_device_instrumentation_test_run.py
index 4b762c9889a531fdc641e96daa15c098bfd6ab9b..b150187654a8242d43d1be5a9818d2b31d9d0514 100644
--- a/build/android/pylib/local/device/local_device_instrumentation_test_run.py
+++ b/build/android/pylib/local/device/local_device_instrumentation_test_run.py
@@ -513,84 +513,103 @@ class LocalDeviceInstrumentationTestRun(
def _ProcessRenderTestResults(
self, device, render_tests_device_output_dir, results):
- # Will archive test images if we are given a GS bucket to store the results
- # in and are given a results file to output the links to.
- if not bool(self._test_instance.gs_results_bucket):
+ # If GS results bucket is specified, will archive render result images.
+ # If render image dir is specified, will pull the render result image from
+ # the device and leave in the directory.
+ if not (bool(self._test_instance.gs_results_bucket) or
+ bool(self._test_instance.render_results_dir)):
return
failure_images_device_dir = posixpath.join(
render_tests_device_output_dir, 'failures')
-
if not device.FileExists(failure_images_device_dir):
return
- render_tests_bucket = (
- self._test_instance.gs_results_bucket + '/render_tests')
-
diff_images_device_dir = posixpath.join(
render_tests_device_output_dir, 'diffs')
golden_images_device_dir = posixpath.join(
render_tests_device_output_dir, 'goldens')
- with tempfile_ext.NamedTemporaryDirectory() as temp_dir:
- device.PullFile(failure_images_device_dir, temp_dir)
+ with contextlib_ext.Optional(
+ tempfile_ext.NamedTemporaryDirectory(),
+ not bool(self._test_instance.render_results_dir)) as render_temp_dir:
+ render_host_dir = (
+ self._test_instance.render_results_dir or render_temp_dir)
+
+ if not os.path.exists(render_host_dir):
+ os.makedirs(render_host_dir)
+
+ # Pull all render test results from device.
+ device.PullFile(failure_images_device_dir, render_host_dir)
if device.FileExists(diff_images_device_dir):
- device.PullFile(diff_images_device_dir, temp_dir)
+ device.PullFile(diff_images_device_dir, render_host_dir)
else:
logging.error('Diff images not found on device.')
if device.FileExists(golden_images_device_dir):
- device.PullFile(golden_images_device_dir, temp_dir)
+ device.PullFile(golden_images_device_dir, render_host_dir)
else:
logging.error('Golden images not found on device.')
- for failure_filename in os.listdir(os.path.join(temp_dir, 'failures')):
- m = RE_RENDER_IMAGE_NAME.match(failure_filename)
- if not m:
- logging.warning('Unexpected file in render test failures: %s',
- failure_filename)
- continue
-
- failure_filepath = os.path.join(temp_dir, 'failures', failure_filename)
- failure_link = google_storage_helper.upload_content_addressed(
- failure_filepath, bucket=render_tests_bucket)
-
- golden_filepath = os.path.join(temp_dir, 'goldens', failure_filename)
- if os.path.exists(golden_filepath):
- golden_link = google_storage_helper.upload_content_addressed(
- golden_filepath, bucket=render_tests_bucket)
- else:
- golden_link = ''
+ # Upload results to Google Storage.
+ if self._test_instance.gs_results_bucket:
+ self._UploadRenderTestResults(render_host_dir, results)
- diff_filepath = os.path.join(temp_dir, 'diffs', failure_filename)
- if os.path.exists(diff_filepath):
- diff_link = google_storage_helper.upload_content_addressed(
- diff_filepath, bucket=render_tests_bucket)
- else:
- diff_link = ''
-
- with tempfile.NamedTemporaryFile(suffix='.html') as temp_html:
- jinja2_env = jinja2.Environment(
- loader=jinja2.FileSystemLoader(_JINJA_TEMPLATE_DIR),
- trim_blocks=True)
- template = jinja2_env.get_template(_JINJA_TEMPLATE_FILENAME)
- # pylint: disable=no-member
- processed_template_output = template.render(
- test_name=failure_filename,
- failure_link=failure_link,
- golden_link=golden_link,
- diff_link=diff_link)
-
- temp_html.write(processed_template_output)
- temp_html.flush()
- html_results_link = google_storage_helper.upload_content_addressed(
- temp_html.name,
- bucket=render_tests_bucket,
- content_type='text/html')
- for result in results:
- result.SetLink(failure_filename, html_results_link)
+ def _UploadRenderTestResults(self, render_host_dir, results):
+ render_tests_bucket = (
+ self._test_instance.gs_results_bucket + '/render_tests')
+
+ for failure_filename in os.listdir(
+ os.path.join(render_host_dir, 'failures')):
+ m = RE_RENDER_IMAGE_NAME.match(failure_filename)
+ if not m:
+ logging.warning('Unexpected file in render test failures: %s',
+ failure_filename)
+ continue
+
+ failure_filepath = os.path.join(
+ render_host_dir, 'failures', failure_filename)
+ failure_link = google_storage_helper.upload_content_addressed(
+ failure_filepath, bucket=render_tests_bucket)
+
+ golden_filepath = os.path.join(
+ render_host_dir, 'goldens', failure_filename)
+ if os.path.exists(golden_filepath):
+ golden_link = google_storage_helper.upload_content_addressed(
+ golden_filepath, bucket=render_tests_bucket)
+ else:
+ golden_link = ''
+
+ diff_filepath = os.path.join(
+ render_host_dir, 'diffs', failure_filename)
+ if os.path.exists(diff_filepath):
+ diff_link = google_storage_helper.upload_content_addressed(
+ diff_filepath, bucket=render_tests_bucket)
+ else:
+ diff_link = ''
+
+ with tempfile.NamedTemporaryFile(suffix='.html') as temp_html:
+ jinja2_env = jinja2.Environment(
+ loader=jinja2.FileSystemLoader(_JINJA_TEMPLATE_DIR),
+ trim_blocks=True)
+ template = jinja2_env.get_template(_JINJA_TEMPLATE_FILENAME)
+ # pylint: disable=no-member
+ processed_template_output = template.render(
+ test_name=failure_filename,
+ failure_link=failure_link,
+ golden_link=golden_link,
+ diff_link=diff_link)
+
+ temp_html.write(processed_template_output)
+ temp_html.flush()
+ html_results_link = google_storage_helper.upload_content_addressed(
+ temp_html.name,
+ bucket=render_tests_bucket,
+ content_type='text/html')
+ for result in results:
+ result.SetLink(failure_filename, html_results_link)
#override
def _ShouldRetry(self, test):
« no previous file with comments | « build/android/pylib/instrumentation/instrumentation_test_instance.py ('k') | build/android/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698