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 """Dart frog buildbot steps | 7 """Dart frog buildbot steps |
8 | 8 |
9 Runs tests for the frog or dart2js compiler. | 9 Runs tests for the frog or dart2js compiler. |
10 """ | 10 """ |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 args, _ = parser.parse_args() | 47 args, _ = parser.parse_args() |
48 | 48 |
49 compiler = None | 49 compiler = None |
50 runtime = None | 50 runtime = None |
51 mode = None | 51 mode = None |
52 system = None | 52 system = None |
53 builder_name = os.environ.get(BUILDER_NAME) | 53 builder_name = os.environ.get(BUILDER_NAME) |
54 option = None | 54 option = None |
55 shard_index = None | 55 shard_index = None |
56 total_shards = None | 56 total_shards = None |
| 57 is_buildbot = True |
57 if not builder_name: | 58 if not builder_name: |
58 # We are not running on a buildbot. | 59 # We are not running on a buildbot. |
| 60 is_buildbot = False |
59 if args.name: | 61 if args.name: |
60 builder_name = args.name | 62 builder_name = args.name |
61 else: | 63 else: |
62 print 'Use -n $BUILDBOT_NAME for the bot you would like to emulate.' | 64 print 'Use -n $BUILDBOT_NAME for the bot you would like to emulate.' |
63 sys.exit(1) | 65 sys.exit(1) |
64 | 66 |
65 if builder_name: | 67 if builder_name: |
66 dart2js_pattern = re.match(DART2JS_BUILDER, builder_name) | 68 dart2js_pattern = re.match(DART2JS_BUILDER, builder_name) |
67 frog_pattern = re.match(FROG_BUILDER, builder_name) | 69 frog_pattern = re.match(FROG_BUILDER, builder_name) |
68 web_pattern = re.match(WEB_BUILDER, builder_name) | 70 web_pattern = re.match(WEB_BUILDER, builder_name) |
(...skipping 23 matching lines...) Expand all Loading... |
92 | 94 |
93 if system == 'windows': | 95 if system == 'windows': |
94 system = 'win7' | 96 system = 'win7' |
95 | 97 |
96 if (system == 'win7' and platform.system() != 'Windows') or ( | 98 if (system == 'win7' and platform.system() != 'Windows') or ( |
97 system == 'mac' and platform.system() != 'Darwin') or ( | 99 system == 'mac' and platform.system() != 'Darwin') or ( |
98 system == 'linux' and platform.system() != 'Linux'): | 100 system == 'linux' and platform.system() != 'Linux'): |
99 print ('Error: You cannot emulate a buildbot with a platform different ' | 101 print ('Error: You cannot emulate a buildbot with a platform different ' |
100 'from your own.') | 102 'from your own.') |
101 sys.exit(1) | 103 sys.exit(1) |
102 return (compiler, runtime, mode, system, option, shard_index, total_shards) | 104 return (compiler, runtime, mode, system, option, shard_index, total_shards, |
| 105 is_buildbot) |
103 | 106 |
104 | 107 |
105 def NeedsXterm(compiler, runtime): | 108 def NeedsXterm(compiler, runtime): |
106 return runtime in ['ie', 'chrome', 'safari', 'opera', 'ff', 'drt'] | 109 return runtime in ['ie', 'chrome', 'safari', 'opera', 'ff', 'drt'] |
107 | 110 |
108 def TestStep(name, mode, system, compiler, runtime, targets, flags): | 111 def TestStep(name, mode, system, compiler, runtime, targets, flags): |
109 print '@@@BUILD_STEP %s %s tests: %s %s@@@' % (name, compiler, runtime, | 112 print '@@@BUILD_STEP %s %s tests: %s %s@@@' % (name, compiler, runtime, |
110 ' '.join(flags)) | 113 ' '.join(flags)) |
111 sys.stdout.flush() | 114 sys.stdout.flush() |
112 if NeedsXterm(compiler, runtime) and system == 'linux': | 115 if NeedsXterm(compiler, runtime) and system == 'linux': |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 shutil.rmtree('frog/%s' % outdir, ignore_errors=True) | 162 shutil.rmtree('frog/%s' % outdir, ignore_errors=True) |
160 shutil.rmtree('runtime/%s' % outdir, ignore_errors=True) | 163 shutil.rmtree('runtime/%s' % outdir, ignore_errors=True) |
161 | 164 |
162 os.chdir(DART_PATH) | 165 os.chdir(DART_PATH) |
163 | 166 |
164 args = [sys.executable, './tools/build.py', '--mode=' + mode, 'create_sdk'] | 167 args = [sys.executable, './tools/build.py', '--mode=' + mode, 'create_sdk'] |
165 print 'running %s' % (' '.join(args)) | 168 print 'running %s' % (' '.join(args)) |
166 return subprocess.call(args, env=NO_COLOR_ENV) | 169 return subprocess.call(args, env=NO_COLOR_ENV) |
167 | 170 |
168 | 171 |
169 def TestCompiler(compiler, runtime, mode, system, option, flags): | 172 def TestCompiler(compiler, runtime, mode, system, option, flags, is_buildbot): |
170 """ test the compiler. | 173 """ test the compiler. |
171 Args: | 174 Args: |
172 - compiler: either 'dart2js' or 'frog' | 175 - compiler: either 'dart2js' or 'frog' |
173 - runtime: either 'd8', or one of the browsers, see GetBuildInfo | 176 - runtime: either 'd8', or one of the browsers, see GetBuildInfo |
174 - mode: either 'debug' or 'release' | 177 - mode: either 'debug' or 'release' |
175 - system: either 'linux', 'mac', or 'win7' | 178 - system: either 'linux', 'mac', or 'win7' |
176 - option: 'checked' | 179 - option: 'checked' |
177 - flags: extra flags to pass to test.dart | 180 - flags: extra flags to pass to test.dart |
| 181 - is_buildbot: true if we are running on a real buildbot instead of |
| 182 emulating one. |
178 """ | 183 """ |
179 | 184 |
180 # Make sure we are in the frog directory | 185 # Make sure we are in the frog directory |
181 os.chdir(DART_PATH) | 186 os.chdir(DART_PATH) |
182 | 187 |
183 if system.startswith('win') and runtime == 'ie': | 188 if system.startswith('win') and runtime == 'ie': |
184 # We don't do proper sharding on the IE bots, since the runtime is | 189 # We don't do proper sharding on the IE bots, since the runtime is |
185 # long for both. We have a "fast bot" and a "slow bot" that run specific | 190 # long for both. We have a "fast bot" and a "slow bot" that run specific |
186 # tests instead. | 191 # tests instead. |
187 for i in flags: | 192 for i in flags: |
188 if i.startswith('--shard='): | 193 if i.startswith('--shard='): |
189 bot_num = i.split('=')[1] | 194 bot_num = i.split('=')[1] |
190 # There should not be more than one InternetExplorerDriver instance | 195 # There should not be more than one InternetExplorerDriver instance |
191 # running at a time. For details, see | 196 # running at a time. For details, see |
192 # http://code.google.com/p/selenium/wiki/InternetExplorerDriver. | 197 # http://code.google.com/p/selenium/wiki/InternetExplorerDriver. |
193 flags = (filter(lambda(item): not item.startswith('--shard'), flags) + | 198 flags = (filter(lambda(item): not item.startswith('--shard'), flags) + |
194 ['-j1']) | 199 ['-j1']) |
195 | 200 |
| 201 def GetPath(runtime): |
| 202 """ Helper to get the path to the Chrome or Firefox executable for a |
| 203 particular platform on the buildbot. Throws a KeyError if runtime is not |
| 204 either 'chrome' or 'ff'.""" |
| 205 if system == 'mac': |
| 206 partDict = {'chrome': 'Google\\ Chrome', 'ff': 'Firefox'} |
| 207 mac_path = '/Applications/%s.app/Contents/MacOS/%s' |
| 208 path_dict = {'chrome': mac_path % (partDict[runtime], partDict[runtime]), |
| 209 'ff': mac_path % (partDict[runtime], partDict[runtime].lower())} |
| 210 elif system == 'linux': |
| 211 path_dict = {'ff': 'firefox', 'chrome': 'google-chrome'} |
| 212 else: |
| 213 # Windows. |
| 214 path_dict = {'ff': os.path.join('C:/', 'Program Files (x86)', |
| 215 'Mozilla Firefox', 'firefox.exe'), |
| 216 'chrome': os.path.join('C:/', 'Users', 'chrome-bot', 'AppData', |
| 217 'Local', 'Google', 'Chrome', 'Application', 'chrome.exe')} |
| 218 return path_dict[runtime] |
| 219 |
196 if system == 'linux' and runtime == 'chrome': | 220 if system == 'linux' and runtime == 'chrome': |
197 # TODO(ngeoffray): We should install selenium on the buildbot. | 221 # TODO(ngeoffray): We should install selenium on the buildbot. |
198 runtime = 'drt' | 222 runtime = 'drt' |
| 223 elif ((runtime == 'ff' or runtime == 'chrome') and is_buildbot: |
| 224 # Print out browser version numbers if we're running on the buildbot (where |
| 225 # we know the paths to these browser installations). |
| 226 p = subprocess.Popen('%s --version' % GetPath(runtime), |
| 227 stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) |
| 228 output, stderr = p.communicate() |
| 229 print 'Version of %s: %s' % (runtime, output) |
199 | 230 |
200 if compiler == 'dart2js': | 231 if compiler == 'dart2js': |
201 if option == 'checked': flags = flags + ['--host-checked'] | 232 if option == 'checked': flags = flags + ['--host-checked'] |
202 | 233 |
203 if runtime == 'd8': | 234 if runtime == 'd8': |
204 # The dart2js compiler isn't self-hosted (yet) so we run its | 235 # The dart2js compiler isn't self-hosted (yet) so we run its |
205 # unit tests on the VM. We avoid doing this on the builders | 236 # unit tests on the VM. We avoid doing this on the builders |
206 # that run the browser tests to cut down on the cycle time. | 237 # that run the browser tests to cut down on the cycle time. |
207 TestStep("dart2js_unit", mode, system, 'none', 'vm', ['dart2js'], flags) | 238 TestStep("dart2js_unit", mode, system, 'none', 'vm', ['dart2js'], flags) |
208 | 239 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 _DeleteFirefoxProfiles('/tmp') | 298 _DeleteFirefoxProfiles('/tmp') |
268 _DeleteFirefoxProfiles('/var/tmp') | 299 _DeleteFirefoxProfiles('/var/tmp') |
269 | 300 |
270 def main(): | 301 def main(): |
271 print '@@@BUILD_STEP build sdk@@@' | 302 print '@@@BUILD_STEP build sdk@@@' |
272 | 303 |
273 if len(sys.argv) == 0: | 304 if len(sys.argv) == 0: |
274 print 'Script pathname not known, giving up.' | 305 print 'Script pathname not known, giving up.' |
275 return 1 | 306 return 1 |
276 | 307 |
277 compiler, runtime, mode, system, option, shard_index, total_shards = ( | 308 (compiler, runtime, mode, system, option, shard_index, total_shards, |
278 GetBuildInfo()) | 309 is_buildbot) = GetBuildInfo() |
279 shard_description = "" | 310 shard_description = "" |
280 if shard_index: | 311 if shard_index: |
281 shard_description = " shard %s of %s" % (shard_index, total_shards) | 312 shard_description = " shard %s of %s" % (shard_index, total_shards) |
282 print "compiler: %s, runtime: %s mode: %s, system: %s, option: %s%s" % ( | 313 print "compiler: %s, runtime: %s mode: %s, system: %s, option: %s%s" % ( |
283 compiler, runtime, mode, system, option, shard_description) | 314 compiler, runtime, mode, system, option, shard_description) |
284 if compiler is None: | 315 if compiler is None: |
285 return 1 | 316 return 1 |
286 | 317 |
287 status = BuildSDK(mode, system) | 318 status = BuildSDK(mode, system) |
288 if status != 0: | 319 if status != 0: |
289 print '@@@STEP_FAILURE@@@' | 320 print '@@@STEP_FAILURE@@@' |
290 return status | 321 return status |
291 | 322 |
292 test_flags = [] | 323 test_flags = [] |
293 if shard_index: | 324 if shard_index: |
294 test_flags = ['--shards=%s' % total_shards, '--shard=%s' % shard_index] | 325 test_flags = ['--shards=%s' % total_shards, '--shard=%s' % shard_index] |
295 | 326 |
296 # First we run all the regular tests. | 327 # First we run all the regular tests. |
297 status = TestCompiler(compiler, runtime, mode, system, option, test_flags) | 328 status = TestCompiler(compiler, runtime, mode, system, option, test_flags, |
| 329 is_buildbot) |
298 | 330 |
299 # We only run checked mode tests when the host is not in checked mode. | 331 # We only run checked mode tests when the host is not in checked mode. |
300 if status == 0 and option != 'checked' and runtime == 'd8': | 332 if status == 0 and option != 'checked' and runtime == 'd8': |
301 status = TestCompiler(compiler, runtime, mode, system, option, | 333 status = TestCompiler(compiler, runtime, mode, system, option, |
302 test_flags + ['--checked']) | 334 test_flags + ['--checked'], is_buildbot) |
303 | 335 |
304 if runtime != 'd8': CleanUpTemporaryFiles(system, runtime) | 336 if runtime != 'd8': CleanUpTemporaryFiles(system, runtime) |
305 if status != 0: print '@@@STEP_FAILURE@@@' | 337 if status != 0: print '@@@STEP_FAILURE@@@' |
306 return status | 338 return status |
307 | 339 |
308 if __name__ == '__main__': | 340 if __name__ == '__main__': |
309 sys.exit(main()) | 341 sys.exit(main()) |
OLD | NEW |