Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import logging | 5 import logging |
| 6 import os | 6 import os |
| 7 import posixpath | 7 import posixpath |
| 8 import re | 8 import re |
| 9 import time | 9 import time |
| 10 | 10 |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 # - clearing the application state while persisting permissions | 379 # - clearing the application state while persisting permissions |
| 380 if any(r.GetType() not in (base_test_result.ResultType.PASS, | 380 if any(r.GetType() not in (base_test_result.ResultType.PASS, |
| 381 base_test_result.ResultType.SKIP) | 381 base_test_result.ResultType.SKIP) |
| 382 for r in results): | 382 for r in results): |
| 383 with contextlib_ext.Optional( | 383 with contextlib_ext.Optional( |
| 384 tempfile_ext.NamedTemporaryDirectory(), | 384 tempfile_ext.NamedTemporaryDirectory(), |
| 385 self._test_instance.screenshot_dir is None and | 385 self._test_instance.screenshot_dir is None and |
| 386 self._test_instance.gs_results_bucket) as screenshot_host_dir: | 386 self._test_instance.gs_results_bucket) as screenshot_host_dir: |
| 387 screenshot_host_dir = ( | 387 screenshot_host_dir = ( |
| 388 self._test_instance.screenshot_dir or screenshot_host_dir) | 388 self._test_instance.screenshot_dir or screenshot_host_dir) |
| 389 | |
| 389 if screenshot_host_dir: | 390 if screenshot_host_dir: |
| 390 file_name = '%s-%s.png' % ( | 391 screenshot_device_file = posixpath.join( |
| 391 test_display_name, | 392 device.GetExternalStoragePath(), |
| 392 time.strftime('%Y%m%dT%H%M%S-UTC', time.gmtime())) | 393 'chromium_tests_root', |
|
jbudorick
2017/05/05 01:21:58
If I don't like hard-coding things, I *really* don
mikecase (-- gone --)
2017/05/05 18:09:19
Changed --screenshot-dir arg to just --screenshot-
| |
| 393 screenshot_file = device.TakeScreenshot( | 394 instrumentation_test_instance.FAILURE_SCREENSHOT_SUBDIR, |
| 394 os.path.join(screenshot_host_dir, file_name)) | 395 'failure.png') |
| 395 logging.info( | 396 screenshot_host_file = os.path.join( |
| 396 'Saved screenshot for %s to %s.', | 397 screenshot_host_dir, |
| 397 test_display_name, screenshot_file) | 398 '%s-%s.png' % ( |
| 398 if self._test_instance.gs_results_bucket: | 399 test_display_name, |
| 399 link = google_storage_helper.upload( | 400 time.strftime('%Y%m%dT%H%M%S-UTC', time.gmtime()))) |
| 400 google_storage_helper.unique_name('screenshot', device=device), | 401 if device.FileExists(screenshot_device_file): |
| 401 screenshot_file, | 402 device.PullFile(screenshot_device_file, screenshot_host_file) |
| 402 bucket=self._test_instance.gs_results_bucket + '/screenshots') | 403 device.RemovePath(screenshot_device_file) |
|
jbudorick
2017/05/05 01:21:58
We should try to remove the file even if pulling i
mikecase (-- gone --)
2017/05/05 18:09:19
sounds good. Done
| |
| 403 for result in results: | 404 |
| 404 result.SetLink('post_test_screenshot', link) | 405 logging.info( |
| 406 'Saved screenshot for %s to %s.', | |
| 407 test_display_name, screenshot_host_file) | |
| 408 if self._test_instance.gs_results_bucket: | |
| 409 link = google_storage_helper.upload( | |
| 410 google_storage_helper.unique_name( | |
| 411 'screenshot', device=device), | |
| 412 screenshot_host_file, | |
| 413 bucket=self._test_instance.gs_results_bucket + '/screenshots') | |
|
jbudorick
2017/05/05 01:21:58
nit: '%s/screenshots' % self._test_instance.gs_res
| |
| 414 for result in results: | |
| 415 result.SetLink('post_test_screenshot', link) | |
| 405 | 416 |
| 406 logging.info('detected failure in %s. raw output:', test_display_name) | 417 logging.info('detected failure in %s. raw output:', test_display_name) |
| 407 for l in output: | 418 for l in output: |
| 408 logging.info(' %s', l) | 419 logging.info(' %s', l) |
| 409 if (not self._env.skip_clear_data | 420 if (not self._env.skip_clear_data |
| 410 and self._test_instance.package_info): | 421 and self._test_instance.package_info): |
| 411 permissions = ( | 422 permissions = ( |
| 412 self._test_instance.apk_under_test.GetPermissions() | 423 self._test_instance.apk_under_test.GetPermissions() |
| 413 if self._test_instance.apk_under_test | 424 if self._test_instance.apk_under_test |
| 414 else None) | 425 else None) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 if k in annotations: | 481 if k in annotations: |
| 471 timeout = v | 482 timeout = v |
| 472 break | 483 break |
| 473 else: | 484 else: |
| 474 logging.warning('Using default 1 minute timeout for %s', test_name) | 485 logging.warning('Using default 1 minute timeout for %s', test_name) |
| 475 timeout = 60 | 486 timeout = 60 |
| 476 | 487 |
| 477 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) | 488 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) |
| 478 | 489 |
| 479 return timeout | 490 return timeout |
| OLD | NEW |