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

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

Issue 2721323003: Record screenshots on failures on swarming bots. (Closed)
Patch Set: Record screenshots on failures on swarming bots. Created 3 years, 10 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 | « no previous file | no next file » | 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 7bfe3f5974efed2439e332afc0cd94f7ccd968ab..c23aa5c17f351422244be69a36f0d0c5245948f4 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
@@ -370,22 +370,29 @@ class LocalDeviceInstrumentationTestRun(
if any(r.GetType() not in (base_test_result.ResultType.PASS,
base_test_result.ResultType.SKIP)
for r in results):
- if self._test_instance.screenshot_dir:
- file_name = '%s-%s.png' % (
- test_display_name,
- time.strftime('%Y%m%dT%H%M%S', time.localtime()))
- screenshot_file = device.TakeScreenshot(
- os.path.join(self._test_instance.screenshot_dir, file_name))
- logging.info(
- 'Saved screenshot for %s to %s.',
- test_display_name, screenshot_file)
- if self._test_instance.should_save_images:
- link = google_storage_helper.upload(
- google_storage_helper.unique_name('screenshot', device=device),
- screenshot_file,
- bucket='chromium-render-tests')
- for result in results:
- result.SetLink('failure_screenshot', link)
+
+ with contextlib_ext.Optional(
+ tempfile_ext.NamedTemporaryDirectory(),
+ self._test_instance.screenshot_dir is None
+ and self._test_instance.should_save_images) as screenshot_dir:
+
+ screenshot_dir = self._test_instance.screenshot_dir or screenshot_dir
+ if screenshot_dir:
+ file_name = '%s-%s.png' % (
+ test_display_name,
+ time.strftime('%Y%m%dT%H%M%S', time.localtime()))
+ screenshot_file = device.TakeScreenshot(
+ os.path.join(self._test_instance.screenshot_dir, file_name))
+ logging.info(
+ 'Saved screenshot for %s to %s.',
+ test_display_name, screenshot_file)
+ if self._test_instance.should_save_images:
+ link = google_storage_helper.upload(
+ google_storage_helper.unique_name('screenshot', device=device),
+ screenshot_file,
+ bucket='chromium-render-tests')
+ for result in results:
+ result.SetLink('failure_screenshot', link)
logging.info('detected failure in %s. raw output:', test_display_name)
for l in output:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698