OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
2 # | |
3 # Copyright 2011 Google Inc. All Rights Reserved. | |
4 | |
5 import fnmatch | |
6 import optparse | |
7 import os | |
8 import re | |
9 import shutil | |
10 import subprocess | |
11 import sys | |
12 import urllib | |
13 import utils | |
14 | |
15 SCRIPT_TAG = '<script type="application/%s" src="%s"></script>\n' | |
16 | |
17 DART_TEST_DIR = os.path.join('dart') | |
18 | |
19 DART_VM_FLAGS = [ | |
20 ] | |
21 DART_VM_CHECKED_FLAGS = DART_VM_FLAGS + [ | |
22 '--enable_type_checks', | |
23 '--warning_as_error', | |
24 ] | |
25 | |
26 TEST_DRT_FLAGS = [ | |
27 '--compiler=none', | |
28 '--runtime=drt', | |
29 '--drt=%(drt)s', | |
30 '--mode=%(mode)s', | |
31 '--arch=%(arch)s', | |
32 '--build-directory=%(build_dir)s', | |
33 '--report', | |
34 '--time', | |
35 ] | |
36 | |
37 TEST_DRT_CHECKED_FLAGS = TEST_DRT_FLAGS + [ | |
38 '--checked', | |
39 ] | |
40 | |
41 TEST_DARTIUM_FLAGS = [ | |
42 '--compiler=none', | |
43 '--runtime=dartium', | |
44 '--dartium=%(dartium)s', | |
45 '--mode=%(mode)s', | |
46 '--build-directory=%(build_dir)s', | |
47 '--report', | |
48 '--time', | |
49 ] | |
50 | |
51 TEST_DARTIUM_CHECKED_FLAGS = TEST_DARTIUM_FLAGS + [ | |
52 '--checked', | |
53 ] | |
54 | |
55 TEST_INFO = { | |
56 'dartium': { | |
57 'core': { | |
58 'checked': TEST_DARTIUM_CHECKED_FLAGS, | |
59 'unchecked': TEST_DARTIUM_FLAGS, | |
60 }, | |
61 }, | |
62 'drt': { | |
63 'layout': { | |
64 'checked': DART_VM_CHECKED_FLAGS, | |
65 'unchecked': DART_VM_FLAGS, | |
66 }, | |
67 'core': { | |
68 'checked': TEST_DRT_CHECKED_FLAGS, | |
69 'unchecked': TEST_DRT_FLAGS, | |
70 }, | |
71 }, | |
72 } | |
73 | |
74 COMPONENTS = TEST_INFO.keys() | |
75 SUITES = [ 'layout', 'core' ] | |
76 | |
77 def main(): | |
78 parser = optparse.OptionParser() | |
79 parser.add_option('--mode', dest='mode', | |
80 action='store', type='string', | |
81 help='Test mode (Debug or Release)') | |
82 parser.add_option('--component', dest='component', | |
83 default='drt', | |
84 action='store', type='string', | |
85 help='Execution mode (dartium, drt or all)') | |
86 parser.add_option('--suite', dest='suite', | |
87 default='all', | |
88 action='store', type='string', | |
89 help='Test suite (layout, core, or all)') | |
90 parser.add_option('--arch', dest='arch', | |
91 default='ia32', | |
92 action='store', type='string', | |
93 help='Target architecture') | |
94 parser.add_option('--no-show-results', action='store_false', | |
95 default=True, dest='show_results', | |
96 help='Don\'t launch a browser with results ' | |
97 'after the tests are done') | |
98 parser.add_option('--checked', action='store_true', | |
99 default=False, dest='checked', | |
100 help='Run Dart code in checked mode') | |
101 parser.add_option('--unchecked', action='store_true', | |
102 default=False, dest='unchecked', | |
103 help='Run Dart code in unchecked mode') | |
104 parser.add_option('--buildbot', action='store_true', | |
105 default=False, dest='buildbot', | |
106 help='Print results in buildbot format') | |
107 parser.add_option('--layout-test', dest='layout_test', | |
108 default=None, | |
109 action='store', type='string', | |
110 help='Single layout test to run if set') | |
111 parser.add_option('--test-filter', dest='test_filter', | |
112 default=None, | |
113 action='store', type='string', | |
114 help='Test filter for core tests') | |
115 parser.add_option('--win-ninja-build', action='store_true', | |
116 default=False, dest='is_win_ninja', | |
117 help='We are on windows and use ninja for building.') | |
118 | |
119 (options, args) = parser.parse_args() | |
120 mode = options.mode | |
121 if not (mode in ['Debug', 'Release']): | |
122 raise Exception('Invalid test mode') | |
123 | |
124 if options.component == 'all': | |
125 components = COMPONENTS | |
126 elif not (options.component in COMPONENTS): | |
127 raise Exception('Invalid component %s' % options.component) | |
128 else: | |
129 components = [ options.component ] | |
130 | |
131 if options.suite == 'all': | |
132 suites = SUITES | |
133 elif not (options.suite in SUITES): | |
134 raise Exception('Invalid suite %s' % options.suite) | |
135 else: | |
136 suites = [ options.suite ] | |
137 | |
138 # If --checked or --unchecked not present, run with both. | |
139 checkmodes = ['unchecked', 'checked'] | |
140 if options.checked or options.unchecked: | |
141 checkmodes = [] | |
142 if options.unchecked: checkmodes.append('unchecked') | |
143 if options.checked: checkmodes.append('checked') | |
144 | |
145 pathname = os.path.dirname(sys.argv[0]) | |
146 fullpath = os.path.abspath(pathname) | |
147 srcpath = os.path.normpath(os.path.join(fullpath, '..')) | |
148 | |
149 test_mode = '' | |
150 timeout = 30000 | |
151 if mode == 'Debug': | |
152 test_mode = '--debug' | |
153 timeout = 60000 | |
154 | |
155 show_results = '' | |
156 if not options.show_results: | |
157 show_results = '--no-show-results' | |
158 | |
159 host_os = utils.guessOS() | |
160 if options.is_win_ninja: | |
161 host_os = 'win-ninja' | |
162 build_root, drt_path, dartium_path, dart_path = { | |
163 'mac': ( | |
164 'out', | |
165 os.path.join('Content Shell.app', 'Contents', 'MacOS', 'Content Shell'), | |
166 os.path.join('Chromium.app', 'Contents', 'MacOS', 'Chromium'), | |
167 'dart', | |
168 ), | |
169 'linux': ('out', 'content_shell', 'chrome', 'dart'), | |
170 'win': ('out', 'content_shell.exe', 'chrome.exe', 'dart.exe'), | |
171 'win-ninja': ('out', 'content_shell.exe', 'chrome.exe', 'dart.exe'), | |
172 }[host_os] | |
173 | |
174 build_dir = os.path.join(srcpath, build_root, mode) | |
175 | |
176 executable_map = { | |
177 'mode': mode.lower(), | |
178 'build_dir': os.path.relpath(build_dir), | |
179 'drt': os.path.join(build_dir, drt_path), | |
180 'dartium': os.path.join(build_dir, dartium_path), | |
181 'dart': os.path.join(build_dir, dart_path), | |
182 'arch': options.arch, | |
183 } | |
184 | |
185 test_script = os.path.join(srcpath, 'webkit', 'tools', 'layout_tests', | |
186 'run_webkit_tests.py') | |
187 | |
188 errors = False | |
189 for component in components: | |
190 for checkmode in checkmodes: | |
191 # Capture errors and report at the end. | |
192 try: | |
193 if ('layout' in suites and | |
194 'layout' in TEST_INFO[component] and | |
195 checkmode in TEST_INFO[component]['layout']): | |
196 # Run layout tests in this mode | |
197 dart_flags = ' '.join(TEST_INFO[component]['layout'][checkmode]) | |
198 | |
199 if options.layout_test: | |
200 test = os.path.join(DART_TEST_DIR, options.layout_test) | |
201 else: | |
202 test = DART_TEST_DIR | |
203 package_root = os.path.join(build_dir, 'packages') | |
204 utils.runCommand(['python', | |
205 test_script, | |
206 test_mode, | |
207 show_results, | |
208 '--time-out-ms', str(timeout), | |
209 # Temporary hack to fix issue with svn vs. svn.bat. | |
210 '--builder-name', 'BuildBot', | |
211 '--additional-env-var', | |
212 'DART_FLAGS=%s' % dart_flags, | |
213 '--additional-env-var', | |
214 'DART_PACKAGE_ROOT=file://%s' % package_root, | |
215 test]) | |
216 | |
217 # Run core dart tests | |
218 if ('core' in suites and | |
219 'core' in TEST_INFO[component] and | |
220 checkmode in TEST_INFO[component]['core']): | |
221 core_flags = TEST_INFO[component]['core'][checkmode] | |
222 core_flags = map(lambda flag: flag % executable_map, core_flags) | |
223 if options.buildbot: | |
224 core_flags = ['--progress=buildbot'] + core_flags | |
225 tester = os.path.join(srcpath, 'dart', 'tools', 'test.py') | |
226 test_filter = [options.test_filter] if options.test_filter else [] | |
227 utils.runCommand(['python', tester] + core_flags + test_filter) | |
228 except (StandardError, Exception) as e: | |
229 print 'Fail: ' + str(e) | |
230 errors = True | |
231 | |
232 if errors: | |
233 return 1 | |
234 else: | |
235 return 0 | |
236 | |
237 if __name__ == '__main__': | |
238 try: | |
239 sys.exit(main()) | |
240 except StandardError as e: | |
241 print 'Fail: ' + str(e) | |
242 sys.exit(1) | |
OLD | NEW |