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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 291 |
292 | 292 |
293 class JsonTestProgressIndicator(ProgressIndicator): | 293 class JsonTestProgressIndicator(ProgressIndicator): |
294 | 294 |
295 def __init__(self, progress_indicator, json_test_results, arch, mode): | 295 def __init__(self, progress_indicator, json_test_results, arch, mode): |
296 self.progress_indicator = progress_indicator | 296 self.progress_indicator = progress_indicator |
297 self.json_test_results = json_test_results | 297 self.json_test_results = json_test_results |
298 self.arch = arch | 298 self.arch = arch |
299 self.mode = mode | 299 self.mode = mode |
300 self.results = [] | 300 self.results = [] |
| 301 self.tests = [] |
301 | 302 |
302 def Starting(self): | 303 def Starting(self): |
303 self.progress_indicator.runner = self.runner | 304 self.progress_indicator.runner = self.runner |
304 self.progress_indicator.Starting() | 305 self.progress_indicator.Starting() |
305 | 306 |
306 def Done(self): | 307 def Done(self): |
307 self.progress_indicator.Done() | 308 self.progress_indicator.Done() |
308 complete_results = [] | 309 complete_results = [] |
309 if os.path.exists(self.json_test_results): | 310 if os.path.exists(self.json_test_results): |
310 with open(self.json_test_results, "r") as f: | 311 with open(self.json_test_results, "r") as f: |
311 # Buildbot might start out with an empty file. | 312 # Buildbot might start out with an empty file. |
312 complete_results = json.loads(f.read() or "[]") | 313 complete_results = json.loads(f.read() or "[]") |
313 | 314 |
| 315 # Sort tests by duration. |
| 316 timed_tests = [t for t in self.tests if t.duration is not None] |
| 317 timed_tests.sort(lambda a, b: cmp(b.duration, a.duration)) |
| 318 slowest_tests = [ |
| 319 { |
| 320 "name": test.GetLabel(), |
| 321 "flags": test.flags, |
| 322 "command": EscapeCommand(self.runner.GetCommand(test)).replace( |
| 323 ABS_PATH_PREFIX, ""), |
| 324 "duration": test.duration, |
| 325 } for test in timed_tests[:20] |
| 326 ] |
| 327 |
314 complete_results.append({ | 328 complete_results.append({ |
315 "arch": self.arch, | 329 "arch": self.arch, |
316 "mode": self.mode, | 330 "mode": self.mode, |
317 "results": self.results, | 331 "results": self.results, |
| 332 "slowest_tests": slowest_tests, |
318 }) | 333 }) |
319 | 334 |
320 with open(self.json_test_results, "w") as f: | 335 with open(self.json_test_results, "w") as f: |
321 f.write(json.dumps(complete_results)) | 336 f.write(json.dumps(complete_results)) |
322 | 337 |
323 def AboutToRun(self, test): | 338 def AboutToRun(self, test): |
324 self.progress_indicator.AboutToRun(test) | 339 self.progress_indicator.AboutToRun(test) |
325 | 340 |
326 def HasRun(self, test, has_unexpected_output): | 341 def HasRun(self, test, has_unexpected_output): |
327 self.progress_indicator.HasRun(test, has_unexpected_output) | 342 self.progress_indicator.HasRun(test, has_unexpected_output) |
| 343 # Buffer all tests for sorting the durations in the end. |
| 344 self.tests.append(test) |
328 if not has_unexpected_output: | 345 if not has_unexpected_output: |
329 # Omit tests that run as expected. Passing tests of reruns after failures | 346 # Omit tests that run as expected. Passing tests of reruns after failures |
330 # will have unexpected_output to be reported here has well. | 347 # will have unexpected_output to be reported here has well. |
331 return | 348 return |
332 | 349 |
333 self.results.append({ | 350 self.results.append({ |
334 "name": test.GetLabel(), | 351 "name": test.GetLabel(), |
335 "flags": test.flags, | 352 "flags": test.flags, |
336 "command": EscapeCommand(self.runner.GetCommand(test)).replace( | 353 "command": EscapeCommand(self.runner.GetCommand(test)).replace( |
337 ABS_PATH_PREFIX, ""), | 354 ABS_PATH_PREFIX, ""), |
338 "run": test.run, | 355 "run": test.run, |
339 "stdout": test.output.stdout, | 356 "stdout": test.output.stdout, |
340 "stderr": test.output.stderr, | 357 "stderr": test.output.stderr, |
341 "exit_code": test.output.exit_code, | 358 "exit_code": test.output.exit_code, |
342 "result": test.suite.GetOutcome(test), | 359 "result": test.suite.GetOutcome(test), |
343 "expected": list(test.outcomes or ["PASS"]), | 360 "expected": list(test.outcomes or ["PASS"]), |
| 361 "duration": test.duration, |
344 }) | 362 }) |
345 | 363 |
346 | 364 |
347 PROGRESS_INDICATORS = { | 365 PROGRESS_INDICATORS = { |
348 'verbose': VerboseProgressIndicator, | 366 'verbose': VerboseProgressIndicator, |
349 'dots': DotsProgressIndicator, | 367 'dots': DotsProgressIndicator, |
350 'color': ColorProgressIndicator, | 368 'color': ColorProgressIndicator, |
351 'mono': MonochromeProgressIndicator | 369 'mono': MonochromeProgressIndicator |
352 } | 370 } |
OLD | NEW |