| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """This script is used by chrome_tests.gypi's js2webui action to maintain the | 6 """This script is used by chrome_tests.gypi's js2webui action to maintain the |
| 7 argument lists and to generate inlinable tests. | 7 argument lists and to generate inlinable tests. |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import json | 10 import json |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 cxxoutfile, test_type] | 40 cxxoutfile, test_type] |
| 41 cmd.extend(['-e', "arguments=" + json.dumps(arguments), mock_js, | 41 cmd.extend(['-e', "arguments=" + json.dumps(arguments), mock_js, |
| 42 test_api, js2webui]) | 42 test_api, js2webui]) |
| 43 if opts.verbose or opts.impotent: | 43 if opts.verbose or opts.impotent: |
| 44 print cmd | 44 print cmd |
| 45 if not opts.impotent: | 45 if not opts.impotent: |
| 46 try: | 46 try: |
| 47 p = subprocess.Popen( | 47 p = subprocess.Popen( |
| 48 cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=0) | 48 cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=0) |
| 49 out, err = p.communicate() | 49 out, err = p.communicate() |
| 50 if p.returncode: | |
| 51 # TODO(jochen): Remove once crbug.com/370551 is resolved. | |
| 52 if sys.platform == 'darwin': | |
| 53 sys.path.insert(0, '/Developer/Library/PrivateFrameworks/' | |
| 54 'LLDB.framework/Resources/Python') | |
| 55 try: | |
| 56 import lldb | |
| 57 except: | |
| 58 raise Exception("Could not load lldb module") | |
| 59 debugger = lldb.SBDebugger.Create() | |
| 60 debugger.SetAsync(False) | |
| 61 target = debugger.CreateTargetWithFileAndArch( | |
| 62 cmd[0], lldb.LLDB_ARCH_DEFAULT) | |
| 63 if not target: | |
| 64 raise Exception("Failed to create d8 target") | |
| 65 process = target.LaunchSimple(cmd[1:], None, os.getcwd()) | |
| 66 if not process: | |
| 67 raise Exception("Failed to start d8") | |
| 68 if process.GetState() == lldb.eStateStopped: | |
| 69 for thread in process: | |
| 70 print "Thread (id %d)" % thread.GetThreadID() | |
| 71 for frame in thread: | |
| 72 print frame | |
| 73 print "" | |
| 74 raise Exception( | |
| 75 "d8 crashed, please report this at http://crbug.com/370551") | |
| 76 else: | |
| 77 # For some reason d8 worked this time... | |
| 78 out = '' | |
| 79 while True: | |
| 80 s = process.GetSTDOUT(4096) | |
| 81 if s == '': | |
| 82 break | |
| 83 out += s | |
| 84 | |
| 85 with open(cxxoutfile, 'wb') as f: | 50 with open(cxxoutfile, 'wb') as f: |
| 86 f.write(out) | 51 f.write(out) |
| 87 shutil.copyfile(inputfile, jsoutfile) | 52 shutil.copyfile(inputfile, jsoutfile) |
| 88 except Exception, ex: | 53 except Exception, ex: |
| 89 if os.path.exists(cxxoutfile): | 54 if os.path.exists(cxxoutfile): |
| 90 os.remove(cxxoutfile) | 55 os.remove(cxxoutfile) |
| 91 if os.path.exists(jsoutfile): | 56 if os.path.exists(jsoutfile): |
| 92 os.remove(jsoutfile) | 57 os.remove(jsoutfile) |
| 93 raise | 58 raise |
| 94 | 59 |
| 95 | 60 |
| 96 if __name__ == '__main__': | 61 if __name__ == '__main__': |
| 97 sys.exit(main()) | 62 sys.exit(main()) |
| OLD | NEW |