| 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 sys | 9 import sys |
| 10 import tempfile | 10 import tempfile |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 device.PullFile(diff_images_device_dir, temp_dir) | 540 device.PullFile(diff_images_device_dir, temp_dir) |
| 541 else: | 541 else: |
| 542 logging.error('Diff images not found on device.') | 542 logging.error('Diff images not found on device.') |
| 543 | 543 |
| 544 if device.FileExists(golden_images_device_dir): | 544 if device.FileExists(golden_images_device_dir): |
| 545 device.PullFile(golden_images_device_dir, temp_dir) | 545 device.PullFile(golden_images_device_dir, temp_dir) |
| 546 else: | 546 else: |
| 547 logging.error('Golden images not found on device.') | 547 logging.error('Golden images not found on device.') |
| 548 | 548 |
| 549 for failure_filename in os.listdir(os.path.join(temp_dir, 'failures')): | 549 for failure_filename in os.listdir(os.path.join(temp_dir, 'failures')): |
| 550 | |
| 551 m = RE_RENDER_IMAGE_NAME.match(failure_filename) | 550 m = RE_RENDER_IMAGE_NAME.match(failure_filename) |
| 552 if not m: | 551 if not m: |
| 553 logging.warning('Unexpected file in render test failures: %s', | 552 logging.warning('Unexpected file in render test failures: %s', |
| 554 failure_filename) | 553 failure_filename) |
| 555 continue | 554 continue |
| 556 | 555 |
| 557 failure_filepath = os.path.join(temp_dir, 'failures', failure_filename) | 556 failure_filepath = os.path.join(temp_dir, 'failures', failure_filename) |
| 558 failure_link = google_storage_helper.upload( | 557 failure_link = google_storage_helper.upload_content_addressed( |
| 559 google_storage_helper.unique_name( | 558 failure_filepath, bucket=render_tests_bucket) |
| 560 'failure_%s' % failure_filename, device=device), | |
| 561 failure_filepath, | |
| 562 bucket=render_tests_bucket) | |
| 563 | 559 |
| 564 golden_filepath = os.path.join(temp_dir, 'goldens', failure_filename) | 560 golden_filepath = os.path.join(temp_dir, 'goldens', failure_filename) |
| 565 if os.path.exists(golden_filepath): | 561 if os.path.exists(golden_filepath): |
| 566 golden_link = google_storage_helper.upload( | 562 golden_link = google_storage_helper.upload_content_addressed( |
| 567 google_storage_helper.unique_name( | 563 golden_filepath, bucket=render_tests_bucket) |
| 568 'golden_%s' % failure_filename, device=device), | |
| 569 golden_filepath, | |
| 570 bucket=render_tests_bucket) | |
| 571 else: | 564 else: |
| 572 golden_link = '' | 565 golden_link = '' |
| 573 | 566 |
| 574 diff_filepath = os.path.join(temp_dir, 'diffs', failure_filename) | 567 diff_filepath = os.path.join(temp_dir, 'diffs', failure_filename) |
| 575 if os.path.exists(diff_filepath): | 568 if os.path.exists(diff_filepath): |
| 576 diff_link = google_storage_helper.upload( | 569 diff_link = google_storage_helper.upload_content_addressed( |
| 577 google_storage_helper.unique_name( | 570 diff_filepath, bucket=render_tests_bucket) |
| 578 'diff_%s' % failure_filename, device=device), | |
| 579 diff_filepath, | |
| 580 bucket=render_tests_bucket) | |
| 581 else: | 571 else: |
| 582 diff_link = '' | 572 diff_link = '' |
| 583 | 573 |
| 584 with tempfile.NamedTemporaryFile(suffix='.html') as temp_html: | 574 with tempfile.NamedTemporaryFile(suffix='.html') as temp_html: |
| 585 jinja2_env = jinja2.Environment( | 575 jinja2_env = jinja2.Environment( |
| 586 loader=jinja2.FileSystemLoader(_JINJA_TEMPLATE_DIR), | 576 loader=jinja2.FileSystemLoader(_JINJA_TEMPLATE_DIR), |
| 587 trim_blocks=True) | 577 trim_blocks=True) |
| 588 template = jinja2_env.get_template(_JINJA_TEMPLATE_FILENAME) | 578 template = jinja2_env.get_template(_JINJA_TEMPLATE_FILENAME) |
| 589 # pylint: disable=no-member | 579 # pylint: disable=no-member |
| 590 processed_template_output = template.render( | 580 processed_template_output = template.render( |
| 591 failure_link=failure_link, | 581 failure_link=failure_link, |
| 592 golden_link=golden_link, | 582 golden_link=golden_link, |
| 593 diff_link=diff_link) | 583 diff_link=diff_link) |
| 594 | 584 |
| 595 temp_html.write(processed_template_output) | 585 temp_html.write(processed_template_output) |
| 596 temp_html.flush() | 586 temp_html.flush() |
| 597 html_results_link = google_storage_helper.upload( | 587 html_results_link = google_storage_helper.upload_content_addressed( |
| 598 google_storage_helper.unique_name('render_html', device=device), | |
| 599 temp_html.name, | 588 temp_html.name, |
| 600 bucket=render_tests_bucket, | 589 bucket=render_tests_bucket, |
| 601 content_type='text/html') | 590 content_type='text/html') |
| 602 for result in results: | 591 for result in results: |
| 603 result.SetLink(failure_filename, html_results_link) | 592 result.SetLink(failure_filename, html_results_link) |
| 604 | 593 |
| 605 #override | 594 #override |
| 606 def _ShouldRetry(self, test): | 595 def _ShouldRetry(self, test): |
| 607 if 'RetryOnFailure' in test.get('annotations', {}): | 596 if 'RetryOnFailure' in test.get('annotations', {}): |
| 608 return True | 597 return True |
| (...skipping 27 matching lines...) Expand all Loading... |
| 636 | 625 |
| 637 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) | 626 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) |
| 638 | 627 |
| 639 return timeout | 628 return timeout |
| 640 | 629 |
| 641 def _IsRenderTest(test): | 630 def _IsRenderTest(test): |
| 642 """Determines if a test or list of tests has a RenderTest amongst them.""" | 631 """Determines if a test or list of tests has a RenderTest amongst them.""" |
| 643 if not isinstance(test, list): | 632 if not isinstance(test, list): |
| 644 test = [test] | 633 test = [test] |
| 645 return any([RENDER_TEST_FEATURE_ANNOTATION in t['annotations'].get( | 634 return any([RENDER_TEST_FEATURE_ANNOTATION in t['annotations'].get( |
| 646 FEATURE_ANNOTATION, ()) for t in test]) | 635 FEATURE_ANNOTATION, {}).get('value', ()) for t in test]) |
| OLD | NEW |