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