OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2012, 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 """ | 7 """ |
8 Dart2js buildbot steps | 8 Dart2js buildbot steps |
9 | 9 |
10 Runs tests for the dart2js compiler. | 10 Runs tests for the dart2js compiler. |
11 """ | 11 """ |
12 | 12 |
13 import os | 13 import os |
14 import platform | 14 import platform |
15 import re | 15 import re |
16 import shutil | 16 import shutil |
17 import socket | 17 import socket |
18 import subprocess | 18 import subprocess |
19 import sys | 19 import sys |
20 | 20 |
21 import bot | 21 import bot |
22 | 22 |
23 DARTIUM_BUILDER = r'none-dartium-(linux|mac|windows)' | 23 DARTIUM_BUILDER = r'none-dartium-(linux|mac|windows)' |
24 DART2JS_BUILDER = ( | 24 DART2JS_BUILDER = ( |
25 r'dart2js-(linux|mac|windows)(-(jsshell))?-(debug|release)(-(checked|host-ch
ecked))?(-(host-checked))?(-(minified))?(-(x64))?-?(\d*)-?(\d*)') | 25 r'dart2js-(linux|mac|windows)(-(jsshell))?-(debug|release)(-(checked|host-ch
ecked))?(-(host-checked))?(-(minified))?(-(x64))?-?(\d*)-?(\d*)') |
| 26 DART2JS_FULL_BUILDER = r'dart2js-full-(linux|mac|windows)(-checked)?(-minified)?
-(\d+)-(\d+)' |
26 WEB_BUILDER = ( | 27 WEB_BUILDER = ( |
27 r'dart2js-(ie9|ie10|ff|safari|chrome|chromeOnAndroid|opera|drt)-(win7|win8|m
ac10\.8|mac10\.7|linux)(-(all|html))?(-(csp))?(-(\d+)-(\d+))?') | 28 r'dart2js-(ie9|ie10|ff|safari|chrome|chromeOnAndroid|opera|drt)-(win7|win8|m
ac10\.8|mac10\.7|linux)(-(all|html))?(-(csp))?(-(\d+)-(\d+))?') |
28 | 29 |
| 30 DART2JS_FULL_CONFIGURATIONS = { |
| 31 'linux' : [ ], |
| 32 'mac' : [ ], |
| 33 'windows' : [ |
| 34 {'runtime' : 'ie9'}, |
| 35 {'runtime' : 'ie9', 'additional_flags' : ['--checked']}, |
| 36 ], |
| 37 } |
| 38 |
29 | 39 |
30 def GetBuildInfo(builder_name, is_buildbot): | 40 def GetBuildInfo(builder_name, is_buildbot): |
31 """Returns a BuildInfo object for the current buildbot based on the | 41 """Returns a BuildInfo object for the current buildbot based on the |
32 name of the builder. | 42 name of the builder. |
33 """ | 43 """ |
34 compiler = None | 44 compiler = None |
35 runtime = None | 45 runtime = None |
36 mode = None | 46 mode = None |
37 system = None | 47 system = None |
38 checked = False | 48 checked = False |
39 host_checked = False | 49 host_checked = False |
40 minified = False | 50 minified = False |
41 shard_index = None | 51 shard_index = None |
42 total_shards = None | 52 total_shards = None |
43 test_set = None | 53 test_set = None |
44 csp = None | 54 csp = None |
45 arch = None | 55 arch = None |
| 56 dart2js_full = False |
46 | 57 |
47 dart2js_pattern = re.match(DART2JS_BUILDER, builder_name) | 58 dart2js_pattern = re.match(DART2JS_BUILDER, builder_name) |
| 59 dart2js_full_pattern = re.match(DART2JS_FULL_BUILDER, builder_name) |
48 web_pattern = re.match(WEB_BUILDER, builder_name) | 60 web_pattern = re.match(WEB_BUILDER, builder_name) |
49 dartium_pattern = re.match(DARTIUM_BUILDER, builder_name) | 61 dartium_pattern = re.match(DARTIUM_BUILDER, builder_name) |
50 | 62 |
51 if web_pattern: | 63 if web_pattern: |
52 compiler = 'dart2js' | 64 compiler = 'dart2js' |
53 runtime = web_pattern.group(1) | 65 runtime = web_pattern.group(1) |
54 system = web_pattern.group(2) | 66 system = web_pattern.group(2) |
55 mode = 'release' | 67 mode = 'release' |
56 test_set = web_pattern.group(4) | 68 test_set = web_pattern.group(4) |
57 if web_pattern.group(6) == 'csp': | 69 if web_pattern.group(6) == 'csp': |
58 csp = True | 70 csp = True |
59 shard_index = web_pattern.group(8) | 71 shard_index = web_pattern.group(8) |
60 total_shards = web_pattern.group(9) | 72 total_shards = web_pattern.group(9) |
| 73 elif dart2js_full_pattern: |
| 74 mode = 'release' |
| 75 compiler = 'dart2js' |
| 76 dart2js_full = True |
| 77 system = dart2js_full_pattern.group(1) |
| 78 if dart2js_full_pattern.group(2): |
| 79 checked = True |
| 80 if dart2js_full_pattern.group(3): |
| 81 minified = True |
| 82 shard_index = dart2js_full_pattern.group(4) |
| 83 total_shards = dart2js_full_pattern.group(5) |
61 elif dart2js_pattern: | 84 elif dart2js_pattern: |
62 compiler = 'dart2js' | 85 compiler = 'dart2js' |
63 system = dart2js_pattern.group(1) | 86 system = dart2js_pattern.group(1) |
64 runtime = 'd8' | 87 runtime = 'd8' |
65 arch = 'ia32' | 88 arch = 'ia32' |
66 if dart2js_pattern.group(3) == 'jsshell': | 89 if dart2js_pattern.group(3) == 'jsshell': |
67 runtime = 'jsshell' | 90 runtime = 'jsshell' |
68 mode = dart2js_pattern.group(4) | 91 mode = dart2js_pattern.group(4) |
69 # The valid naming parts for checked and host-checked are: | 92 # The valid naming parts for checked and host-checked are: |
70 # Empty: checked=False, host_checked=False | 93 # Empty: checked=False, host_checked=False |
(...skipping 29 matching lines...) Expand all Loading... |
100 system = 'mac' | 123 system = 'mac' |
101 | 124 |
102 if (system == 'windows' and platform.system() != 'Windows') or ( | 125 if (system == 'windows' and platform.system() != 'Windows') or ( |
103 system == 'mac' and platform.system() != 'Darwin') or ( | 126 system == 'mac' and platform.system() != 'Darwin') or ( |
104 system == 'linux' and platform.system() != 'Linux'): | 127 system == 'linux' and platform.system() != 'Linux'): |
105 print ('Error: You cannot emulate a buildbot with a platform different ' | 128 print ('Error: You cannot emulate a buildbot with a platform different ' |
106 'from your own.') | 129 'from your own.') |
107 return None | 130 return None |
108 return bot.BuildInfo(compiler, runtime, mode, system, checked, host_checked, | 131 return bot.BuildInfo(compiler, runtime, mode, system, checked, host_checked, |
109 minified, shard_index, total_shards, is_buildbot, | 132 minified, shard_index, total_shards, is_buildbot, |
110 test_set, csp, arch) | 133 test_set, csp, arch, dart2js_full) |
111 | 134 |
112 | 135 |
113 def NeedsXterm(compiler, runtime): | 136 def NeedsXterm(compiler, runtime): |
114 return runtime in ['ie9', 'ie10', 'chrome', 'safari', 'opera', 'ff', 'drt', | 137 return runtime in ['ie9', 'ie10', 'chrome', 'safari', 'opera', 'ff', 'drt', |
115 'dartium'] | 138 'dartium'] |
116 | 139 |
117 | 140 |
118 def TestStepName(name, flags): | 141 def TestStepName(name, flags): |
119 # Filter out flags with '=' as this breaks the /stats feature of the | 142 # Filter out flags with '=' as this breaks the /stats feature of the |
120 # build bot. | 143 # build bot. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 186 |
164 if flags: | 187 if flags: |
165 cmd.extend(flags) | 188 cmd.extend(flags) |
166 cmd.extend(targets) | 189 cmd.extend(targets) |
167 | 190 |
168 print 'Running: %s' % (' '.join(map(lambda arg: '"%s"' % arg, cmd))) | 191 print 'Running: %s' % (' '.join(map(lambda arg: '"%s"' % arg, cmd))) |
169 sys.stdout.flush() | 192 sys.stdout.flush() |
170 bot.RunProcess(cmd) | 193 bot.RunProcess(cmd) |
171 | 194 |
172 | 195 |
173 def TestCompiler(runtime, mode, system, flags, is_buildbot, test_set, arch, | 196 def TestCompiler(runtime, mode, system, flags, is_buildbot, arch, |
174 compiler=None): | 197 compiler=None, dart2js_full=False): |
175 """ test the compiler. | 198 """ test the compiler. |
176 Args: | 199 Args: |
177 - runtime: either 'd8', 'jsshell', or one of the browsers, see GetBuildInfo | 200 - runtime: either 'd8', 'jsshell', or one of the browsers, see GetBuildInfo |
178 - mode: either 'debug' or 'release' | 201 - mode: either 'debug' or 'release' |
179 - system: either 'linux', 'mac', 'windows' | 202 - system: either 'linux', 'mac', 'windows' |
180 - flags: extra flags to pass to test.dart | 203 - flags: extra flags to pass to test.dart |
181 - is_buildbot: true if we are running on a real buildbot instead of | 204 - is_buildbot: true if we are running on a real buildbot instead of |
182 emulating one. | 205 emulating one. |
183 - test_set: Specification of a non standard test set, default None | |
184 - arch: The architecture to run on. | 206 - arch: The architecture to run on. |
185 - compiler: The compiler to use for test.py (default is 'dart2js'). | 207 - compiler: The compiler to use for test.py (default is 'dart2js'). |
186 """ | 208 """ |
187 | 209 |
188 if not compiler: | 210 if not compiler: |
189 compiler = 'dart2js' | 211 compiler = 'dart2js' |
190 | 212 |
191 def GetPath(runtime): | 213 def GetPath(runtime): |
192 """ Helper to get the path to the Chrome or Firefox executable for a | 214 """ Helper to get the path to the Chrome or Firefox executable for a |
193 particular platform on the buildbot. Throws a KeyError if runtime is not | 215 particular platform on the buildbot. Throws a KeyError if runtime is not |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 tools_dir = os.path.abspath(join(android_sdk, 'tools')) | 313 tools_dir = os.path.abspath(join(android_sdk, 'tools')) |
292 platform_tools_dir = os.path.abspath(join(android_sdk, 'platform-tools')) | 314 platform_tools_dir = os.path.abspath(join(android_sdk, 'platform-tools')) |
293 os.environ['PATH'] = os.pathsep.join( | 315 os.environ['PATH'] = os.pathsep.join( |
294 [os.environ['PATH'], tools_dir, platform_tools_dir]) | 316 [os.environ['PATH'], tools_dir, platform_tools_dir]) |
295 | 317 |
296 def RunCompilerTests(build_info): | 318 def RunCompilerTests(build_info): |
297 test_flags = [] | 319 test_flags = [] |
298 if build_info.shard_index: | 320 if build_info.shard_index: |
299 test_flags = ['--shards=%s' % build_info.total_shards, | 321 test_flags = ['--shards=%s' % build_info.total_shards, |
300 '--shard=%s' % build_info.shard_index] | 322 '--shard=%s' % build_info.shard_index] |
301 | |
302 if build_info.checked: test_flags += ['--checked'] | 323 if build_info.checked: test_flags += ['--checked'] |
303 | 324 if build_info.minified: test_flags += ['--minified'] |
304 if build_info.host_checked: test_flags += ['--host-checked'] | 325 if build_info.host_checked: test_flags += ['--host-checked'] |
305 | 326 |
306 if build_info.minified: test_flags += ['--minified'] | 327 if build_info.dart2js_full: |
| 328 compiler = build_info.compiler |
| 329 assert compiler == 'dart2js' |
| 330 system = build_info.system |
| 331 arch = build_info.arch |
| 332 mode = build_info.mode |
| 333 is_buildbot = build_info.is_buildbot |
| 334 for configuration in DART2JS_FULL_CONFIGURATIONS[system]: |
| 335 additional_flags = configuration.get('additional_flags', []) |
| 336 TestCompiler(configuration['runtime'], mode, system, |
| 337 test_flags + additional_flags, is_buildbot, arch, |
| 338 compiler=compiler, dart2js_full=True) |
| 339 else: |
| 340 if build_info.csp: test_flags += ['--csp'] |
307 | 341 |
308 if build_info.csp: test_flags += ['--csp'] | 342 if build_info.runtime == 'chromeOnAndroid': |
| 343 test_flags.append('--local_ip=%s' % GetLocalIPAddress()) |
| 344 # test.py expects the android tools directories to be in PATH |
| 345 # (they contain for example 'adb') |
| 346 AddAndroidToolsToPath() |
309 | 347 |
310 if build_info.runtime == 'chromeOnAndroid': | 348 TestCompiler(build_info.runtime, build_info.mode, build_info.system, |
311 test_flags.append('--local_ip=%s' % GetLocalIPAddress()) | 349 list(test_flags), build_info.is_buildbot, |
312 # test.py expects the android tools directories to be in PATH | 350 build_info.arch, compiler=build_info.compiler) |
313 # (they contain for example 'adb') | |
314 AddAndroidToolsToPath() | |
315 | 351 |
316 TestCompiler(build_info.runtime, build_info.mode, build_info.system, | 352 # See comment in GetHasHardCodedCheckedMode, this is a hack. |
317 list(test_flags), build_info.is_buildbot, build_info.test_set, | 353 if (GetHasHardCodedCheckedMode(build_info)): |
318 build_info.arch, compiler=build_info.compiler) | 354 TestCompiler(build_info.runtime, build_info.mode, build_info.system, |
319 | 355 test_flags + ['--checked'], build_info.is_buildbot, |
320 # See comment in GetHasHardCodedCheckedMode, this is a hack. | 356 build_info.arch, compiler=build_info.compiler) |
321 if (GetHasHardCodedCheckedMode(build_info)): | |
322 TestCompiler(build_info.runtime, build_info.mode, build_info.system, | |
323 test_flags + ['--checked'], build_info.is_buildbot, | |
324 build_info.test_set, build_info.arch, | |
325 compiler=build_info.compiler) | |
326 | 357 |
327 | 358 |
328 def BuildCompiler(build_info): | 359 def BuildCompiler(build_info): |
329 """ | 360 """ |
330 Builds the SDK. | 361 Builds the SDK. |
331 | 362 |
332 - build_info: the buildInfo object, containing information about what sort of | 363 - build_info: the buildInfo object, containing information about what sort of |
333 build and test to be run. | 364 build and test to be run. |
334 """ | 365 """ |
335 with bot.BuildStep('Build SDK and d8'): | 366 with bot.BuildStep('Build SDK'): |
336 args = [sys.executable, './tools/build.py', '--mode=' + build_info.mode, | 367 args = [sys.executable, './tools/build.py', '--mode=' + build_info.mode, |
337 '--arch=' + build_info.arch, 'dart2js_bot'] | 368 '--arch=' + build_info.arch, 'dart2js_bot'] |
338 print 'Build SDK and d8: %s' % (' '.join(args)) | 369 print 'Build SDK and d8: %s' % (' '.join(args)) |
339 bot.RunProcess(args) | 370 bot.RunProcess(args) |
340 | 371 |
341 | 372 |
342 if __name__ == '__main__': | 373 if __name__ == '__main__': |
343 bot.RunBot(GetBuildInfo, RunCompilerTests, build_step=BuildCompiler) | 374 bot.RunBot(GetBuildInfo, RunCompilerTests, build_step=BuildCompiler) |
OLD | NEW |