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 |
11 # with the distribution. | 11 # with the distribution. |
12 # * Neither the name of Google Inc. nor the names of its | 12 # * Neither the name of Google Inc. nor the names of its |
13 # contributors may be used to endorse or promote products derived | 13 # contributors may be used to endorse or promote products derived |
14 # from this software without specific prior written permission. | 14 # from this software without specific prior written permission. |
15 # | 15 # |
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 | 28 |
| 29 import json |
| 30 import os |
29 import sys | 31 import sys |
30 import time | 32 import time |
31 | 33 |
32 from . import junit_output | 34 from . import junit_output |
33 | 35 |
| 36 |
| 37 ABS_PATH_PREFIX = os.getcwd() + os.sep |
| 38 |
| 39 |
34 def EscapeCommand(command): | 40 def EscapeCommand(command): |
35 parts = [] | 41 parts = [] |
36 for part in command: | 42 for part in command: |
37 if ' ' in part: | 43 if ' ' in part: |
38 # Escape spaces. We may need to escape more characters for this | 44 # Escape spaces. We may need to escape more characters for this |
39 # to work properly. | 45 # to work properly. |
40 parts.append('"%s"' % part) | 46 parts.append('"%s"' % part) |
41 else: | 47 else: |
42 parts.append(part) | 48 parts.append(part) |
43 return " ".join(parts) | 49 return " ".join(parts) |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 if test.output.HasCrashed(): | 276 if test.output.HasCrashed(): |
271 fail_text += "exit code: %d\n--- CRASHED ---" % test.output.exit_code | 277 fail_text += "exit code: %d\n--- CRASHED ---" % test.output.exit_code |
272 if test.output.HasTimedOut(): | 278 if test.output.HasTimedOut(): |
273 fail_text += "--- TIMEOUT ---" | 279 fail_text += "--- TIMEOUT ---" |
274 self.outputter.HasRunTest( | 280 self.outputter.HasRunTest( |
275 [test.GetLabel()] + self.runner.context.mode_flags + test.flags, | 281 [test.GetLabel()] + self.runner.context.mode_flags + test.flags, |
276 test.duration, | 282 test.duration, |
277 fail_text) | 283 fail_text) |
278 | 284 |
279 | 285 |
| 286 class JsonTestProgressIndicator(ProgressIndicator): |
| 287 |
| 288 def __init__(self, progress_indicator, json_test_results, arch, mode): |
| 289 self.progress_indicator = progress_indicator |
| 290 self.json_test_results = json_test_results |
| 291 self.arch = arch |
| 292 self.mode = mode |
| 293 self.results = [] |
| 294 |
| 295 def Starting(self): |
| 296 self.progress_indicator.runner = self.runner |
| 297 self.progress_indicator.Starting() |
| 298 |
| 299 def Done(self): |
| 300 self.progress_indicator.Done() |
| 301 complete_results = [] |
| 302 if os.path.exists(self.json_test_results): |
| 303 with open(self.json_test_results, "r") as f: |
| 304 # Buildbot might start out with an empty file. |
| 305 complete_results = json.loads(f.read() or "[]") |
| 306 |
| 307 complete_results.append({ |
| 308 "arch": self.arch, |
| 309 "mode": self.mode, |
| 310 "results": self.results, |
| 311 }) |
| 312 |
| 313 with open(self.json_test_results, "w") as f: |
| 314 f.write(json.dumps(complete_results)) |
| 315 |
| 316 def AboutToRun(self, test): |
| 317 self.progress_indicator.AboutToRun(test) |
| 318 |
| 319 def HasRun(self, test, has_unexpected_output): |
| 320 self.progress_indicator.HasRun(test, has_unexpected_output) |
| 321 if not has_unexpected_output: |
| 322 return |
| 323 self.results.append({ |
| 324 "name": test.GetLabel(), |
| 325 "flags": test.flags, |
| 326 "command": EscapeCommand(self.runner.GetCommand(test)).replace( |
| 327 ABS_PATH_PREFIX, ""), |
| 328 "stdout": test.output.stdout, |
| 329 "stderr": test.output.stderr, |
| 330 "exit_code": test.output.exit_code, |
| 331 "result": "CRASH" if test.output.HasCrashed() else "FAIL", |
| 332 }) |
| 333 |
| 334 |
280 PROGRESS_INDICATORS = { | 335 PROGRESS_INDICATORS = { |
281 'verbose': VerboseProgressIndicator, | 336 'verbose': VerboseProgressIndicator, |
282 'dots': DotsProgressIndicator, | 337 'dots': DotsProgressIndicator, |
283 'color': ColorProgressIndicator, | 338 'color': ColorProgressIndicator, |
284 'mono': MonochromeProgressIndicator | 339 'mono': MonochromeProgressIndicator |
285 } | 340 } |
OLD | NEW |