OLD | NEW |
1 # Copyright 2012 the V8 project authors. All rights reserved. | 1 # Copyright 2012 the V8 project authors. All rights reserved. |
2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
4 # met: | 4 # met: |
5 # | 5 # |
6 # * Redistributions of source code must retain the above copyright | 6 # * Redistributions of source code must retain the above copyright |
7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
8 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 # Rerun slow tests at most once. | 119 # Rerun slow tests at most once. |
120 return | 120 return |
121 | 121 |
122 # Rerun this test. | 122 # Rerun this test. |
123 test.duration = None | 123 test.duration = None |
124 test.output = None | 124 test.output = None |
125 test.run += 1 | 125 test.run += 1 |
126 pool.add([self._GetJob(test)]) | 126 pool.add([self._GetJob(test)]) |
127 self.remaining += 1 | 127 self.remaining += 1 |
128 | 128 |
| 129 def _ProcessTestNormal(self, test, result, pool): |
| 130 self.indicator.AboutToRun(test) |
| 131 test.output = result[1] |
| 132 test.duration = result[2] |
| 133 has_unexpected_output = test.suite.HasUnexpectedOutput(test) |
| 134 if has_unexpected_output: |
| 135 self.failed.append(test) |
| 136 if test.output.HasCrashed(): |
| 137 self.crashed += 1 |
| 138 else: |
| 139 self.succeeded += 1 |
| 140 self.remaining -= 1 |
| 141 self.indicator.HasRun(test, has_unexpected_output) |
| 142 if has_unexpected_output: |
| 143 # Rerun test failures after the indicator has processed the results. |
| 144 self._MaybeRerun(pool, test) |
| 145 # Update the perf database if the test succeeded. |
| 146 return not has_unexpected_output |
| 147 |
| 148 def _ProcessTestPredictable(self, test, result, pool): |
| 149 # Always pass the test duration for the database update. |
| 150 test.duration = result[2] |
| 151 if test.run == 1 and result[1].HasTimedOut(): |
| 152 # If we get a timeout in the first run, we are already in an |
| 153 # unpredictable state. Just report it as a failure and don't rerun. |
| 154 self.indicator.AboutToRun(test) |
| 155 test.output = result[1] |
| 156 self.remaining -= 1 |
| 157 self.failed.append(test) |
| 158 self.indicator.HasRun(test, True) |
| 159 if test.run > 1 and test.output != result[1]: |
| 160 # From the second run on, check for differences. If a difference is |
| 161 # found, call the indicator twice to report both tests. All runs of each |
| 162 # test are counted as one for the statistic. |
| 163 self.indicator.AboutToRun(test) |
| 164 self.remaining -= 1 |
| 165 self.failed.append(test) |
| 166 self.indicator.HasRun(test, True) |
| 167 self.indicator.AboutToRun(test) |
| 168 test.output = result[1] |
| 169 self.indicator.HasRun(test, True) |
| 170 elif test.run >= 3: |
| 171 # No difference on the third run -> report a success. |
| 172 self.indicator.AboutToRun(test) |
| 173 self.remaining -= 1 |
| 174 self.succeeded += 1 |
| 175 test.output = result[1] |
| 176 self.indicator.HasRun(test, False) |
| 177 else: |
| 178 # No difference yet and less than three runs -> add another run and |
| 179 # remember the output for comparison. |
| 180 test.run += 1 |
| 181 test.output = result[1] |
| 182 pool.add([self._GetJob(test)]) |
| 183 # Always update the perf database. |
| 184 return True |
| 185 |
129 def Run(self, jobs): | 186 def Run(self, jobs): |
130 self.indicator.Starting() | 187 self.indicator.Starting() |
131 self._RunInternal(jobs) | 188 self._RunInternal(jobs) |
132 self.indicator.Done() | 189 self.indicator.Done() |
133 if self.failed or self.remaining: | 190 if self.failed or self.remaining: |
134 return 1 | 191 return 1 |
135 return 0 | 192 return 0 |
136 | 193 |
137 def _RunInternal(self, jobs): | 194 def _RunInternal(self, jobs): |
138 pool = Pool(jobs) | 195 pool = Pool(jobs) |
(...skipping 10 matching lines...) Expand all Loading... |
149 queue.append([self._GetJob(test)]) | 206 queue.append([self._GetJob(test)]) |
150 except Exception, e: | 207 except Exception, e: |
151 # If this failed, save the exception and re-raise it later (after | 208 # If this failed, save the exception and re-raise it later (after |
152 # all other tests have had a chance to run). | 209 # all other tests have had a chance to run). |
153 queued_exception = e | 210 queued_exception = e |
154 continue | 211 continue |
155 try: | 212 try: |
156 it = pool.imap_unordered(RunTest, queue) | 213 it = pool.imap_unordered(RunTest, queue) |
157 for result in it: | 214 for result in it: |
158 test = test_map[result[0]] | 215 test = test_map[result[0]] |
159 self.indicator.AboutToRun(test) | 216 if self.context.predictable: |
160 test.output = result[1] | 217 update_perf = self._ProcessTestPredictable(test, result, pool) |
161 test.duration = result[2] | |
162 has_unexpected_output = test.suite.HasUnexpectedOutput(test) | |
163 if has_unexpected_output: | |
164 self.failed.append(test) | |
165 if test.output.HasCrashed(): | |
166 self.crashed += 1 | |
167 else: | 218 else: |
| 219 update_perf = self._ProcessTestNormal(test, result, pool) |
| 220 if update_perf: |
168 self._RunPerfSafe(lambda: self.perfdata.UpdatePerfData(test)) | 221 self._RunPerfSafe(lambda: self.perfdata.UpdatePerfData(test)) |
169 self.succeeded += 1 | |
170 self.remaining -= 1 | |
171 self.indicator.HasRun(test, has_unexpected_output) | |
172 if has_unexpected_output: | |
173 # Rerun test failures after the indicator has processed the results. | |
174 self._MaybeRerun(pool, test) | |
175 finally: | 222 finally: |
176 pool.terminate() | 223 pool.terminate() |
177 self._RunPerfSafe(lambda: self.perf_data_manager.close()) | 224 self._RunPerfSafe(lambda: self.perf_data_manager.close()) |
178 if self.perf_failures: | 225 if self.perf_failures: |
179 # Nuke perf data in case of failures. This might not work on windows as | 226 # Nuke perf data in case of failures. This might not work on windows as |
180 # some files might still be open. | 227 # some files might still be open. |
181 print "Deleting perf test data due to db corruption." | 228 print "Deleting perf test data due to db corruption." |
182 shutil.rmtree(self.datapath) | 229 shutil.rmtree(self.datapath) |
183 if queued_exception: | 230 if queued_exception: |
184 raise queued_exception | 231 raise queued_exception |
(...skipping 13 matching lines...) Expand all Loading... |
198 test.suite.GetFlagsForTestCase(test, self.context) + | 245 test.suite.GetFlagsForTestCase(test, self.context) + |
199 self.context.extra_flags) | 246 self.context.extra_flags) |
200 return cmd | 247 return cmd |
201 | 248 |
202 | 249 |
203 class BreakNowException(Exception): | 250 class BreakNowException(Exception): |
204 def __init__(self, value): | 251 def __init__(self, value): |
205 self.value = value | 252 self.value = value |
206 def __str__(self): | 253 def __str__(self): |
207 return repr(self.value) | 254 return repr(self.value) |
OLD | NEW |