Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_result_writer.py (159977 => 159978)
--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_result_writer.py 2013-12-02 23:52:34 UTC (rev 159977)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_result_writer.py 2013-12-02 23:55:06 UTC (rev 159978)
@@ -45,44 +45,8 @@
writer.write_stderr(driver_output.error)
for failure in failures:
- # FIXME: Instead of this long 'if' block, each failure class might
- # have a responsibility for writing a test result.
- if isinstance(failure, (test_failures.FailureMissingResult,
- test_failures.FailureTextMismatch)):
- writer.write_text_files(driver_output.text, expected_driver_output.text)
- writer.create_text_diff_and_write_result(driver_output.text, expected_driver_output.text)
- elif isinstance(failure, test_failures.FailureMissingImage):
- writer.write_image_files(driver_output.image, expected_image=None)
- elif isinstance(failure, test_failures.FailureMissingImageHash):
- writer.write_image_files(driver_output.image, expected_driver_output.image)
- elif isinstance(failure, test_failures.FailureImageHashMismatch):
- writer.write_image_files(driver_output.image, expected_driver_output.image)
- writer.write_image_diff_files(driver_output.image_diff)
- elif isinstance(failure, (test_failures.FailureAudioMismatch,
- test_failures.FailureMissingAudio)):
- writer.write_audio_files(driver_output.audio, expected_driver_output.audio)
- elif isinstance(failure, test_failures.FailureCrash):
- crashed_driver_output = expected_driver_output if failure.is_reftest else driver_output
- writer.write_crash_log(crashed_driver_output.crash_log)
- elif isinstance(failure, test_failures.FailureReftestMismatch):
- writer.write_image_files(driver_output.image, expected_driver_output.image)
- # FIXME: This work should be done earlier in the pipeline (e.g., when we compare images for non-ref tests).
- # FIXME: We should always have 2 images here.
- if driver_output.image and expected_driver_output.image:
- diff_image, diff_percent, err_str = port.diff_image(expected_driver_output.image, driver_output.image, tolerance=0)
- if diff_image:
- writer.write_image_diff_files(diff_image)
- failure.diff_percent = diff_percent
- else:
- _log.warn('ref test mismatch did not produce an image diff.')
- writer.write_reftest(failure.reference_filename)
- elif isinstance(failure, test_failures.FailureReftestMismatchDidNotOccur):
- writer.write_image_files(driver_output.image, expected_image=None)
- writer.write_reftest(failure.reference_filename)
- else:
- assert isinstance(failure, (test_failures.FailureTimeout, test_failures.FailureReftestNoImagesGenerated))
+ failure.write_failure(writer, driver_output, expected_driver_output, port)
-
class TestResultWriter(object):
"""A class which handles all writing operations to the result directory."""
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/models/test_failures.py (159977 => 159978)
--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_failures.py 2013-12-02 23:52:34 UTC (rev 159977)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_failures.py 2013-12-02 23:55:06 UTC (rev 159978)
@@ -27,9 +27,11 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import cPickle
+import logging
from webkitpy.layout_tests.models import test_expectations
+_log = logging.getLogger(__name__)
def is_reftest_failure(failure_list):
failure_types = [type(f) for f in failure_list]
@@ -107,7 +109,21 @@
"""Returns True if we should kill DumpRenderTree/WebKitTestRunner before the next test."""
return False
+ def write_failure(self, writer, driver_output, expected_driver_output, port):
+ assert isinstance(self, (FailureTimeout, FailureReftestNoImagesGenerated))
+
+class FailureText(TestFailure):
+ def write_failure(self, writer, driver_output, expected_driver_output, port):
+ writer.write_text_files(driver_output.text, expected_driver_output.text)
+ writer.create_text_diff_and_write_result(driver_output.text, expected_driver_output.text)
+
+
+class FailureAudio(TestFailure):
+ def write_failure(self, writer, driver_output, expected_driver_output, port):
+ writer.write_audio_files(driver_output.audio, expected_driver_output.audio)
+
+
class FailureTimeout(TestFailure):
def __init__(self, is_reftest=False):
super(FailureTimeout, self).__init__()
@@ -135,26 +151,37 @@
def driver_needs_restart(self):
return True
+ def write_failure(self, writer, driver_output, expected_driver_output, port):
+ crashed_driver_output = expected_driver_output if self.is_reftest else driver_output
+ writer.write_crash_log(crashed_driver_output.crash_log)
-class FailureMissingResult(TestFailure):
+
+class FailureMissingResult(FailureText):
def message(self):
return "-expected.txt was missing"
-class FailureTextMismatch(TestFailure):
+class FailureTextMismatch(FailureText):
def message(self):
return "text diff"
+
class FailureMissingImageHash(TestFailure):
def message(self):
return "-expected.png was missing an embedded checksum"
+ def write_failure(self, writer, driver_output, expected_driver_output, port):
+ writer.write_image_files(driver_output.image, expected_driver_output.image)
+
class FailureMissingImage(TestFailure):
def message(self):
return "-expected.png was missing"
+ def write_failure(self, writer, driver_output, expected_driver_output, port):
+ writer.write_image_files(driver_output.image, expected_image=None)
+
class FailureImageHashMismatch(TestFailure):
def __init__(self, diff_percent=0):
super(FailureImageHashMismatch, self).__init__()
@@ -163,7 +190,11 @@
def message(self):
return "image diff"
+ def write_failure(self, writer, driver_output, expected_driver_output, port):
+ writer.write_image_files(driver_output.image, expected_driver_output.image)
+ writer.write_image_diff_files(driver_output.image_diff)
+
class FailureImageHashIncorrect(TestFailure):
def message(self):
return "-expected.png embedded checksum is incorrect"
@@ -178,7 +209,20 @@
def message(self):
return "reference mismatch"
+ def write_failure(self, writer, driver_output, expected_driver_output, port):
+ writer.write_image_files(driver_output.image, expected_driver_output.image)
+ # FIXME: This work should be done earlier in the pipeline (e.g., when we compare images for non-ref tests).
+ # FIXME: We should always have 2 images here.
+ if driver_output.image and expected_driver_output.image:
+ diff_image, diff_percent, err_str = port.diff_image(expected_driver_output.image, driver_output.image, tolerance=0)
+ if diff_image:
+ writer.write_image_diff_files(diff_image)
+ self.diff_percent = diff_percent
+ else:
+ _log.warn('ref test mismatch did not produce an image diff.')
+ writer.write_reftest(self.reference_filename)
+
class FailureReftestMismatchDidNotOccur(TestFailure):
def __init__(self, reference_filename=None):
super(FailureReftestMismatchDidNotOccur, self).__init__()
@@ -187,6 +231,9 @@
def message(self):
return "reference mismatch didn't happen"
+ def write_failure(self, writer, driver_output, expected_driver_output, port):
+ writer.write_image_files(driver_output.image, expected_image=None)
+ writer.write_reftest(self.reference_filename)
class FailureReftestNoImagesGenerated(TestFailure):
def __init__(self, reference_filename=None):
@@ -197,12 +244,12 @@
return "reference didn't generate pixel results."
-class FailureMissingAudio(TestFailure):
+class FailureMissingAudio(FailureAudio):
def message(self):
return "expected audio result was missing"
-class FailureAudioMismatch(TestFailure):
+class FailureAudioMismatch(FailureAudio):
def message(self):
return "audio mismatch"