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 |
11 # in the documentation and/or other materials provided with the | 11 # in the documentation and/or other materials provided with the |
12 # distribution. | 12 # distribution. |
13 # * Neither the name of Google Inc. nor the names of its | 13 # * Neither the name of Google Inc. nor the names of its |
14 # contributors may be used to endorse or promote products derived from | 14 # contributors may be used to endorse or promote products derived from |
15 # this software without specific prior written permission. | 15 # this software without specific prior written permission. |
16 # | 16 # |
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
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 from collections import namedtuple | |
Dirk Pranke
2017/03/20 23:22:27
Nit: this line goes between lines 32 and 34.
Gleb Lanbin
2017/03/21 17:31:52
Done.
| |
30 import logging | 31 import logging |
31 import re | 32 import re |
32 | 33 |
33 from webkitpy.layout_tests.controllers import repaint_overlay | 34 from webkitpy.layout_tests.controllers import repaint_overlay |
34 from webkitpy.layout_tests.controllers import test_result_writer | 35 from webkitpy.layout_tests.controllers import test_result_writer |
35 from webkitpy.layout_tests.port.driver import DeviceFailure, DriverInput, Driver Output | 36 from webkitpy.layout_tests.port.driver import DeviceFailure, DriverInput, Driver Output |
36 from webkitpy.layout_tests.models import test_expectations | 37 from webkitpy.layout_tests.models import test_expectations |
37 from webkitpy.layout_tests.models import test_failures | 38 from webkitpy.layout_tests.models import test_failures |
38 from webkitpy.layout_tests.models.test_results import TestResult | 39 from webkitpy.layout_tests.models.test_results import TestResult |
39 from webkitpy.layout_tests.models import testharness_results | 40 from webkitpy.layout_tests.models import testharness_results |
(...skipping 23 matching lines...) Expand all Loading... | |
63 self._port = port | 64 self._port = port |
64 self._filesystem = port.host.filesystem | 65 self._filesystem = port.host.filesystem |
65 self._options = options | 66 self._options = options |
66 self._results_directory = results_directory | 67 self._results_directory = results_directory |
67 self._driver = primary_driver | 68 self._driver = primary_driver |
68 self._reference_driver = primary_driver | 69 self._reference_driver = primary_driver |
69 self._timeout_ms = test_input.timeout_ms | 70 self._timeout_ms = test_input.timeout_ms |
70 self._worker_name = worker_name | 71 self._worker_name = worker_name |
71 self._test_name = test_input.test_name | 72 self._test_name = test_input.test_name |
72 self._should_run_pixel_test = test_input.should_run_pixel_test | 73 self._should_run_pixel_test = test_input.should_run_pixel_test |
74 self._should_run_pixel_test_first = ( | |
75 test_input.should_run_pixel_test_first) | |
73 self._reference_files = test_input.reference_files | 76 self._reference_files = test_input.reference_files |
74 self._should_add_missing_baselines = test_input.should_add_missing_basel ines | 77 self._should_add_missing_baselines = test_input.should_add_missing_basel ines |
75 self._stop_when_done = stop_when_done | 78 self._stop_when_done = stop_when_done |
76 | 79 |
77 # If this is a virtual test that uses the default flags instead of the | 80 # If this is a virtual test that uses the default flags instead of the |
78 # virtual flags for it's references, run it on the secondary driver so | 81 # virtual flags for it's references, run it on the secondary driver so |
79 # that the primary driver does not need to be restarted. | 82 # that the primary driver does not need to be restarted. |
80 if (secondary_driver and | 83 if (secondary_driver and |
81 self._port.is_virtual_test(self._test_name) and | 84 self._port.is_virtual_test(self._test_name) and |
82 not self._port.lookup_virtual_reference_args(self._test_name)): | 85 not self._port.lookup_virtual_reference_args(self._test_name)): |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 | 279 |
277 if driver_output.crash: | 280 if driver_output.crash: |
278 # Don't continue any more if we already have a crash. | 281 # Don't continue any more if we already have a crash. |
279 # In case of timeouts, we continue since we still want to see the te xt and image output. | 282 # In case of timeouts, we continue since we still want to see the te xt and image output. |
280 return TestResult(self._test_name, failures, driver_output.test_time , driver_output.has_stderr(), | 283 return TestResult(self._test_name, failures, driver_output.test_time , driver_output.has_stderr(), |
281 pid=driver_output.pid) | 284 pid=driver_output.pid) |
282 | 285 |
283 is_testharness_test, testharness_failures = self._compare_testharness_te st(driver_output, expected_driver_output) | 286 is_testharness_test, testharness_failures = self._compare_testharness_te st(driver_output, expected_driver_output) |
284 if is_testharness_test: | 287 if is_testharness_test: |
285 failures.extend(testharness_failures) | 288 failures.extend(testharness_failures) |
289 | |
290 function = namedtuple('Function', 'call args') | |
Dirk Pranke
2017/03/20 23:22:27
Nit: I would do this slightly different. I'd just
Gleb Lanbin
2017/03/21 17:31:52
Done.
| |
291 compare_functions = [] | |
292 compare_image_fn = function(self._compare_image, ( | |
293 expected_driver_output, driver_output)) | |
294 compare_txt_fn = function(self._compare_text, ( | |
295 expected_driver_output.text, driver_output.text)) | |
296 compare_audio_fn = function(self._compare_audio, ( | |
297 expected_driver_output.audio, driver_output.audio)) | |
298 | |
299 if self._should_run_pixel_test_first: | |
300 if driver_output.image_hash: | |
301 compare_functions.append(compare_image_fn) | |
302 else: | |
303 compare_functions.append(compare_txt_fn) | |
286 else: | 304 else: |
287 failures.extend(self._compare_text(expected_driver_output.text, driv er_output.text)) | 305 compare_functions.append(compare_txt_fn) |
288 failures.extend(self._compare_audio(expected_driver_output.audio, driver _output.audio)) | 306 if self._should_run_pixel_test: |
289 if self._should_run_pixel_test: | 307 compare_functions.append(compare_image_fn) |
290 failures.extend(self._compare_image(expected_driver_output, driver_o utput)) | 308 compare_functions.append(compare_audio_fn) |
309 | |
310 for compare_function in compare_functions: | |
Dirk Pranke
2017/03/20 23:22:27
and change this for line to:
for func, first_ar
Gleb Lanbin
2017/03/21 17:31:52
partially done. I switched to an unnamed tuple but
| |
311 failures.extend(compare_function.call(*compare_function.args)) | |
312 | |
291 has_repaint_overlay = (repaint_overlay.result_contains_repaint_rects(exp ected_driver_output.text) or | 313 has_repaint_overlay = (repaint_overlay.result_contains_repaint_rects(exp ected_driver_output.text) or |
292 repaint_overlay.result_contains_repaint_rects(dri ver_output.text)) | 314 repaint_overlay.result_contains_repaint_rects(dri ver_output.text)) |
293 return TestResult(self._test_name, failures, driver_output.test_time, dr iver_output.has_stderr(), | 315 return TestResult(self._test_name, failures, driver_output.test_time, dr iver_output.has_stderr(), |
294 pid=driver_output.pid, has_repaint_overlay=has_repaint _overlay) | 316 pid=driver_output.pid, has_repaint_overlay=has_repaint _overlay) |
295 | 317 |
296 def _compare_testharness_test(self, driver_output, expected_driver_output): | 318 def _compare_testharness_test(self, driver_output, expected_driver_output): |
297 if expected_driver_output.text: | 319 if expected_driver_output.text: |
298 return False, [] | 320 return False, [] |
299 | 321 |
300 if self._is_render_tree(driver_output.text): | 322 if self._is_render_tree(driver_output.text): |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
449 elif reference_driver_output.image_hash != actual_driver_output.image_ha sh: | 471 elif reference_driver_output.image_hash != actual_driver_output.image_ha sh: |
450 diff, err_str = self._port.diff_image(reference_driver_output.image, actual_driver_output.image) | 472 diff, err_str = self._port.diff_image(reference_driver_output.image, actual_driver_output.image) |
451 if diff: | 473 if diff: |
452 failures.append(test_failures.FailureReftestMismatch(reference_f ilename)) | 474 failures.append(test_failures.FailureReftestMismatch(reference_f ilename)) |
453 elif err_str: | 475 elif err_str: |
454 _log.error(err_str) | 476 _log.error(err_str) |
455 else: | 477 else: |
456 _log.warning(" %s -> ref test hashes didn't match but diff pass ed", self._test_name) | 478 _log.warning(" %s -> ref test hashes didn't match but diff pass ed", self._test_name) |
457 | 479 |
458 return TestResult(self._test_name, failures, 0, has_stderr, pid=actual_d river_output.pid) | 480 return TestResult(self._test_name, failures, 0, has_stderr, pid=actual_d river_output.pid) |
OLD | NEW |