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

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

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

Powered by Google App Engine
This is Rietveld 408576698