| OLD | NEW |
| 1 # Copyright (C) 2011 Google Inc. All rights reserved. | 1 # Copyright (C) 2011 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 writer.write_image_files(driver_output.image, expected_driver_output
.image) | 58 writer.write_image_files(driver_output.image, expected_driver_output
.image) |
| 59 elif isinstance(failure, test_failures.FailureImageHashMismatch): | 59 elif isinstance(failure, test_failures.FailureImageHashMismatch): |
| 60 writer.write_image_files(driver_output.image, expected_driver_output
.image) | 60 writer.write_image_files(driver_output.image, expected_driver_output
.image) |
| 61 writer.write_image_diff_files(driver_output.image_diff) | 61 writer.write_image_diff_files(driver_output.image_diff) |
| 62 elif isinstance(failure, (test_failures.FailureAudioMismatch, | 62 elif isinstance(failure, (test_failures.FailureAudioMismatch, |
| 63 test_failures.FailureMissingAudio)): | 63 test_failures.FailureMissingAudio)): |
| 64 writer.write_audio_files(driver_output.audio, expected_driver_output
.audio) | 64 writer.write_audio_files(driver_output.audio, expected_driver_output
.audio) |
| 65 elif isinstance(failure, test_failures.FailureCrash): | 65 elif isinstance(failure, test_failures.FailureCrash): |
| 66 crashed_driver_output = expected_driver_output if failure.is_reftest
else driver_output | 66 crashed_driver_output = expected_driver_output if failure.is_reftest
else driver_output |
| 67 writer.write_crash_log(crashed_driver_output.crash_log) | 67 writer.write_crash_log(crashed_driver_output.crash_log) |
| 68 elif isinstance(failure, test_failures.FailureLeak): |
| 69 writer.write_leak_log(driver_output.leak_log) |
| 68 elif isinstance(failure, test_failures.FailureReftestMismatch): | 70 elif isinstance(failure, test_failures.FailureReftestMismatch): |
| 69 writer.write_image_files(driver_output.image, expected_driver_output
.image) | 71 writer.write_image_files(driver_output.image, expected_driver_output
.image) |
| 70 # FIXME: This work should be done earlier in the pipeline (e.g., whe
n we compare images for non-ref tests). | 72 # FIXME: This work should be done earlier in the pipeline (e.g., whe
n we compare images for non-ref tests). |
| 71 # FIXME: We should always have 2 images here. | 73 # FIXME: We should always have 2 images here. |
| 72 if driver_output.image and expected_driver_output.image: | 74 if driver_output.image and expected_driver_output.image: |
| 73 diff_image, err_str = port.diff_image(expected_driver_output.ima
ge, driver_output.image) | 75 diff_image, err_str = port.diff_image(expected_driver_output.ima
ge, driver_output.image) |
| 74 if diff_image: | 76 if diff_image: |
| 75 writer.write_image_diff_files(diff_image) | 77 writer.write_image_diff_files(diff_image) |
| 76 else: | 78 else: |
| 77 _log.warn('ref test mismatch did not produce an image diff.'
) | 79 _log.warn('ref test mismatch did not produce an image diff.'
) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 93 class TestResultWriter(object): | 95 class TestResultWriter(object): |
| 94 """A class which handles all writing operations to the result directory.""" | 96 """A class which handles all writing operations to the result directory.""" |
| 95 | 97 |
| 96 # Filename pieces when writing failures to the test results directory. | 98 # Filename pieces when writing failures to the test results directory. |
| 97 FILENAME_SUFFIX_ACTUAL = "-actual" | 99 FILENAME_SUFFIX_ACTUAL = "-actual" |
| 98 FILENAME_SUFFIX_EXPECTED = "-expected" | 100 FILENAME_SUFFIX_EXPECTED = "-expected" |
| 99 FILENAME_SUFFIX_DIFF = "-diff" | 101 FILENAME_SUFFIX_DIFF = "-diff" |
| 100 FILENAME_SUFFIX_STDERR = "-stderr" | 102 FILENAME_SUFFIX_STDERR = "-stderr" |
| 101 FILENAME_SUFFIX_CRASH_LOG = "-crash-log" | 103 FILENAME_SUFFIX_CRASH_LOG = "-crash-log" |
| 102 FILENAME_SUFFIX_SAMPLE = "-sample" | 104 FILENAME_SUFFIX_SAMPLE = "-sample" |
| 105 FILENAME_SUFFIX_LEAK_LOG = "-leak-log" |
| 103 FILENAME_SUFFIX_WDIFF = "-wdiff.html" | 106 FILENAME_SUFFIX_WDIFF = "-wdiff.html" |
| 104 FILENAME_SUFFIX_PRETTY_PATCH = "-pretty-diff.html" | 107 FILENAME_SUFFIX_PRETTY_PATCH = "-pretty-diff.html" |
| 105 FILENAME_SUFFIX_IMAGE_DIFF = "-diff.png" | 108 FILENAME_SUFFIX_IMAGE_DIFF = "-diff.png" |
| 106 FILENAME_SUFFIX_IMAGE_DIFFS_HTML = "-diffs.html" | 109 FILENAME_SUFFIX_IMAGE_DIFFS_HTML = "-diffs.html" |
| 107 | 110 |
| 108 def __init__(self, filesystem, port, root_output_dir, test_name): | 111 def __init__(self, filesystem, port, root_output_dir, test_name): |
| 109 self._filesystem = filesystem | 112 self._filesystem = filesystem |
| 110 self._port = port | 113 self._port = port |
| 111 self._root_output_dir = root_output_dir | 114 self._root_output_dir = root_output_dir |
| 112 self._test_name = test_name | 115 self._test_name = test_name |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 self._write_file(expected_filename, expected) | 165 self._write_file(expected_filename, expected) |
| 163 | 166 |
| 164 def write_stderr(self, error): | 167 def write_stderr(self, error): |
| 165 filename = self.output_filename(self.FILENAME_SUFFIX_STDERR + ".txt") | 168 filename = self.output_filename(self.FILENAME_SUFFIX_STDERR + ".txt") |
| 166 self._write_file(filename, error) | 169 self._write_file(filename, error) |
| 167 | 170 |
| 168 def write_crash_log(self, crash_log): | 171 def write_crash_log(self, crash_log): |
| 169 filename = self.output_filename(self.FILENAME_SUFFIX_CRASH_LOG + ".txt") | 172 filename = self.output_filename(self.FILENAME_SUFFIX_CRASH_LOG + ".txt") |
| 170 self._write_file(filename, crash_log.encode('utf8', 'replace')) | 173 self._write_file(filename, crash_log.encode('utf8', 'replace')) |
| 171 | 174 |
| 175 def write_leak_log(self, leak_log): |
| 176 filename = self.output_filename(self.FILENAME_SUFFIX_LEAK_LOG + ".txt") |
| 177 self._write_file(filename, leak_log) |
| 178 |
| 172 def copy_sample_file(self, sample_file): | 179 def copy_sample_file(self, sample_file): |
| 173 filename = self.output_filename(self.FILENAME_SUFFIX_SAMPLE + ".txt") | 180 filename = self.output_filename(self.FILENAME_SUFFIX_SAMPLE + ".txt") |
| 174 self._filesystem.copyfile(sample_file, filename) | 181 self._filesystem.copyfile(sample_file, filename) |
| 175 | 182 |
| 176 def write_text_files(self, actual_text, expected_text): | 183 def write_text_files(self, actual_text, expected_text): |
| 177 self.write_output_files(".txt", actual_text, expected_text) | 184 self.write_output_files(".txt", actual_text, expected_text) |
| 178 | 185 |
| 179 def create_text_diff_and_write_result(self, actual_text, expected_text): | 186 def create_text_diff_and_write_result(self, actual_text, expected_text): |
| 180 # FIXME: This function is actually doing the diffs as well as writing re
sults. | 187 # FIXME: This function is actually doing the diffs as well as writing re
sults. |
| 181 # It might be better to extract code which does 'diff' and make it a sep
arate function. | 188 # It might be better to extract code which does 'diff' and make it a sep
arate function. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 'diff_filename': self._output_testname(self.FILENAME_SUFFIX_IMAGE_DI
FF), | 274 'diff_filename': self._output_testname(self.FILENAME_SUFFIX_IMAGE_DI
FF), |
| 268 'prefix': self._output_testname(''), | 275 'prefix': self._output_testname(''), |
| 269 } | 276 } |
| 270 self._write_file(diffs_html_filename, html) | 277 self._write_file(diffs_html_filename, html) |
| 271 | 278 |
| 272 def write_reftest(self, src_filepath): | 279 def write_reftest(self, src_filepath): |
| 273 fs = self._filesystem | 280 fs = self._filesystem |
| 274 dst_dir = fs.dirname(fs.join(self._root_output_dir, self._test_name)) | 281 dst_dir = fs.dirname(fs.join(self._root_output_dir, self._test_name)) |
| 275 dst_filepath = fs.join(dst_dir, fs.basename(src_filepath)) | 282 dst_filepath = fs.join(dst_dir, fs.basename(src_filepath)) |
| 276 self._write_file(dst_filepath, fs.read_binary_file(src_filepath)) | 283 self._write_file(dst_filepath, fs.read_binary_file(src_filepath)) |
| OLD | NEW |