| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Dart2js buildbot steps | 7 """Dart2js buildbot steps |
| 8 | 8 |
| 9 Runs tests for the dart2js compiler. | 9 Runs tests for the dart2js compiler. |
| 10 """ | 10 """ |
| 11 | 11 |
| 12 import platform | 12 import platform |
| 13 import optparse | 13 import optparse |
| 14 import os | 14 import os |
| 15 import re | 15 import re |
| 16 import shutil | 16 import shutil |
| 17 import subprocess | 17 import subprocess |
| 18 import sys | 18 import sys |
| 19 | 19 |
| 20 BUILDER_NAME = 'BUILDBOT_BUILDERNAME' | 20 BUILDER_NAME = 'BUILDBOT_BUILDERNAME' |
| 21 BUILDER_CLOBBER = 'BUILDBOT_CLOBBER' | 21 BUILDER_CLOBBER = 'BUILDBOT_CLOBBER' |
| 22 | 22 |
| 23 | 23 |
| 24 DART_PATH = os.path.dirname( | 24 DART_PATH = os.path.dirname( |
| 25 os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | 25 os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
| 26 | 26 |
| 27 DART2JS_BUILDER = ( | 27 DART2JS_BUILDER = ( |
| 28 r'dart2js-(linux|mac|windows)-(debug|release)(-([a-z]+))?-?(\d*)-?(\d*)') | 28 r'dart2js-(linux|mac|windows)-(debug|release)(-(checked|host-checked))?(-(ho
st-checked))?-?(\d*)-?(\d*)') |
| 29 # TODO(ricow): rename all builders from web- to dart2js-. |
| 29 WEB_BUILDER = ( | 30 WEB_BUILDER = ( |
| 30 r'web-(ie|ff|safari|chrome|opera)-(win7|win8|mac|linux)-?(\d*)-?(\d*)') | 31 r'(dart2js|web)-(ie|ff|safari|chrome|opera)-(win7|win8|mac|linux)-?(\d*)-?(\
d*)') |
| 31 | 32 |
| 32 NO_COLOR_ENV = dict(os.environ) | 33 NO_COLOR_ENV = dict(os.environ) |
| 33 NO_COLOR_ENV['TERM'] = 'nocolor' | 34 NO_COLOR_ENV['TERM'] = 'nocolor' |
| 34 | 35 |
| 35 def GetBuildInfo(): | 36 def GetBuildInfo(): |
| 36 """Returns a tuple (compiler, runtime, mode, system, option) where: | 37 """Returns a tuple (compiler, runtime, mode, system, checked, host_checked, |
| 38 shard_index, total_shards, is_buildbot) where: |
| 37 - compiler: 'dart2js' or None when the builder has an incorrect name | 39 - compiler: 'dart2js' or None when the builder has an incorrect name |
| 38 - runtime: 'd8', 'ie', 'ff', 'safari', 'chrome', 'opera' | 40 - runtime: 'd8', 'ie', 'ff', 'safari', 'chrome', 'opera' |
| 39 - mode: 'debug' or 'release' | 41 - mode: 'debug' or 'release' |
| 40 - system: 'linux', 'mac', or 'win7' | 42 - system: 'linux', 'mac', or 'win7' |
| 41 - option: 'checked' | 43 - checked: True if we should run in checked mode, otherwise False |
| 44 - host_checked: True if we should run in host checked mode, otherwise False |
| 45 - shard_index: The shard we are running, None when not specified. |
| 46 - total_shards: The total number of shards, None when not specified. |
| 47 - is_buildbot: True if we are on a buildbot (or emulating it). |
| 42 """ | 48 """ |
| 43 parser = optparse.OptionParser() | 49 parser = optparse.OptionParser() |
| 44 parser.add_option('-n', '--name', dest='name', help='The name of the build' | 50 parser.add_option('-n', '--name', dest='name', help='The name of the build' |
| 45 'bot you would like to emulate (ex: web-chrome-win7)', default=None) | 51 'bot you would like to emulate (ex: web-chrome-win7)', default=None) |
| 46 args, _ = parser.parse_args() | 52 args, _ = parser.parse_args() |
| 47 | 53 |
| 48 compiler = None | 54 compiler = None |
| 49 runtime = None | 55 runtime = None |
| 50 mode = None | 56 mode = None |
| 51 system = None | 57 system = None |
| 52 builder_name = os.environ.get(BUILDER_NAME) | 58 builder_name = os.environ.get(BUILDER_NAME) |
| 53 option = None | 59 checked = False |
| 60 host_checked = False |
| 54 shard_index = None | 61 shard_index = None |
| 55 total_shards = None | 62 total_shards = None |
| 56 is_buildbot = True | 63 is_buildbot = True |
| 57 if not builder_name: | 64 if not builder_name: |
| 58 # We are not running on a buildbot. | 65 # We are not running on a buildbot. |
| 59 is_buildbot = False | 66 is_buildbot = False |
| 60 if args.name: | 67 if args.name: |
| 61 builder_name = args.name | 68 builder_name = args.name |
| 62 else: | 69 else: |
| 63 print 'Use -n $BUILDBOT_NAME for the bot you would like to emulate.' | 70 print 'Use -n $BUILDBOT_NAME for the bot you would like to emulate.' |
| 64 sys.exit(1) | 71 sys.exit(1) |
| 65 | 72 |
| 66 if builder_name: | 73 if builder_name: |
| 67 dart2js_pattern = re.match(DART2JS_BUILDER, builder_name) | 74 dart2js_pattern = re.match(DART2JS_BUILDER, builder_name) |
| 68 web_pattern = re.match(WEB_BUILDER, builder_name) | 75 web_pattern = re.match(WEB_BUILDER, builder_name) |
| 69 | 76 |
| 70 if dart2js_pattern: | 77 if web_pattern: |
| 78 compiler = 'dart2js' |
| 79 runtime = web_pattern.group(2) |
| 80 system = web_pattern.group(3) |
| 81 mode = 'release' |
| 82 shard_index = web_pattern.group(3) |
| 83 total_shards = web_pattern.group(4) |
| 84 elif dart2js_pattern: |
| 71 compiler = 'dart2js' | 85 compiler = 'dart2js' |
| 72 runtime = 'd8' | 86 runtime = 'd8' |
| 73 system = dart2js_pattern.group(1) | 87 system = dart2js_pattern.group(1) |
| 74 mode = dart2js_pattern.group(2) | 88 mode = dart2js_pattern.group(2) |
| 75 option = dart2js_pattern.group(4) | 89 # The valid naming parts for checked and host-checked are: |
| 76 shard_index = dart2js_pattern.group(5) | 90 # Empty: checked=False, host_checked=False |
| 77 total_shards = dart2js_pattern.group(6) | 91 # -checked: checked=True, host_checked=False |
| 78 | 92 # -host-checked: checked=False, host_checked=True |
| 79 elif web_pattern: | 93 # -checked-host-checked: checked=True, host_checked=True |
| 80 compiler = 'dart2js' | 94 if dart2js_pattern.group(4) == 'checked': |
| 81 runtime = web_pattern.group(1) | 95 checked = True |
| 82 system = web_pattern.group(2) | 96 if dart2js_pattern.group(4) == 'host-checked': |
| 83 mode = 'release' | 97 host_checked = True |
| 84 shard_index = web_pattern.group(3) | 98 if dart2js_pattern.group(6) == 'host-checked': |
| 85 total_shards = web_pattern.group(4) | 99 host_checked = True |
| 100 shard_index = dart2js_pattern.group(7) |
| 101 total_shards = dart2js_pattern.group(8) |
| 86 | 102 |
| 87 if system == 'windows': | 103 if system == 'windows': |
| 88 system = 'win7' | 104 system = 'win7' |
| 89 | 105 |
| 90 if (system == 'win7' and platform.system() != 'Windows') or ( | 106 if (system == 'win7' and platform.system() != 'Windows') or ( |
| 91 system == 'mac' and platform.system() != 'Darwin') or ( | 107 system == 'mac' and platform.system() != 'Darwin') or ( |
| 92 system == 'linux' and platform.system() != 'Linux'): | 108 system == 'linux' and platform.system() != 'Linux'): |
| 93 print ('Error: You cannot emulate a buildbot with a platform different ' | 109 print ('Error: You cannot emulate a buildbot with a platform different ' |
| 94 'from your own.') | 110 'from your own.') |
| 95 sys.exit(1) | 111 sys.exit(1) |
| 96 return (compiler, runtime, mode, system, option, shard_index, total_shards, | 112 return (compiler, runtime, mode, system, checked, host_checked, shard_index, |
| 97 is_buildbot) | 113 total_shards, is_buildbot) |
| 98 | 114 |
| 99 | 115 |
| 100 def NeedsXterm(compiler, runtime): | 116 def NeedsXterm(compiler, runtime): |
| 101 return runtime in ['ie', 'chrome', 'safari', 'opera', 'ff', 'drt'] | 117 return runtime in ['ie', 'chrome', 'safari', 'opera', 'ff', 'drt'] |
| 102 | 118 |
| 103 | 119 |
| 104 def TestStepName(name, flags): | 120 def TestStepName(name, flags): |
| 105 # Filter out flags with '=' as this breaks the /stats feature of the | 121 # Filter out flags with '=' as this breaks the /stats feature of the |
| 106 # build bot. | 122 # build bot. |
| 107 flags = [x for x in flags if not '=' in x] | 123 flags = [x for x in flags if not '=' in x] |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 - mode: either 'debug' or 'release' | 167 - mode: either 'debug' or 'release' |
| 152 - system: either 'linux', 'mac', or 'win7' | 168 - system: either 'linux', 'mac', or 'win7' |
| 153 """ | 169 """ |
| 154 os.chdir(DART_PATH) | 170 os.chdir(DART_PATH) |
| 155 | 171 |
| 156 args = [sys.executable, './tools/build.py', '--mode=' + mode, 'create_sdk'] | 172 args = [sys.executable, './tools/build.py', '--mode=' + mode, 'create_sdk'] |
| 157 print 'running %s' % (' '.join(args)) | 173 print 'running %s' % (' '.join(args)) |
| 158 return subprocess.call(args, env=NO_COLOR_ENV) | 174 return subprocess.call(args, env=NO_COLOR_ENV) |
| 159 | 175 |
| 160 | 176 |
| 161 def TestCompiler(runtime, mode, system, option, flags, is_buildbot): | 177 def TestCompiler(runtime, mode, system, flags, is_buildbot): |
| 162 """ test the compiler. | 178 """ test the compiler. |
| 163 Args: | 179 Args: |
| 164 - runtime: either 'd8', or one of the browsers, see GetBuildInfo | 180 - runtime: either 'd8', or one of the browsers, see GetBuildInfo |
| 165 - mode: either 'debug' or 'release' | 181 - mode: either 'debug' or 'release' |
| 166 - system: either 'linux', 'mac', or 'win7' | 182 - system: either 'linux', 'mac', or 'win7' |
| 167 - option: 'checked' | |
| 168 - flags: extra flags to pass to test.dart | 183 - flags: extra flags to pass to test.dart |
| 169 - is_buildbot: true if we are running on a real buildbot instead of | 184 - is_buildbot: true if we are running on a real buildbot instead of |
| 170 emulating one. | 185 emulating one. |
| 171 """ | 186 """ |
| 172 | 187 |
| 173 # Make sure we are in the dart directory | 188 # Make sure we are in the dart directory |
| 174 os.chdir(DART_PATH) | 189 os.chdir(DART_PATH) |
| 175 | 190 |
| 176 if system.startswith('win') and runtime == 'ie': | 191 if system.startswith('win') and runtime == 'ie': |
| 177 # TODO(ahe): This pre-dates the shard feature and should be | 192 # TODO(ahe): This pre-dates the shard feature and should be |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 p = subprocess.Popen(version_query_string, | 240 p = subprocess.Popen(version_query_string, |
| 226 stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) | 241 stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) |
| 227 output, stderr = p.communicate() | 242 output, stderr = p.communicate() |
| 228 output = output.split() | 243 output = output.split() |
| 229 try: | 244 try: |
| 230 print 'Version of %s: %s' % (runtime, output[-1]) | 245 print 'Version of %s: %s' % (runtime, output[-1]) |
| 231 except IndexError: | 246 except IndexError: |
| 232 # Failed to obtain version information. Continue running tests. | 247 # Failed to obtain version information. Continue running tests. |
| 233 pass | 248 pass |
| 234 | 249 |
| 235 if option == 'checked': flags = flags + ['--host-checked'] | |
| 236 | |
| 237 if runtime == 'd8': | 250 if runtime == 'd8': |
| 238 # The dart2js compiler isn't self-hosted (yet) so we run its | 251 # The dart2js compiler isn't self-hosted (yet) so we run its |
| 239 # unit tests on the VM. We avoid doing this on the builders | 252 # unit tests on the VM. We avoid doing this on the builders |
| 240 # that run the browser tests to cut down on the cycle time. | 253 # that run the browser tests to cut down on the cycle time. |
| 241 TestStep("dart2js_unit", mode, system, 'none', 'vm', ['dart2js'], flags) | 254 TestStep("dart2js_unit", mode, system, 'none', 'vm', ['dart2js'], flags) |
| 242 | 255 |
| 243 if not (system.startswith('win') and runtime == 'ie'): | 256 if not (system.startswith('win') and runtime == 'ie'): |
| 244 # Run the default set of test suites. | 257 # Run the default set of test suites. |
| 245 TestStep("dart2js", mode, system, 'dart2js', runtime, [], flags) | 258 TestStep("dart2js", mode, system, 'dart2js', runtime, [], flags) |
| 246 | 259 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 return subprocess.call(cmd, env=NO_COLOR_ENV) | 323 return subprocess.call(cmd, env=NO_COLOR_ENV) |
| 311 | 324 |
| 312 def GetShouldClobber(): | 325 def GetShouldClobber(): |
| 313 return os.environ.get(BUILDER_CLOBBER) == "1" | 326 return os.environ.get(BUILDER_CLOBBER) == "1" |
| 314 | 327 |
| 315 def main(): | 328 def main(): |
| 316 if len(sys.argv) == 0: | 329 if len(sys.argv) == 0: |
| 317 print 'Script pathname not known, giving up.' | 330 print 'Script pathname not known, giving up.' |
| 318 return 1 | 331 return 1 |
| 319 | 332 |
| 320 (compiler, runtime, mode, system, option, shard_index, total_shards, | 333 (compiler, runtime, mode, system, checked, host_checked, shard_index, |
| 321 is_buildbot) = GetBuildInfo() | 334 total_shards, is_buildbot) = GetBuildInfo() |
| 322 shard_description = "" | 335 shard_description = "" |
| 323 if shard_index: | 336 if shard_index: |
| 324 shard_description = " shard %s of %s" % (shard_index, total_shards) | 337 shard_description = " shard %s of %s" % (shard_index, total_shards) |
| 325 print "compiler: %s, runtime: %s mode: %s, system: %s, option: %s%s" % ( | 338 print ("compiler: %s, runtime: %s mode: %s, system: %s," |
| 326 compiler, runtime, mode, system, option, shard_description) | 339 " checked: %s, host-checked: %s%s") % (compiler, runtime, mode, system, |
| 340 checked, host_checked, |
| 341 shard_description) |
| 342 |
| 327 if compiler is None: | 343 if compiler is None: |
| 328 return 1 | 344 return 1 |
| 329 | 345 |
| 330 if GetShouldClobber(): | 346 if GetShouldClobber(): |
| 331 print '@@@BUILD_STEP Clobber@@@' | 347 print '@@@BUILD_STEP Clobber@@@' |
| 332 status = ClobberBuilder(mode) | 348 status = ClobberBuilder(mode) |
| 333 if status != 0: | 349 if status != 0: |
| 334 print '@@@STEP_FAILURE@@@' | 350 print '@@@STEP_FAILURE@@@' |
| 335 return status | 351 return status |
| 336 | 352 |
| 337 print '@@@BUILD_STEP build sdk@@@' | 353 print '@@@BUILD_STEP build sdk@@@' |
| 338 status = BuildSDK(mode, system) | 354 status = BuildSDK(mode, system) |
| 339 if status != 0: | 355 if status != 0: |
| 340 print '@@@STEP_FAILURE@@@' | 356 print '@@@STEP_FAILURE@@@' |
| 341 return status | 357 return status |
| 342 | 358 |
| 343 test_flags = [] | 359 test_flags = [] |
| 344 if shard_index: | 360 if shard_index: |
| 345 test_flags = ['--shards=%s' % total_shards, '--shard=%s' % shard_index] | 361 test_flags = ['--shards=%s' % total_shards, '--shard=%s' % shard_index] |
| 346 | 362 |
| 347 # First we run all the regular tests. | 363 if checked: test_flags += ['--checked'] |
| 348 status = TestCompiler(runtime, mode, system, option, test_flags, | |
| 349 is_buildbot) | |
| 350 | 364 |
| 351 if (status == 0 | 365 if host_checked: test_flags += ['--host-checked'] |
| 352 and (system == 'linux' or runtime != 'chrome') | 366 |
| 353 and runtime != 'opera' | 367 status = TestCompiler(runtime, mode, system, test_flags, is_buildbot) |
| 354 and runtime != 'ff' | 368 |
| 355 and runtime != 'ie' | 369 # TODO(ricow): We currently have only one browser runtime that runs checked |
| 356 and runtime != 'safari'): | 370 # mode test where this is not reflected by the name, namely dart2js on chrome |
| 357 status = TestCompiler(runtime, mode, system, option, | 371 # linux. We should eliminate this (by splitting this onto two builders - |
| 358 test_flags + ['--checked'], is_buildbot) | 372 # potentially on the same vm). |
| 373 if (status == 0 and system == 'linux' and runtime == 'chrome'): |
| 374 status = TestCompiler(runtime, mode, system, test_flags + ['--checked'], |
| 375 is_buildbot) |
| 359 | 376 |
| 360 if runtime != 'd8': CleanUpTemporaryFiles(system, runtime) | 377 if runtime != 'd8': CleanUpTemporaryFiles(system, runtime) |
| 361 if status != 0: print '@@@STEP_FAILURE@@@' | 378 if status != 0: print '@@@STEP_FAILURE@@@' |
| 362 return status | 379 return status |
| 363 | 380 |
| 364 if __name__ == '__main__': | 381 if __name__ == '__main__': |
| 365 sys.exit(main()) | 382 sys.exit(main()) |
| OLD | NEW |