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 26 matching lines...) Expand all Loading... |
37 if os.path.exists(icudatafile): | 37 if os.path.exists(icudatafile): |
38 cmd.extend(['--icu-data-file=%s' % icudatafile]) | 38 cmd.extend(['--icu-data-file=%s' % icudatafile]) |
39 arguments = [js2webui, inputfile, inputrelfile, opts.deps_js, | 39 arguments = [js2webui, inputfile, inputrelfile, opts.deps_js, |
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(cmd, stdout=subprocess.PIPE, bufsize=0) | 47 p = subprocess.Popen( |
| 48 cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=0) |
48 out, err = p.communicate() | 49 out, err = p.communicate() |
49 if p.returncode: | 50 if p.returncode: |
50 raise Exception('Failed to run d8', out, err) | 51 raise Exception('Failed to run d8', out, err) |
51 with open(cxxoutfile, 'wb') as f: | 52 with open(cxxoutfile, 'wb') as f: |
52 f.write(out) | 53 f.write(out) |
53 shutil.copyfile(inputfile, jsoutfile) | 54 shutil.copyfile(inputfile, jsoutfile) |
54 except Exception, ex: | 55 except Exception, ex: |
55 if os.path.exists(cxxoutfile): | 56 if os.path.exists(cxxoutfile): |
56 os.remove(cxxoutfile) | 57 os.remove(cxxoutfile) |
57 if os.path.exists(jsoutfile): | 58 if os.path.exists(jsoutfile): |
58 os.remove(jsoutfile) | 59 os.remove(jsoutfile) |
59 raise | 60 raise |
60 | 61 |
61 | 62 |
62 if __name__ == '__main__': | 63 if __name__ == '__main__': |
63 sys.exit(main()) | 64 sys.exit(main()) |
OLD | NEW |