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..a27c062c15d99d10aeee4a1e4d630e19a6d2c58f 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,58 +513,76 @@ 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(), |
+ self._test_instance.render_results_dir is None) as render_host_dir: |
jbudorick
2017/05/17 21:26:45
nit: Can you name the context manager something ot
mikecase (-- gone --)
2017/05/17 21:46:04
Done
|
+ render_host_dir = ( |
+ self._test_instance.render_results_dir or render_host_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')): |
+ # Upload results to Google Storage. |
jbudorick
2017/05/17 21:26:45
Since we no longer always do this, I think it'd be
mikecase (-- gone --)
2017/05/17 21:46:05
Done, added _UploadRenderTestResults function.
|
+ if not self._test_instance.gs_results_bucket: |
+ return |
+ |
+ 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(temp_dir, 'failures', failure_filename) |
+ 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(temp_dir, 'goldens', failure_filename) |
+ 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(temp_dir, 'diffs', failure_filename) |
+ 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) |