| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
| 5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. |
| 6 | 6 |
| 7 # A script which makes it easy to execute common DOM-related tasks | 7 # A script which makes it easy to execute common DOM-related tasks |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 import subprocess | 10 import subprocess |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 call(args) | 89 call(args) |
| 90 return out_file | 90 return out_file |
| 91 | 91 |
| 92 def gen(): | 92 def gen(): |
| 93 os.chdir(os.path.join('tools', 'dom', 'scripts')) | 93 os.chdir(os.path.join('tools', 'dom', 'scripts')) |
| 94 result = call([os.path.join(os.getcwd(), 'dartdomgenerator.py'), | 94 result = call([os.path.join(os.getcwd(), 'dartdomgenerator.py'), |
| 95 '--rebuild', '--parallel', '--systems=htmldart2js,htmldartium']) | 95 '--rebuild', '--parallel', '--systems=htmldart2js,htmldartium']) |
| 96 os.chdir(os.path.join('..', '..', '..')) | 96 os.chdir(os.path.join('..', '..', '..')) |
| 97 return result | 97 return result |
| 98 | 98 |
| 99 def http_server(): | |
| 100 print('Browse tests at ' | |
| 101 '\033[94mhttp://localhost:5400/root_build/generated_tests/\033[0m') | |
| 102 return call([ | |
| 103 utils.DartBinary(), | |
| 104 os.path.join('tools', 'testing', 'dart', 'http_server.dart'), | |
| 105 '--port=5400', | |
| 106 '--crossOriginPort=5401', | |
| 107 '--network=0.0.0.0', | |
| 108 '--build-directory=%s' % os.path.join('out', 'ReleaseIA32') | |
| 109 ]) | |
| 110 | |
| 111 def size_check(): | 99 def size_check(): |
| 112 ''' Displays the dart2js size of swarm. ''' | 100 ''' Displays the dart2js size of swarm. ''' |
| 113 dart_file = os.path.join('samples', 'swarm', 'swarm.dart') | 101 dart_file = os.path.join('samples', 'swarm', 'swarm.dart') |
| 114 out_file = compile_dart2js(dart_file, False) | 102 out_file = compile_dart2js(dart_file, False) |
| 115 | 103 |
| 116 return call([ | 104 return call([ |
| 117 'du', | 105 'du', |
| 118 '-kh', | 106 '-kh', |
| 119 '--apparent-size', | 107 '--apparent-size', |
| 120 out_file, | 108 out_file, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 144 '-v', | 132 '-v', |
| 145 ] | 133 ] |
| 146 if argv: | 134 if argv: |
| 147 cmd.append(argv.pop(0)) | 135 cmd.append(argv.pop(0)) |
| 148 else: | 136 else: |
| 149 print( | 137 print( |
| 150 'Test commands should be followed by tests to run. Defaulting to html') | 138 'Test commands should be followed by tests to run. Defaulting to html') |
| 151 cmd.append('html') | 139 cmd.append('html') |
| 152 return call(cmd) | 140 return call(cmd) |
| 153 | 141 |
| 142 def test_server(): |
| 143 start_test_server(5400, os.path.join('out', 'ReleaseIA32')) |
| 144 |
| 145 def test_server_dartium(): |
| 146 start_test_server(5500, os.path.join('..', 'out', 'Release')) |
| 147 |
| 148 def start_test_server(port, build_directory): |
| 149 print('Browse tests at ' |
| 150 '\033[94mhttp://localhost:%d/root_build/generated_tests/\033[0m' % port) |
| 151 return call([ |
| 152 utils.DartBinary(), |
| 153 os.path.join('tools', 'testing', 'dart', 'http_server.dart'), |
| 154 '--port=%d' % port, |
| 155 '--crossOriginPort=%d' % (port + 1), |
| 156 '--network=0.0.0.0', |
| 157 '--build-directory=%s' % build_directory |
| 158 ]) |
| 159 |
| 160 |
| 154 def call(args): | 161 def call(args): |
| 155 print ' '.join(args) | 162 print ' '.join(args) |
| 156 pipe = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 163 pipe = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 157 output, error = pipe.communicate() | 164 output, error = pipe.communicate() |
| 158 if output: | 165 if output: |
| 159 print output | 166 print output |
| 160 if error: | 167 if error: |
| 161 print error | 168 print error |
| 162 return pipe.returncode | 169 return pipe.returncode |
| 163 | 170 |
| 164 commands = { | 171 commands = { |
| 165 'analyze': [analyze, 'Run the dart analyzer'], | 172 'analyze': [analyze, 'Run the dart analyzer'], |
| 166 'build': [build, 'Build dart in release mode'], | 173 'build': [build, 'Build dart in release mode'], |
| 167 'dart2js': [dart2js, 'Run dart2js on the .dart file specified'], | 174 'dart2js': [dart2js, 'Run dart2js on the .dart file specified'], |
| 168 'docs': [docs, 'Generates docs.json'], | 175 'docs': [docs, 'Generates docs.json'], |
| 169 'gen': [gen, 'Re-generate DOM generated files (run go.sh)'], | 176 'gen': [gen, 'Re-generate DOM generated files (run go.sh)'], |
| 170 'size_check': [size_check, 'Check the size of dart2js compiled Swarm'], | 177 'size_check': [size_check, 'Check the size of dart2js compiled Swarm'], |
| 171 'test_docs': [test_docs, 'Tests docs.dart'], | 178 'test_docs': [test_docs, 'Tests docs.dart'], |
| 172 'test_chrome': [test_chrome, 'Run tests in checked mode in Chrome.\n' | 179 'test_chrome': [test_chrome, 'Run tests in checked mode in Chrome.\n' |
| 173 '\t\tOptionally provide name of test to run.'], | 180 '\t\tOptionally provide name of test to run.'], |
| 174 # TODO(antonm): fix option name. | 181 # TODO(antonm): fix option name. |
| 175 'test_drt': [test_drt, 'Run tests in checked mode in content shell.\n' | 182 'test_drt': [test_drt, 'Run tests in checked mode in content shell.\n' |
| 176 '\t\tOptionally provide name of test to run.'], | 183 '\t\tOptionally provide name of test to run.'], |
| 177 'test_ff': [test_ff, 'Run tests in checked mode in Firefox.\n' | 184 'test_ff': [test_ff, 'Run tests in checked mode in Firefox.\n' |
| 178 '\t\tOptionally provide name of test to run.'], | 185 '\t\tOptionally provide name of test to run.'], |
| 179 'http_server': [http_server, 'Starts the testing server for manually ' | 186 'test_server': [test_server, 'Starts the testing server for manually ' |
| 180 'running browser tests.'], | 187 'running browser tests.'], |
| 188 'test_server_dartium': [test_server_dartium, 'Starts the testing server for ' |
| 189 'manually running browser tests from a dartium enlistment.'], |
| 181 } | 190 } |
| 182 | 191 |
| 183 def main(): | 192 def main(): |
| 184 success = True | 193 success = True |
| 185 argv.pop(0) | 194 argv.pop(0) |
| 186 | 195 |
| 187 if not argv: | 196 if not argv: |
| 188 help() | 197 help() |
| 189 success = False | 198 success = False |
| 190 | 199 |
| 191 while (argv): | 200 while (argv): |
| 192 # Make sure that we're always rooted in the dart root folder. | 201 # Make sure that we're always rooted in the dart root folder. |
| 193 os.chdir(dart_dir) | 202 os.chdir(dart_dir) |
| 194 command = argv.pop(0) | 203 command = argv.pop(0) |
| 195 | 204 |
| 196 if not command in commands: | 205 if not command in commands: |
| 197 help(); | 206 help(); |
| 198 success = False | 207 success = False |
| 199 break | 208 break |
| 200 returncode = commands[command][0]() | 209 returncode = commands[command][0]() |
| 201 success = success and not bool(returncode) | 210 success = success and not bool(returncode) |
| 202 | 211 |
| 203 sys.exit(not success) | 212 sys.exit(not success) |
| 204 | 213 |
| 205 if __name__ == '__main__': | 214 if __name__ == '__main__': |
| 206 main() | 215 main() |
| OLD | NEW |