Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: utils/compiler/buildbot.py

Issue 10951025: Reapply change which was reverted by mistake. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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)(-(checked|host-checked))?(-(ho st-checked))?-?(\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-.
30 WEB_BUILDER = ( 29 WEB_BUILDER = (
31 r'(dart2js|web)-(ie|ff|safari|chrome|opera)-(win7|win8|mac|linux)-?(\d*)-?(\ d*)') 30 r'dart2js-(ie|ff|safari|chrome|opera)-(win7|win8|mac|linux)(-(all|html))?')
32 31
33 NO_COLOR_ENV = dict(os.environ) 32 NO_COLOR_ENV = dict(os.environ)
34 NO_COLOR_ENV['TERM'] = 'nocolor' 33 NO_COLOR_ENV['TERM'] = 'nocolor'
35 34
36 def GetBuildInfo(): 35 class BuildInfo(object):
37 """Returns a tuple (compiler, runtime, mode, system, checked, host_checked, 36 """ Encapsulation of build information.
38 shard_index, total_shards, is_buildbot) where:
39 - compiler: 'dart2js' or None when the builder has an incorrect name 37 - compiler: 'dart2js' or None when the builder has an incorrect name
40 - runtime: 'd8', 'ie', 'ff', 'safari', 'chrome', 'opera' 38 - runtime: 'd8', 'ie', 'ff', 'safari', 'chrome', 'opera'
41 - mode: 'debug' or 'release' 39 - mode: 'debug' or 'release'
42 - system: 'linux', 'mac', or 'win7' 40 - system: 'linux', 'mac', or 'win7'
43 - checked: True if we should run in checked mode, otherwise False 41 - 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 42 - 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. 43 - shard_index: The shard we are running, None when not specified.
46 - total_shards: The total number of shards, None when not specified. 44 - total_shards: The total number of shards, None when not specified.
47 - is_buildbot: True if we are on a buildbot (or emulating it). 45 - is_buildbot: True if we are on a buildbot (or emulating it).
46 - test_set: Specification of a non standard test set, default None
47 """
48 def __init__(self, compiler, runtime, mode, system, checked=False,
49 host_checked=False, shard_index=None, total_shards=None,
50 is_buildbot=False, test_set=None):
51 self.compiler = compiler
52 self.runtime = runtime
53 self.mode = mode
54 self.system = system
55 self.checked = checked
56 self.host_checked = host_checked
57 self.shard_index = shard_index
58 self.total_shards = total_shards
59 self.is_buildbot = is_buildbot
60 self.test_set = test_set
61
62 def PrintBuildInfo(self):
63 shard_description = ""
64 if self.shard_index:
65 shard_description = " shard %s of %s" % (self.shard_index,
66 self.total_shards)
67 print ("compiler: %s, runtime: %s mode: %s, system: %s,"
68 " checked: %s, host-checked: %s, test-set: %s%s"
69 ) % (self.compiler, self.runtime, self.mode, self.system,
70 self.checked, self.host_checked, self.test_set,
71 shard_description)
72
73
74 def GetBuildInfo():
75 """Returns a BuildInfo object for the current buildbot based on the
76 name of the builder.
48 """ 77 """
49 parser = optparse.OptionParser() 78 parser = optparse.OptionParser()
50 parser.add_option('-n', '--name', dest='name', help='The name of the build' 79 parser.add_option('-n', '--name', dest='name', help='The name of the build'
51 'bot you would like to emulate (ex: web-chrome-win7)', default=None) 80 'bot you would like to emulate (ex: web-chrome-win7)', default=None)
52 args, _ = parser.parse_args() 81 args, _ = parser.parse_args()
53 82
54 compiler = None 83 compiler = None
55 runtime = None 84 runtime = None
56 mode = None 85 mode = None
57 system = None 86 system = None
58 builder_name = os.environ.get(BUILDER_NAME) 87 builder_name = os.environ.get(BUILDER_NAME)
59 checked = False 88 checked = False
60 host_checked = False 89 host_checked = False
61 shard_index = None 90 shard_index = None
62 total_shards = None 91 total_shards = None
63 is_buildbot = True 92 is_buildbot = True
93 test_set = None
94
64 if not builder_name: 95 if not builder_name:
65 # We are not running on a buildbot. 96 # We are not running on a buildbot.
66 is_buildbot = False 97 is_buildbot = False
67 if args.name: 98 if args.name:
68 builder_name = args.name 99 builder_name = args.name
69 else: 100 else:
70 print 'Use -n $BUILDBOT_NAME for the bot you would like to emulate.' 101 print 'Use -n $BUILDBOT_NAME for the bot you would like to emulate.'
71 sys.exit(1) 102 sys.exit(1)
72 103
73 if builder_name: 104 if builder_name:
74 dart2js_pattern = re.match(DART2JS_BUILDER, builder_name) 105 dart2js_pattern = re.match(DART2JS_BUILDER, builder_name)
75 web_pattern = re.match(WEB_BUILDER, builder_name) 106 web_pattern = re.match(WEB_BUILDER, builder_name)
76 107
77 if web_pattern: 108 if web_pattern:
78 compiler = 'dart2js' 109 compiler = 'dart2js'
79 runtime = web_pattern.group(2) 110 runtime = web_pattern.group(1)
80 system = web_pattern.group(3) 111 system = web_pattern.group(2)
81 mode = 'release' 112 mode = 'release'
82 shard_index = web_pattern.group(4) 113 test_set = web_pattern.group(4)
83 total_shards = web_pattern.group(5)
84 elif dart2js_pattern: 114 elif dart2js_pattern:
85 compiler = 'dart2js' 115 compiler = 'dart2js'
86 runtime = 'd8' 116 runtime = 'd8'
87 system = dart2js_pattern.group(1) 117 system = dart2js_pattern.group(1)
88 mode = dart2js_pattern.group(2) 118 mode = dart2js_pattern.group(2)
89 # The valid naming parts for checked and host-checked are: 119 # The valid naming parts for checked and host-checked are:
90 # Empty: checked=False, host_checked=False 120 # Empty: checked=False, host_checked=False
91 # -checked: checked=True, host_checked=False 121 # -checked: checked=True, host_checked=False
92 # -host-checked: checked=False, host_checked=True 122 # -host-checked: checked=False, host_checked=True
93 # -checked-host-checked: checked=True, host_checked=True 123 # -checked-host-checked: checked=True, host_checked=True
94 if dart2js_pattern.group(4) == 'checked': 124 if dart2js_pattern.group(4) == 'checked':
95 checked = True 125 checked = True
96 if dart2js_pattern.group(4) == 'host-checked': 126 if dart2js_pattern.group(4) == 'host-checked':
97 host_checked = True 127 host_checked = True
98 if dart2js_pattern.group(6) == 'host-checked': 128 if dart2js_pattern.group(6) == 'host-checked':
99 host_checked = True 129 host_checked = True
100 shard_index = dart2js_pattern.group(7) 130 shard_index = dart2js_pattern.group(7)
101 total_shards = dart2js_pattern.group(8) 131 total_shards = dart2js_pattern.group(8)
102 132
103 if system == 'windows': 133 if system == 'windows':
104 system = 'win7' 134 system = 'win7'
105 135
106 if (system == 'win7' and platform.system() != 'Windows') or ( 136 if (system == 'win7' and platform.system() != 'Windows') or (
107 system == 'mac' and platform.system() != 'Darwin') or ( 137 system == 'mac' and platform.system() != 'Darwin') or (
108 system == 'linux' and platform.system() != 'Linux'): 138 system == 'linux' and platform.system() != 'Linux'):
109 print ('Error: You cannot emulate a buildbot with a platform different ' 139 print ('Error: You cannot emulate a buildbot with a platform different '
110 'from your own.') 140 'from your own.')
111 sys.exit(1) 141 return BuildInfo(compiler, runtime, mode, system, checked, host_checked,
112 return (compiler, runtime, mode, system, checked, host_checked, shard_index, 142 shard_index, total_shards, is_buildbot, test_set)
113 total_shards, is_buildbot)
114 143
115 144
116 def NeedsXterm(compiler, runtime): 145 def NeedsXterm(compiler, runtime):
117 return runtime in ['ie', 'chrome', 'safari', 'opera', 'ff', 'drt'] 146 return runtime in ['ie', 'chrome', 'safari', 'opera', 'ff', 'drt']
118 147
119 148
120 def TestStepName(name, flags): 149 def TestStepName(name, flags):
121 # Filter out flags with '=' as this breaks the /stats feature of the 150 # Filter out flags with '=' as this breaks the /stats feature of the
122 # build bot. 151 # build bot.
123 flags = [x for x in flags if not '=' in x] 152 flags = [x for x in flags if not '=' in x]
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 - mode: either 'debug' or 'release' 196 - mode: either 'debug' or 'release'
168 - system: either 'linux', 'mac', or 'win7' 197 - system: either 'linux', 'mac', or 'win7'
169 """ 198 """
170 os.chdir(DART_PATH) 199 os.chdir(DART_PATH)
171 200
172 args = [sys.executable, './tools/build.py', '--mode=' + mode, 'create_sdk'] 201 args = [sys.executable, './tools/build.py', '--mode=' + mode, 'create_sdk']
173 print 'running %s' % (' '.join(args)) 202 print 'running %s' % (' '.join(args))
174 return subprocess.call(args, env=NO_COLOR_ENV) 203 return subprocess.call(args, env=NO_COLOR_ENV)
175 204
176 205
177 def TestCompiler(runtime, mode, system, flags, is_buildbot): 206 def TestCompiler(runtime, mode, system, flags, is_buildbot, test_set):
178 """ test the compiler. 207 """ test the compiler.
179 Args: 208 Args:
180 - runtime: either 'd8', or one of the browsers, see GetBuildInfo 209 - runtime: either 'd8', or one of the browsers, see GetBuildInfo
181 - mode: either 'debug' or 'release' 210 - mode: either 'debug' or 'release'
182 - system: either 'linux', 'mac', or 'win7' 211 - system: either 'linux', 'mac', or 'win7'
183 - flags: extra flags to pass to test.dart 212 - flags: extra flags to pass to test.dart
184 - is_buildbot: true if we are running on a real buildbot instead of 213 - is_buildbot: true if we are running on a real buildbot instead of
185 emulating one. 214 emulating one.
215 - test_set: Specification of a non standard test set, default None
186 """ 216 """
187 217
188 # Make sure we are in the dart directory 218 # Make sure we are in the dart directory
189 os.chdir(DART_PATH) 219 os.chdir(DART_PATH)
190 220
191 if system.startswith('win') and runtime == 'ie': 221 if system.startswith('win') and runtime == 'ie':
192 # TODO(ahe): This pre-dates the shard feature and should be
193 # removed. If we want to have a fast and a slow bot, that should
194 # be accomplished by having several shards distributed on multiple
195 # virtual builders.
196
197 # We don't do proper sharding on the IE bots, since the runtime is
198 # long for both. We have a "fast bot" and a "slow bot" that run specific
199 # tests instead.
200 for i in flags:
201 if i.startswith('--shard='):
202 bot_num = i.split('=')[1]
203 # There should not be more than one InternetExplorerDriver instance 222 # There should not be more than one InternetExplorerDriver instance
204 # running at a time. For details, see 223 # running at a time. For details, see
205 # http://code.google.com/p/selenium/wiki/InternetExplorerDriver. 224 # http://code.google.com/p/selenium/wiki/InternetExplorerDriver.
206 flags = (filter(lambda(item): not item.startswith('--shard'), flags) + 225 flags += ['-j1']
207 ['-j1'])
208 226
209 def GetPath(runtime): 227 def GetPath(runtime):
210 """ Helper to get the path to the Chrome or Firefox executable for a 228 """ Helper to get the path to the Chrome or Firefox executable for a
211 particular platform on the buildbot. Throws a KeyError if runtime is not 229 particular platform on the buildbot. Throws a KeyError if runtime is not
212 either 'chrome' or 'ff'.""" 230 either 'chrome' or 'ff'."""
213 if system == 'mac': 231 if system == 'mac':
214 partDict = {'chrome': 'Google\\ Chrome', 'ff': 'Firefox'} 232 partDict = {'chrome': 'Google\\ Chrome', 'ff': 'Firefox'}
215 mac_path = '/Applications/%s.app/Contents/MacOS/%s' 233 mac_path = '/Applications/%s.app/Contents/MacOS/%s'
216 path_dict = {'chrome': mac_path % (partDict[runtime], partDict[runtime]), 234 path_dict = {'chrome': mac_path % (partDict[runtime], partDict[runtime]),
217 'ff': mac_path % (partDict[runtime], partDict[runtime].lower())} 235 'ff': mac_path % (partDict[runtime], partDict[runtime].lower())}
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 TestStep("dart2js_unit", mode, system, 'none', 'vm', ['dart2js'], flags) 272 TestStep("dart2js_unit", mode, system, 'none', 'vm', ['dart2js'], flags)
255 273
256 if not (system.startswith('win') and runtime == 'ie'): 274 if not (system.startswith('win') and runtime == 'ie'):
257 # Run the default set of test suites. 275 # Run the default set of test suites.
258 TestStep("dart2js", mode, system, 'dart2js', runtime, [], flags) 276 TestStep("dart2js", mode, system, 'dart2js', runtime, [], flags)
259 277
260 # TODO(kasperl): Consider running peg and css tests too. 278 # TODO(kasperl): Consider running peg and css tests too.
261 extras = ['dart2js_extra', 'dart2js_native', 'dart2js_foreign'] 279 extras = ['dart2js_extra', 'dart2js_native', 'dart2js_foreign']
262 TestStep("dart2js_extra", mode, system, 'dart2js', runtime, extras, flags) 280 TestStep("dart2js_extra", mode, system, 'dart2js', runtime, extras, flags)
263 else: 281 else:
264 # TODO(ahe): See comment above regarding how to use sharding to 282 # TODO(ricow): Enable standard sharding for IE bots when we have more vms.
265 # accomplish the same. 283 if test_set == 'html':
266 if bot_num == '1':
267 TestStep("dart2js", mode, system, 'dart2js', runtime, ['html'], flags) 284 TestStep("dart2js", mode, system, 'dart2js', runtime, ['html'], flags)
268 else: 285 elif test_set == 'all':
269 TestStep("dart2js", mode, system, 'dart2js', runtime, ['dartc', 286 TestStep("dart2js", mode, system, 'dart2js', runtime, ['dartc',
270 'samples', 'standalone', 'corelib', 'co19', 'language', 'isolate', 287 'samples', 'standalone', 'corelib', 'co19', 'language', 'isolate',
271 'vm', 'json', 'benchmark_smoke', 'dartdoc', 'utils', 'pub', 'lib'], 288 'vm', 'json', 'benchmark_smoke', 'dartdoc', 'utils', 'pub', 'lib'],
272 flags) 289 flags)
273 extras = ['dart2js_extra', 'dart2js_native', 'dart2js_foreign'] 290 extras = ['dart2js_extra', 'dart2js_native', 'dart2js_foreign']
274 TestStep("dart2js_extra", mode, system, 'dart2js', runtime, extras, 291 TestStep("dart2js_extra", mode, system, 'dart2js', runtime, extras,
275 flags) 292 flags)
276 293
277 return 0 294 return 0
278 295
279 def _DeleteFirefoxProfiles(directory): 296 def _DeleteFirefoxProfiles(directory):
280 """Find all the firefox profiles in a particular directory and delete them.""" 297 """Find all the firefox profiles in a particular directory and delete them."""
281 for f in os.listdir(directory): 298 for f in os.listdir(directory):
282 item = os.path.join(directory, f) 299 item = os.path.join(directory, f)
283 if os.path.isdir(item) and f.startswith('tmp'): 300 if os.path.isdir(item) and f.startswith('tmp'):
284 subprocess.Popen('rm -rf %s' % item, shell=True) 301 subprocess.Popen('rm -rf %s' % item, shell=True)
285 302
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 return subprocess.call(cmd, env=NO_COLOR_ENV) 340 return subprocess.call(cmd, env=NO_COLOR_ENV)
324 341
325 def GetShouldClobber(): 342 def GetShouldClobber():
326 return os.environ.get(BUILDER_CLOBBER) == "1" 343 return os.environ.get(BUILDER_CLOBBER) == "1"
327 344
328 def main(): 345 def main():
329 if len(sys.argv) == 0: 346 if len(sys.argv) == 0:
330 print 'Script pathname not known, giving up.' 347 print 'Script pathname not known, giving up.'
331 return 1 348 return 1
332 349
333 (compiler, runtime, mode, system, checked, host_checked, shard_index, 350 build_info = GetBuildInfo()
334 total_shards, is_buildbot) = GetBuildInfo()
335 shard_description = ""
336 if shard_index:
337 shard_description = " shard %s of %s" % (shard_index, total_shards)
338 print ("compiler: %s, runtime: %s mode: %s, system: %s,"
339 " checked: %s, host-checked: %s%s") % (compiler, runtime, mode, system,
340 checked, host_checked,
341 shard_description)
342 351
343 if compiler is None: 352 # Print out the buildinfo for easy debugging.
353 build_info.PrintBuildInfo()
354
355 if build_info.compiler is None:
344 return 1 356 return 1
345 357
346 if GetShouldClobber(): 358 if GetShouldClobber():
347 print '@@@BUILD_STEP Clobber@@@' 359 print '@@@BUILD_STEP Clobber@@@'
348 status = ClobberBuilder(mode) 360 status = ClobberBuilder(build_info.mode)
349 if status != 0: 361 if status != 0:
350 print '@@@STEP_FAILURE@@@' 362 print '@@@STEP_FAILURE@@@'
351 return status 363 return status
352 364
353 print '@@@BUILD_STEP build sdk@@@' 365 print '@@@BUILD_STEP build sdk@@@'
354 status = BuildSDK(mode, system) 366 status = BuildSDK(build_info.mode, build_info.system)
355 if status != 0: 367 if status != 0:
356 print '@@@STEP_FAILURE@@@' 368 print '@@@STEP_FAILURE@@@'
357 return status 369 return status
358 370
359 test_flags = [] 371 test_flags = []
360 if shard_index: 372 if build_info.shard_index:
361 test_flags = ['--shards=%s' % total_shards, '--shard=%s' % shard_index] 373 test_flags = ['--shards=%s' % build_info.total_shards,
374 '--shard=%s' % build_info.shard_index]
362 375
363 if checked: test_flags += ['--checked'] 376 if build_info.checked: test_flags += ['--checked']
364 377
365 if host_checked: test_flags += ['--host-checked'] 378 if build_info.host_checked: test_flags += ['--host-checked']
366 379
367 status = TestCompiler(runtime, mode, system, test_flags, is_buildbot) 380 status = TestCompiler(build_info.runtime, build_info.mode,
381 build_info.system, test_flags,
382 build_info.is_buildbot, build_info.test_set)
368 383
369 # TODO(ricow): We currently have only one browser runtime that runs checked 384 # TODO(ricow): We currently have only one browser runtime that runs checked
370 # mode test where this is not reflected by the name, namely dart2js on chrome 385 # mode test where this is not reflected by the name, namely dart2js on chrome
371 # linux. We should eliminate this (by splitting this onto two builders - 386 # linux. We should eliminate this (by splitting this onto two builders -
372 # potentially on the same vm). 387 # potentially on the same vm).
373 if (status == 0 and system == 'linux' and runtime == 'chrome'): 388 # When this is fixed we should simply pass build_info to TestCompiler.
374 status = TestCompiler(runtime, mode, system, test_flags + ['--checked'], 389 if (status == 0 and build_info.system == 'linux' and
375 is_buildbot) 390 build_info.runtime == 'chrome'):
391 status = TestCompiler(build_info.runtime, build_info.mode,
392 build_info.system,
393 test_flags + ['--checked'],
394 build_info.is_buildbot,
395 build_info.test_set)
376 396
377 if runtime != 'd8': CleanUpTemporaryFiles(system, runtime) 397 if build_info.runtime != 'd8': CleanUpTemporaryFiles(build_info.system,
398 build_info.runtime)
378 if status != 0: print '@@@STEP_FAILURE@@@' 399 if status != 0: print '@@@STEP_FAILURE@@@'
379 return status 400 return status
380 401
381 if __name__ == '__main__': 402 if __name__ == '__main__':
382 sys.exit(main()) 403 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698