| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
| 3 # for details. All rights reserved. Use of this source code is governed by a | |
| 4 # BSD-style license that can be found in the LICENSE file. | |
| 5 | |
| 6 import optparse | |
| 7 import os | |
| 8 import stat | |
| 9 import subprocess | |
| 10 import sys | |
| 11 import time | |
| 12 | |
| 13 | |
| 14 class Error(Exception): | |
| 15 pass | |
| 16 | |
| 17 | |
| 18 def BuildOptions(): | |
| 19 """Configures an option parser for this script""" | |
| 20 result = optparse.OptionParser() | |
| 21 result.add_option( | |
| 22 '--notest', | |
| 23 help='Skip running test.py', | |
| 24 default=False, | |
| 25 action='store_true') | |
| 26 result.add_option( | |
| 27 '--leg-only', | |
| 28 help='Only run leg tests', | |
| 29 default=False, | |
| 30 action='store_true') | |
| 31 return result | |
| 32 | |
| 33 | |
| 34 def RunCommand(*arguments, **kwargs): | |
| 35 pattern = None | |
| 36 if 'pattern' in kwargs: | |
| 37 pattern = kwargs['pattern'] | |
| 38 expected_exit_code = 0 | |
| 39 if 'exit_code' in kwargs: | |
| 40 expected_exit_code = kwargs['exit_code'] | |
| 41 stdout = subprocess.PIPE | |
| 42 if 'verbose' in kwargs and kwargs['verbose']: | |
| 43 print ' '.join(arguments) | |
| 44 stdout = None | |
| 45 try: | |
| 46 proc = subprocess.Popen(arguments, | |
| 47 stdout=stdout, | |
| 48 stderr=subprocess.STDOUT) | |
| 49 stdout = proc.communicate()[0] | |
| 50 exit_code = proc.wait() | |
| 51 except OSError as e: | |
| 52 raise Error('%s: %s' % (arguments[0], e.strerror)) | |
| 53 if exit_code != expected_exit_code: | |
| 54 DiagnoseError(arguments, stdout) | |
| 55 raise Error('%s returned %s' % (arguments[0], exit_code)) | |
| 56 if pattern and not pattern in stdout: | |
| 57 DiagnoseError(arguments, stdout) | |
| 58 raise Error('%s failed' % arguments[0]) | |
| 59 | |
| 60 | |
| 61 def DiagnoseError(arguments, stdout): | |
| 62 quoted_arguments = ' '.join([repr(s) for s in arguments]) | |
| 63 sys.stderr.write('Command failed:\n%s\n' % quoted_arguments) | |
| 64 if stdout: | |
| 65 sys.stderr.write(stdout) | |
| 66 | |
| 67 | |
| 68 EXECUTABLE = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | | |
| 69 stat.S_IRGRP | stat.S_IXGRP | | |
| 70 stat.S_IROTH | stat.S_IXOTH) | |
| 71 | |
| 72 def main(): | |
| 73 dart_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| 74 os.chdir(dart_dir) | |
| 75 | |
| 76 (options, args) = BuildOptions().parse_args() | |
| 77 | |
| 78 RunCommand('./tools/build.py', '--mode=release', 'dart2js') | |
| 79 | |
| 80 test_cmd = ['./tools/test.py', '--report', '--timeout=30', | |
| 81 '--progress=color', '--mode=release', '--checked'] | |
| 82 | |
| 83 if options.notest: return | |
| 84 | |
| 85 if args: | |
| 86 if options.leg_only: | |
| 87 test_cmd.extend('--compiler=dart2js', '--runtime=d8') | |
| 88 else: | |
| 89 test_cmd.extend('--compiler=frog,dart2js', '--runtime=d8') | |
| 90 test_cmd.extend(args) | |
| 91 RunCommand(*test_cmd, verbose=True) | |
| 92 else: | |
| 93 if not options.leg_only: | |
| 94 # Run frog.py on the corelib tests, so we get some frog.py coverage. | |
| 95 cmd = test_cmd + ['--compiler=frog', '--runtime=d8', 'corelib'] | |
| 96 RunCommand(*cmd, verbose=True) | |
| 97 | |
| 98 # Run frogium client tests. This is a pretty quick test but | |
| 99 # tends to uncover different issues due to the size/complexity | |
| 100 # of the DOM APIs. | |
| 101 cmd = test_cmd + ['--compiler=frog', '--runtime=drt', | |
| 102 'dom', 'html', 'json', 'benchmark_smoke'] | |
| 103 RunCommand(*cmd, verbose=True) | |
| 104 | |
| 105 # Run frog on most of the tests. | |
| 106 cmd = test_cmd + ['--compiler=frog', '--runtime=d8', | |
| 107 'language', 'corelib', | |
| 108 'isolate', 'peg', 'frog', 'css', 'frog_native'] | |
| 109 RunCommand(*cmd, verbose=True) | |
| 110 | |
| 111 # Run the "utils" tests which includes dartdoc. Frog/leg changes often | |
| 112 # break dartdoc and this tries to catch those. | |
| 113 cmd = test_cmd + ['--compiler=none', '--runtime=vm', 'utils'] | |
| 114 RunCommand(*cmd, verbose=True) | |
| 115 | |
| 116 # Run leg unit tests. | |
| 117 cmd = test_cmd + ['--compiler=none', '--runtime=vm', 'leg'] | |
| 118 RunCommand(*cmd, verbose=True) | |
| 119 | |
| 120 # Leg does not implement checked mode yet. | |
| 121 test_cmd.remove('--checked') | |
| 122 | |
| 123 cmd = test_cmd + ['--compiler=dart2js', '--runtime=d8', | |
| 124 'leg_only', 'frog_native'] | |
| 125 RunCommand(*cmd, verbose=True) | |
| 126 | |
| 127 # Run dart2js and legium on "built-in" tests. | |
| 128 cmd = test_cmd + ['--compiler=dart2js', '--runtime=d8,drt'] | |
| 129 RunCommand(*cmd, verbose=True) | |
| 130 | |
| 131 | |
| 132 if __name__ == '__main__': | |
| 133 try: | |
| 134 sys.exit(main()) | |
| 135 except Error as e: | |
| 136 sys.stderr.write('%s\n' % e) | |
| 137 sys.exit(1) | |
| OLD | NEW |