| OLD | NEW |
| 1 # Copyright (C) 2010 Google Inc. All rights reserved. | 1 # Copyright (C) 2010 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 15 matching lines...) Expand all Loading... |
| 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 import cPickle | 29 import cPickle |
| 30 | 30 |
| 31 from webkitpy.layout_tests.models import test_expectations | 31 from webkitpy.layout_tests.models import test_expectations |
| 32 | 32 |
| 33 | 33 |
| 34 def is_reftest_failure(failure_list): | 34 def is_reftest_failure(failure_list): |
| 35 failure_types = [type(f) for f in failure_list] | 35 failure_types = [type(f) for f in failure_list] |
| 36 return set((FailureReftestMismatch, FailureReftestMismatchDidNotOccur, Failu
reReftestNoImagesGenerated)).intersection(failure_types) | 36 return set((FailureReftestMismatch, FailureReftestMismatchDidNotOccur, Failu
reReftestNoImagesGenerated)).intersection( |
| 37 failure_types) |
| 37 | 38 |
| 38 # FIXME: This is backwards. Each TestFailure subclass should know what | 39 # FIXME: This is backwards. Each TestFailure subclass should know what |
| 39 # test_expectation type it corresponds too. Then this method just | 40 # test_expectation type it corresponds too. Then this method just |
| 40 # collects them all from the failure list and returns the worst one. | 41 # collects them all from the failure list and returns the worst one. |
| 42 |
| 43 |
| 41 def determine_result_type(failure_list): | 44 def determine_result_type(failure_list): |
| 42 """Takes a set of test_failures and returns which result type best fits | 45 """Takes a set of test_failures and returns which result type best fits |
| 43 the list of failures. "Best fits" means we use the worst type of failure. | 46 the list of failures. "Best fits" means we use the worst type of failure. |
| 44 | 47 |
| 45 Returns: | 48 Returns: |
| 46 one of the test_expectations result types - PASS, FAIL, CRASH, etc.""" | 49 one of the test_expectations result types - PASS, FAIL, CRASH, etc.""" |
| 47 | 50 |
| 48 if not failure_list or len(failure_list) == 0: | 51 if not failure_list or len(failure_list) == 0: |
| 49 return test_expectations.PASS | 52 return test_expectations.PASS |
| 50 | 53 |
| 51 failure_types = [type(f) for f in failure_list] | 54 failure_types = [type(f) for f in failure_list] |
| 52 if FailureCrash in failure_types: | 55 if FailureCrash in failure_types: |
| 53 return test_expectations.CRASH | 56 return test_expectations.CRASH |
| 54 elif FailureLeak in failure_types: | 57 elif FailureLeak in failure_types: |
| 55 return test_expectations.LEAK | 58 return test_expectations.LEAK |
| 56 elif FailureTimeout in failure_types: | 59 elif FailureTimeout in failure_types: |
| 57 return test_expectations.TIMEOUT | 60 return test_expectations.TIMEOUT |
| 58 elif FailureEarlyExit in failure_types: | 61 elif FailureEarlyExit in failure_types: |
| 59 return test_expectations.SKIP | 62 return test_expectations.SKIP |
| 60 elif (FailureMissingResult in failure_types or | 63 elif (FailureMissingResult in failure_types or FailureMissingImage in failur
e_types or |
| 61 FailureMissingImage in failure_types or | 64 FailureMissingImageHash in failure_types or FailureMissingAudio in fai
lure_types): |
| 62 FailureMissingImageHash in failure_types or | |
| 63 FailureMissingAudio in failure_types): | |
| 64 return test_expectations.MISSING | 65 return test_expectations.MISSING |
| 65 else: | 66 else: |
| 66 is_text_failure = (FailureTextMismatch in failure_types or | 67 is_text_failure = (FailureTextMismatch in failure_types or FailureTestHa
rnessAssertion in failure_types) |
| 67 FailureTestHarnessAssertion in failure_types) | 68 is_image_failure = (FailureImageHashIncorrect in failure_types or Failur
eImageHashMismatch in failure_types) |
| 68 is_image_failure = (FailureImageHashIncorrect in failure_types or | |
| 69 FailureImageHashMismatch in failure_types) | |
| 70 is_audio_failure = (FailureAudioMismatch in failure_types) | 69 is_audio_failure = (FailureAudioMismatch in failure_types) |
| 71 if is_text_failure and is_image_failure: | 70 if is_text_failure and is_image_failure: |
| 72 return test_expectations.IMAGE_PLUS_TEXT | 71 return test_expectations.IMAGE_PLUS_TEXT |
| 73 elif is_text_failure: | 72 elif is_text_failure: |
| 74 return test_expectations.TEXT | 73 return test_expectations.TEXT |
| 75 elif is_image_failure or is_reftest_failure(failure_list): | 74 elif is_image_failure or is_reftest_failure(failure_list): |
| 76 return test_expectations.IMAGE | 75 return test_expectations.IMAGE |
| 77 elif is_audio_failure: | 76 elif is_audio_failure: |
| 78 return test_expectations.AUDIO | 77 return test_expectations.AUDIO |
| 79 else: | 78 else: |
| 80 raise ValueError("unclassifiable set of failures: " | 79 raise ValueError("unclassifiable set of failures: " + str(failure_ty
pes)) |
| 81 + str(failure_types)) | |
| 82 | 80 |
| 83 | 81 |
| 84 class TestFailure(object): | 82 class TestFailure(object): |
| 85 """Abstract base class that defines the failure interface.""" | 83 """Abstract base class that defines the failure interface.""" |
| 86 | 84 |
| 87 @staticmethod | 85 @staticmethod |
| 88 def loads(s): | 86 def loads(s): |
| 89 """Creates a TestFailure object from the specified string.""" | 87 """Creates a TestFailure object from the specified string.""" |
| 90 return cPickle.loads(s) | 88 return cPickle.loads(s) |
| 91 | 89 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 217 |
| 220 class FailureAudioMismatch(TestFailure): | 218 class FailureAudioMismatch(TestFailure): |
| 221 def message(self): | 219 def message(self): |
| 222 return "audio mismatch" | 220 return "audio mismatch" |
| 223 | 221 |
| 224 | 222 |
| 225 class FailureEarlyExit(TestFailure): | 223 class FailureEarlyExit(TestFailure): |
| 226 def message(self): | 224 def message(self): |
| 227 return "skipped due to early exit" | 225 return "skipped due to early exit" |
| 228 | 226 |
| 229 | |
| 230 # Convenient collection of all failure classes for anything that might | 227 # Convenient collection of all failure classes for anything that might |
| 231 # need to enumerate over them all. | 228 # need to enumerate over them all. |
| 232 ALL_FAILURE_CLASSES = (FailureTimeout, FailureCrash, FailureMissingResult, | 229 ALL_FAILURE_CLASSES = (FailureTimeout, FailureCrash, FailureMissingResult, Failu
reTestHarnessAssertion, FailureTextMismatch, |
| 233 FailureTestHarnessAssertion, | 230 FailureMissingImageHash, FailureMissingImage, FailureImag
eHashMismatch, FailureImageHashIncorrect, |
| 234 FailureTextMismatch, FailureMissingImageHash, | 231 FailureReftestMismatch, FailureReftestMismatchDidNotOccur
, FailureReftestNoImagesGenerated, |
| 235 FailureMissingImage, FailureImageHashMismatch, | 232 FailureMissingAudio, FailureAudioMismatch, FailureEarlyEx
it) |
| 236 FailureImageHashIncorrect, FailureReftestMismatch, | |
| 237 FailureReftestMismatchDidNotOccur, FailureReftestNoImages
Generated, | |
| 238 FailureMissingAudio, FailureAudioMismatch, | |
| 239 FailureEarlyExit) | |
| OLD | NEW |