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 20 matching lines...) Expand all Loading... |
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(failure_types) |
37 | 37 |
38 # FIXME: This is backwards. Each TestFailure subclass should know what | 38 # FIXME: This is backwards. Each TestFailure subclass should know what |
39 # test_expectation type it corresponds too. Then this method just | 39 # test_expectation type it corresponds too. Then this method just |
40 # collects them all from the failure list and returns the worst one. | 40 # collects them all from the failure list and returns the worst one. |
| 41 |
| 42 |
41 def determine_result_type(failure_list): | 43 def determine_result_type(failure_list): |
42 """Takes a set of test_failures and returns which result type best fits | 44 """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. | 45 the list of failures. "Best fits" means we use the worst type of failure. |
44 | 46 |
45 Returns: | 47 Returns: |
46 one of the test_expectations result types - PASS, FAIL, CRASH, etc.""" | 48 one of the test_expectations result types - PASS, FAIL, CRASH, etc.""" |
47 | 49 |
48 if not failure_list or len(failure_list) == 0: | 50 if not failure_list or len(failure_list) == 0: |
49 return test_expectations.PASS | 51 return test_expectations.PASS |
50 | 52 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 def dumps(self): | 107 def dumps(self): |
106 """Returns the string/JSON representation of a TestFailure.""" | 108 """Returns the string/JSON representation of a TestFailure.""" |
107 return cPickle.dumps(self) | 109 return cPickle.dumps(self) |
108 | 110 |
109 def driver_needs_restart(self): | 111 def driver_needs_restart(self): |
110 """Returns True if we should kill the driver before the next test.""" | 112 """Returns True if we should kill the driver before the next test.""" |
111 return False | 113 return False |
112 | 114 |
113 | 115 |
114 class FailureTimeout(TestFailure): | 116 class FailureTimeout(TestFailure): |
| 117 |
115 def __init__(self, is_reftest=False): | 118 def __init__(self, is_reftest=False): |
116 super(FailureTimeout, self).__init__() | 119 super(FailureTimeout, self).__init__() |
117 self.is_reftest = is_reftest | 120 self.is_reftest = is_reftest |
118 | 121 |
119 def message(self): | 122 def message(self): |
120 return "test timed out" | 123 return "test timed out" |
121 | 124 |
122 def driver_needs_restart(self): | 125 def driver_needs_restart(self): |
123 return True | 126 return True |
124 | 127 |
125 | 128 |
126 class FailureCrash(TestFailure): | 129 class FailureCrash(TestFailure): |
| 130 |
127 def __init__(self, is_reftest=False, process_name='content_shell', pid=None,
has_log=False): | 131 def __init__(self, is_reftest=False, process_name='content_shell', pid=None,
has_log=False): |
128 super(FailureCrash, self).__init__() | 132 super(FailureCrash, self).__init__() |
129 self.process_name = process_name | 133 self.process_name = process_name |
130 self.pid = pid | 134 self.pid = pid |
131 self.is_reftest = is_reftest | 135 self.is_reftest = is_reftest |
132 self.has_log = has_log | 136 self.has_log = has_log |
133 | 137 |
134 def message(self): | 138 def message(self): |
135 if self.pid: | 139 if self.pid: |
136 return "%s crashed [pid=%d]" % (self.process_name, self.pid) | 140 return "%s crashed [pid=%d]" % (self.process_name, self.pid) |
137 return self.process_name + " crashed" | 141 return self.process_name + " crashed" |
138 | 142 |
139 def driver_needs_restart(self): | 143 def driver_needs_restart(self): |
140 return True | 144 return True |
141 | 145 |
142 | 146 |
143 class FailureLeak(TestFailure): | 147 class FailureLeak(TestFailure): |
| 148 |
144 def __init__(self, is_reftest=False, log=''): | 149 def __init__(self, is_reftest=False, log=''): |
145 super(FailureLeak, self).__init__() | 150 super(FailureLeak, self).__init__() |
146 self.is_reftest = is_reftest | 151 self.is_reftest = is_reftest |
147 self.log = log | 152 self.log = log |
148 | 153 |
149 def message(self): | 154 def message(self): |
150 return "leak detected: %s" % (self.log) | 155 return "leak detected: %s" % (self.log) |
151 | 156 |
152 | 157 |
153 class FailureMissingResult(TestFailure): | 158 class FailureMissingResult(TestFailure): |
| 159 |
154 def message(self): | 160 def message(self): |
155 return "-expected.txt was missing" | 161 return "-expected.txt was missing" |
156 | 162 |
157 | 163 |
158 class FailureTestHarnessAssertion(TestFailure): | 164 class FailureTestHarnessAssertion(TestFailure): |
| 165 |
159 def message(self): | 166 def message(self): |
160 return "asserts failed" | 167 return "asserts failed" |
161 | 168 |
162 | 169 |
163 class FailureTextMismatch(TestFailure): | 170 class FailureTextMismatch(TestFailure): |
| 171 |
164 def message(self): | 172 def message(self): |
165 return "text diff" | 173 return "text diff" |
166 | 174 |
167 | 175 |
168 class FailureMissingImageHash(TestFailure): | 176 class FailureMissingImageHash(TestFailure): |
| 177 |
169 def message(self): | 178 def message(self): |
170 return "-expected.png was missing an embedded checksum" | 179 return "-expected.png was missing an embedded checksum" |
171 | 180 |
172 | 181 |
173 class FailureMissingImage(TestFailure): | 182 class FailureMissingImage(TestFailure): |
| 183 |
174 def message(self): | 184 def message(self): |
175 return "-expected.png was missing" | 185 return "-expected.png was missing" |
176 | 186 |
177 | 187 |
178 class FailureImageHashMismatch(TestFailure): | 188 class FailureImageHashMismatch(TestFailure): |
| 189 |
179 def message(self): | 190 def message(self): |
180 return "image diff" | 191 return "image diff" |
181 | 192 |
182 | 193 |
183 class FailureImageHashIncorrect(TestFailure): | 194 class FailureImageHashIncorrect(TestFailure): |
| 195 |
184 def message(self): | 196 def message(self): |
185 return "-expected.png embedded checksum is incorrect" | 197 return "-expected.png embedded checksum is incorrect" |
186 | 198 |
187 | 199 |
188 class FailureReftestMismatch(TestFailure): | 200 class FailureReftestMismatch(TestFailure): |
| 201 |
189 def __init__(self, reference_filename=None): | 202 def __init__(self, reference_filename=None): |
190 super(FailureReftestMismatch, self).__init__() | 203 super(FailureReftestMismatch, self).__init__() |
191 self.reference_filename = reference_filename | 204 self.reference_filename = reference_filename |
192 | 205 |
193 def message(self): | 206 def message(self): |
194 return "reference mismatch" | 207 return "reference mismatch" |
195 | 208 |
196 | 209 |
197 class FailureReftestMismatchDidNotOccur(TestFailure): | 210 class FailureReftestMismatchDidNotOccur(TestFailure): |
| 211 |
198 def __init__(self, reference_filename=None): | 212 def __init__(self, reference_filename=None): |
199 super(FailureReftestMismatchDidNotOccur, self).__init__() | 213 super(FailureReftestMismatchDidNotOccur, self).__init__() |
200 self.reference_filename = reference_filename | 214 self.reference_filename = reference_filename |
201 | 215 |
202 def message(self): | 216 def message(self): |
203 return "reference mismatch didn't happen" | 217 return "reference mismatch didn't happen" |
204 | 218 |
205 | 219 |
206 class FailureReftestNoImagesGenerated(TestFailure): | 220 class FailureReftestNoImagesGenerated(TestFailure): |
| 221 |
207 def __init__(self, reference_filename=None): | 222 def __init__(self, reference_filename=None): |
208 super(FailureReftestNoImagesGenerated, self).__init__() | 223 super(FailureReftestNoImagesGenerated, self).__init__() |
209 self.reference_filename = reference_filename | 224 self.reference_filename = reference_filename |
210 | 225 |
211 def message(self): | 226 def message(self): |
212 return "reference didn't generate pixel results." | 227 return "reference didn't generate pixel results." |
213 | 228 |
214 | 229 |
215 class FailureMissingAudio(TestFailure): | 230 class FailureMissingAudio(TestFailure): |
| 231 |
216 def message(self): | 232 def message(self): |
217 return "expected audio result was missing" | 233 return "expected audio result was missing" |
218 | 234 |
219 | 235 |
220 class FailureAudioMismatch(TestFailure): | 236 class FailureAudioMismatch(TestFailure): |
| 237 |
221 def message(self): | 238 def message(self): |
222 return "audio mismatch" | 239 return "audio mismatch" |
223 | 240 |
224 | 241 |
225 class FailureEarlyExit(TestFailure): | 242 class FailureEarlyExit(TestFailure): |
| 243 |
226 def message(self): | 244 def message(self): |
227 return "skipped due to early exit" | 245 return "skipped due to early exit" |
228 | 246 |
229 | 247 |
230 # Convenient collection of all failure classes for anything that might | 248 # Convenient collection of all failure classes for anything that might |
231 # need to enumerate over them all. | 249 # need to enumerate over them all. |
232 ALL_FAILURE_CLASSES = (FailureTimeout, FailureCrash, FailureMissingResult, | 250 ALL_FAILURE_CLASSES = (FailureTimeout, FailureCrash, FailureMissingResult, |
233 FailureTestHarnessAssertion, | 251 FailureTestHarnessAssertion, |
234 FailureTextMismatch, FailureMissingImageHash, | 252 FailureTextMismatch, FailureMissingImageHash, |
235 FailureMissingImage, FailureImageHashMismatch, | 253 FailureMissingImage, FailureImageHashMismatch, |
236 FailureImageHashIncorrect, FailureReftestMismatch, | 254 FailureImageHashIncorrect, FailureReftestMismatch, |
237 FailureReftestMismatchDidNotOccur, FailureReftestNoImages
Generated, | 255 FailureReftestMismatchDidNotOccur, FailureReftestNoImages
Generated, |
238 FailureMissingAudio, FailureAudioMismatch, | 256 FailureMissingAudio, FailureAudioMismatch, |
239 FailureEarlyExit) | 257 FailureEarlyExit) |
OLD | NEW |