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

Side by Side Diff: Tools/Scripts/webkitpy/layout_tests/controllers/test_result_writer.py

Issue 303223008: Overlay expected and actual repaint rects for LayoutTests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add several small features Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 11 matching lines...) Expand all
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
29 29
30 import logging 30 import logging
31 31
32 from webkitpy.layout_tests.controllers import repaint_overlay
32 from webkitpy.layout_tests.models import test_failures 33 from webkitpy.layout_tests.models import test_failures
33 34
34 35
35 _log = logging.getLogger(__name__) 36 _log = logging.getLogger(__name__)
36 37
37 38
38 def write_test_result(filesystem, port, results_directory, test_name, driver_out put, 39 def write_test_result(filesystem, port, results_directory, test_name, driver_out put,
39 expected_driver_output, failures): 40 expected_driver_output, failures):
40 """Write the test result to the result output directory.""" 41 """Write the test result to the result output directory."""
41 root_output_dir = results_directory 42 root_output_dir = results_directory
42 writer = TestResultWriter(filesystem, port, root_output_dir, test_name) 43 writer = TestResultWriter(filesystem, port, root_output_dir, test_name)
43 44
44 if driver_output.error: 45 if driver_output.error:
45 writer.write_stderr(driver_output.error) 46 writer.write_stderr(driver_output.error)
46 47
47 for failure in failures: 48 for failure in failures:
48 # FIXME: Instead of this long 'if' block, each failure class might 49 # FIXME: Instead of this long 'if' block, each failure class might
49 # have a responsibility for writing a test result. 50 # have a responsibility for writing a test result.
50 if isinstance(failure, (test_failures.FailureMissingResult, 51 if isinstance(failure, (test_failures.FailureMissingResult,
51 test_failures.FailureTextMismatch, 52 test_failures.FailureTextMismatch,
52 test_failures.FailureTestHarnessAssertion)): 53 test_failures.FailureTestHarnessAssertion)):
53 writer.write_text_files(driver_output.text, expected_driver_output.t ext) 54 writer.write_text_files(driver_output.text, expected_driver_output.t ext)
54 writer.create_text_diff_and_write_result(driver_output.text, expecte d_driver_output.text) 55 writer.create_text_diff_and_write_result(driver_output.text, expecte d_driver_output.text)
56 writer.create_repaint_overlay_result(driver_output.text, expected_dr iver_output.text)
55 elif isinstance(failure, test_failures.FailureMissingImage): 57 elif isinstance(failure, test_failures.FailureMissingImage):
56 writer.write_image_files(driver_output.image, expected_image=None) 58 writer.write_image_files(driver_output.image, expected_image=None)
57 elif isinstance(failure, test_failures.FailureMissingImageHash): 59 elif isinstance(failure, test_failures.FailureMissingImageHash):
58 writer.write_image_files(driver_output.image, expected_driver_output .image) 60 writer.write_image_files(driver_output.image, expected_driver_output .image)
59 elif isinstance(failure, test_failures.FailureImageHashMismatch): 61 elif isinstance(failure, test_failures.FailureImageHashMismatch):
60 writer.write_image_files(driver_output.image, expected_driver_output .image) 62 writer.write_image_files(driver_output.image, expected_driver_output .image)
61 writer.write_image_diff_files(driver_output.image_diff) 63 writer.write_image_diff_files(driver_output.image_diff)
62 elif isinstance(failure, (test_failures.FailureAudioMismatch, 64 elif isinstance(failure, (test_failures.FailureAudioMismatch,
63 test_failures.FailureMissingAudio)): 65 test_failures.FailureMissingAudio)):
64 writer.write_audio_files(driver_output.audio, expected_driver_output .audio) 66 writer.write_audio_files(driver_output.audio, expected_driver_output .audio)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 FILENAME_SUFFIX_EXPECTED = "-expected" 102 FILENAME_SUFFIX_EXPECTED = "-expected"
101 FILENAME_SUFFIX_DIFF = "-diff" 103 FILENAME_SUFFIX_DIFF = "-diff"
102 FILENAME_SUFFIX_STDERR = "-stderr" 104 FILENAME_SUFFIX_STDERR = "-stderr"
103 FILENAME_SUFFIX_CRASH_LOG = "-crash-log" 105 FILENAME_SUFFIX_CRASH_LOG = "-crash-log"
104 FILENAME_SUFFIX_SAMPLE = "-sample" 106 FILENAME_SUFFIX_SAMPLE = "-sample"
105 FILENAME_SUFFIX_LEAK_LOG = "-leak-log" 107 FILENAME_SUFFIX_LEAK_LOG = "-leak-log"
106 FILENAME_SUFFIX_WDIFF = "-wdiff.html" 108 FILENAME_SUFFIX_WDIFF = "-wdiff.html"
107 FILENAME_SUFFIX_PRETTY_PATCH = "-pretty-diff.html" 109 FILENAME_SUFFIX_PRETTY_PATCH = "-pretty-diff.html"
108 FILENAME_SUFFIX_IMAGE_DIFF = "-diff.png" 110 FILENAME_SUFFIX_IMAGE_DIFF = "-diff.png"
109 FILENAME_SUFFIX_IMAGE_DIFFS_HTML = "-diffs.html" 111 FILENAME_SUFFIX_IMAGE_DIFFS_HTML = "-diffs.html"
112 FILENAME_SUFFIX_OVERLAY = "-overlay.html"
110 113
111 def __init__(self, filesystem, port, root_output_dir, test_name): 114 def __init__(self, filesystem, port, root_output_dir, test_name):
112 self._filesystem = filesystem 115 self._filesystem = filesystem
113 self._port = port 116 self._port = port
114 self._root_output_dir = root_output_dir 117 self._root_output_dir = root_output_dir
115 self._test_name = test_name 118 self._test_name = test_name
116 119
117 def _make_output_directory(self): 120 def _make_output_directory(self):
118 """Creates the output directory (if needed) for a given test filename."" " 121 """Creates the output directory (if needed) for a given test filename."" "
119 fs = self._filesystem 122 fs = self._filesystem
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 wdiff = self._port.wdiff_text(expected_filename, actual_filename) 206 wdiff = self._port.wdiff_text(expected_filename, actual_filename)
204 wdiff_filename = self.output_filename(self.FILENAME_SUFFIX_WDIFF) 207 wdiff_filename = self.output_filename(self.FILENAME_SUFFIX_WDIFF)
205 self._write_file(wdiff_filename, wdiff) 208 self._write_file(wdiff_filename, wdiff)
206 209
207 # Use WebKit's PrettyPatch.rb to get an HTML diff. 210 # Use WebKit's PrettyPatch.rb to get an HTML diff.
208 if self._port.pretty_patch_available(): 211 if self._port.pretty_patch_available():
209 pretty_patch = self._port.pretty_patch_text(diff_filename) 212 pretty_patch = self._port.pretty_patch_text(diff_filename)
210 pretty_patch_filename = self.output_filename(self.FILENAME_SUFFIX_PR ETTY_PATCH) 213 pretty_patch_filename = self.output_filename(self.FILENAME_SUFFIX_PR ETTY_PATCH)
211 self._write_file(pretty_patch_filename, pretty_patch) 214 self._write_file(pretty_patch_filename, pretty_patch)
212 215
216 def create_repaint_overlay_result(self, actual_text, expected_text):
217 html = repaint_overlay.generate_repaint_overlay_html(self._test_name, ac tual_text, expected_text)
218 if html:
219 overlay_filename = self.output_filename(self.FILENAME_SUFFIX_OVERLAY )
220 self._write_file(overlay_filename, html)
221
213 def write_audio_files(self, actual_audio, expected_audio): 222 def write_audio_files(self, actual_audio, expected_audio):
214 self.write_output_files('.wav', actual_audio, expected_audio) 223 self.write_output_files('.wav', actual_audio, expected_audio)
215 224
216 def write_image_files(self, actual_image, expected_image): 225 def write_image_files(self, actual_image, expected_image):
217 self.write_output_files('.png', actual_image, expected_image) 226 self.write_output_files('.png', actual_image, expected_image)
218 227
219 def write_image_diff_files(self, image_diff): 228 def write_image_diff_files(self, image_diff):
220 diff_filename = self.output_filename(self.FILENAME_SUFFIX_IMAGE_DIFF) 229 diff_filename = self.output_filename(self.FILENAME_SUFFIX_IMAGE_DIFF)
221 self._write_file(diff_filename, image_diff) 230 self._write_file(diff_filename, image_diff)
222 231
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 'diff_filename': self._output_testname(self.FILENAME_SUFFIX_IMAGE_DI FF), 283 'diff_filename': self._output_testname(self.FILENAME_SUFFIX_IMAGE_DI FF),
275 'prefix': self._output_testname(''), 284 'prefix': self._output_testname(''),
276 } 285 }
277 self._write_file(diffs_html_filename, html) 286 self._write_file(diffs_html_filename, html)
278 287
279 def write_reftest(self, src_filepath): 288 def write_reftest(self, src_filepath):
280 fs = self._filesystem 289 fs = self._filesystem
281 dst_dir = fs.dirname(fs.join(self._root_output_dir, self._test_name)) 290 dst_dir = fs.dirname(fs.join(self._root_output_dir, self._test_name))
282 dst_filepath = fs.join(dst_dir, fs.basename(src_filepath)) 291 dst_filepath = fs.join(dst_dir, fs.basename(src_filepath))
283 self._write_file(dst_filepath, fs.read_binary_file(src_filepath)) 292 self._write_file(dst_filepath, fs.read_binary_file(src_filepath))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698