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
4 # found in the LICENSE file.
6 """This script is used by chrome_tests.gypi's js2webui action to maintain the
7 argument lists and to generate inlinable tests.
19 parser
= optparse
.OptionParser()
21 "%prog v8_shell mock.js test_api.js js2webui.js "
22 "testtype inputfile inputrelfile cxxoutfile jsoutfile")
23 parser
.add_option('-v', '--verbose', action
='store_true')
24 parser
.add_option('-n', '--impotent', action
='store_true',
25 help="don't execute; just print (as if verbose)")
26 parser
.add_option('--deps_js', action
="store",
27 help=("Path to deps.js for dependency resolution, " +
29 (opts
, args
) = parser
.parse_args()
32 parser
.error('all arguments are required.')
33 (v8_shell
, mock_js
, test_api
, js2webui
, test_type
,
34 inputfile
, inputrelfile
, cxxoutfile
, jsoutfile
) = args
36 icudatafile
= os
.path
.join(os
.path
.dirname(v8_shell
), 'icudtl.dat')
37 if os
.path
.exists(icudatafile
):
38 cmd
.extend(['--icu-data-file=%s' % icudatafile
])
39 arguments
= [js2webui
, inputfile
, inputrelfile
, opts
.deps_js
,
40 cxxoutfile
, test_type
]
41 cmd
.extend(['-e', "arguments=" + json
.dumps(arguments
), mock_js
,
43 if opts
.verbose
or opts
.impotent
:
48 cmd
, stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
, bufsize
=0)
49 out
, err
= p
.communicate()
51 # TODO(jochen): Remove once crbug.com/370551 is resolved.
52 if sys
.platform
== 'darwin':
54 'gdb', '-batch', '-ex', 'run', '-ex' 'bt', '-ex', 'quit', '-args']
56 cmd
, stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
, bufsize
=0)
57 out
, err
= p
.communicate()
58 raise Exception('Failed to run d8', out
, err
)
59 with
open(cxxoutfile
, 'wb') as f
:
61 shutil
.copyfile(inputfile
, jsoutfile
)
63 if os
.path
.exists(cxxoutfile
):
65 if os
.path
.exists(jsoutfile
):
70 if __name__
== '__main__':