OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/python | |
2 # Copyright (c) 2011 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. | |
5 # | |
6 # This script is used by chrome_tests.gypi's js2webui action to maintain the | |
7 # argument lists and to generate inlinable tests. | |
8 # | |
9 # Usage: | |
10 # python tools/gypv8sh.py -p product_dir path/to/javascript2webui.js | |
11 # python tools/gypv8sh.py -t # print test_harnesses | |
12 # python tools/gypv8sh.py -i # print inputs | |
13 # python tools/gypv8sh.py -o # print outputs | |
14 import json | |
15 import optparse | |
16 import os | |
17 import subprocess | |
18 import sys | |
19 | |
20 # Please adjust the following to edit or add new javascript webui tests. | |
21 rules = [ | |
22 [ | |
23 'WebUIBrowserTestPass', | |
24 'test/data/webui/sample_pass.js', | |
25 'browser/ui/webui/web_ui_browsertest-inl.h', | |
26 ], | |
27 ] | |
28 | |
29 def set_add(option, opt_str, value, parser, the_set, the_value): | |
30 the_set.add(the_value) | |
31 | |
32 # For options -t, -i, & -o, we print the "column" of the |rules|. We keep a set | |
33 # of indices to print in |print_rule_indices| and print them in sorted order if | |
34 # non-empty. | |
35 print_rule_indices = set() | |
36 parser = optparse.OptionParser(); | |
37 parser.add_option('-v', '--verbose', action='store_true', dest='verbose') | |
38 parser.add_option('-n', '--impotent', action='store_true', dest='impotent', | |
39 help="don't execute; just print (as if verbose)") | |
40 parser.add_option('-p', '--product_dir', action='store', type='string', | |
41 dest='product_dir', | |
42 help='for gyp to set the <(PRODUCT_DIR) for running v8_shell') | |
43 parser.add_option('-t', '--test_fixture', action='callback', callback=set_add, | |
44 callback_args=tuple([print_rule_indices, 0]), | |
45 help='print test_fixtures') | |
46 parser.add_option('-i', '--in', action='callback', callback=set_add, | |
47 callback_args=tuple([print_rule_indices, 1]), | |
48 help='print inputs') | |
49 parser.add_option('-o', '--out', action='callback', callback=set_add, | |
50 callback_args=tuple([print_rule_indices, 2]), | |
51 help='print outputs') | |
52 (opts, args) = parser.parse_args(); | |
53 | |
54 if len(print_rule_indices): | |
55 for rule in rules: | |
56 for index in sorted(print_rule_indices): | |
57 print rule[index], | |
58 print | |
59 else: | |
60 if not opts.product_dir: | |
61 print "Need to supply the -p PRODUCT_DIR." | |
62 parser.print_help(); | |
63 exit(-1); | |
Paweł Hajdan Jr.
2011/06/14 20:23:17
I think there is some call in optparse to exit, co
Sheridan Rawlins
2011/06/14 22:39:26
So it does; done.
On 2011/06/14 20:23:17, Paweł H
| |
64 v8_shell = os.path.join(opts.product_dir, 'v8_shell') | |
65 jsfilename = args[0] | |
66 for rule in rules: | |
67 arguments = [jsfilename, rule[0], rule[1], os.path.basename(rule[1])] | |
68 arguments = "arguments=" + json.dumps(arguments) | |
69 cmd = [v8_shell, '-e', arguments, jsfilename] | |
70 if opts.verbose or opts.impotent: | |
71 print cmd | |
72 if not opts.impotent: | |
73 sys.exit(subprocess.call(cmd, stdout=open(rule[2],'w+'))) | |
OLD | NEW |