Chromium Code Reviews| 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 sys | |
| 16 import os | |
| 17 import subprocess | |
| 18 import getopt | |
|
nsylvain
2011/06/12 21:13:19
sort the imports
Sheridan Rawlins
2011/06/13 15:40:44
Done.
| |
| 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 opts, args = getopt.getopt( | |
| 30 sys.argv[1:], 'vntiop:', ['test_fixture', 'in', 'out', 'product_dir=']); | |
| 31 | |
| 32 indices = set() | |
| 33 product_dir = '' | |
| 34 verbose = 0 | |
| 35 impotent = 0 | |
| 36 if len(opts): | |
| 37 for o, a in opts: | |
| 38 if o in ('-t','--test_fixture'): | |
| 39 indices.add(0) | |
| 40 elif o in ('-i', '--in'): | |
| 41 indices.add(1) | |
| 42 elif o in ('-o', '--out'): | |
| 43 indices.add(2) | |
| 44 elif o in ('-p', '--product_dir'): | |
| 45 product_dir = a | |
| 46 elif o in ('-v', '--verbose'): | |
| 47 verbose = 1 | |
| 48 elif o in ('-n', '--impotent'): | |
| 49 impotent = 1 | |
| 50 | |
| 51 if len(indices): | |
| 52 for rule in rules: | |
| 53 for index in sorted(indices): | |
| 54 print rule[index], | |
| 55 print | |
| 56 else: | |
| 57 if not len(product_dir): | |
| 58 product_dir = os.path.dirname(os.path.dirname(sys.argv[0])) | |
| 59 product_dir = os.path.join(product_dir, 'out','Debug') | |
| 60 v8_shell = os.path.join(product_dir, 'v8_shell') | |
| 61 jsfilename = args[0] | |
| 62 for rule in rules: | |
| 63 arguments = [jsfilename, rule[0], rule[1], os.path.basename(rule[1])] | |
| 64 arguments = "arguments=" + json.dumps(arguments) | |
| 65 cmd = [v8_shell, '-e', arguments, jsfilename] | |
| 66 if verbose or impotent: | |
| 67 print cmd | |
| 68 if not impotent: | |
| 69 subprocess.call(cmd, stdout=open(rule[2],'w+')) | |
|
nsylvain
2011/06/12 21:13:19
I guess you should sys.exit(x) the return value of
Sheridan Rawlins
2011/06/13 15:40:44
Done.
| |
| OLD | NEW |