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

Unified Diff: client/tools/pub_buildbot.py

Issue 11236012: Add script for pub buildbots. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/tools/buildbot_annotated_steps.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/tools/pub_buildbot.py
diff --git a/client/tools/pub_buildbot.py b/client/tools/pub_buildbot.py
new file mode 100644
index 0000000000000000000000000000000000000000..2b6a0aec5cafeac2a68c0b1e625cd5193ce03652
--- /dev/null
+++ b/client/tools/pub_buildbot.py
@@ -0,0 +1,154 @@
+#!/usr/bin/python
+
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Pub buildbot steps
+
+Runs tests for pub and the pub packages that are hosted in the main Dart repo.
+This file is heartily inspired by utils/compiler/buildbot.py.
+"""
+
+import optparse
+import os
+from os.path import abspath
+from os.path import dirname
+import re
+import subprocess
+import sys
+
+BUILDER_NAME = 'BUILDBOT_BUILDERNAME'
+BUILDER_CLOBBER = 'BUILDBOT_CLOBBER'
+
+DART_PATH = dirname(dirname(dirname(abspath(__file__))))
+
+PUB_BUILDER = r'pub-(linux|mac|win)'
+
+NO_COLOR_ENV = dict(os.environ)
+NO_COLOR_ENV['TERM'] = 'nocolor'
+
+
+def GetBuildInfo():
+ """Returns info for the current buildbot based on the name of the builder.
+
+ Currently, this is just:
+ - mode: always "release"
+ - system: "linux", "mac", or "win"
+ """
+
+ # For testing the bot locally, allow the user to pass in a buildbot name.
Emily Fortuna 2012/10/19 21:35:53 :-D
+ parser = optparse.OptionParser()
+ parser.add_option('-n', '--name', dest='name', help='The name of the build'
+ 'bot you would like to emulate (ex: web-chrome-win7)', default=None)
Emily Fortuna 2012/10/19 21:35:53 nit: change the name to a pub-like bot name instea
Bob Nystrom 2012/10/20 01:06:38 Done.
+ args, _ = parser.parse_args()
+
+ if args.name:
+ builder_name = args.name
+ else:
+ builder_name = os.environ.get(BUILDER_NAME)
+ if not builder_name:
+ print 'Use -n $BUILDBOT_NAME for the bot you would like to emulate.'
+ sys.exit(1)
+
+ pub_pattern = re.match(PUB_BUILDER, builder_name)
+ if not pub_pattern:
+ print 'Could not handle unfamiliar bot name "$builder_name".'
+ sys.exit(1)
+
+ system = pub_pattern.group(1)
+ if system == 'win': system = 'windows'
+
+ return ('release', system)
+
+
+def TestStepName(name, flags):
+ # Filter out flags with '=' as this breaks the /stats feature of the
+ # build bot.
+ flags = [x for x in flags if not '=' in x]
+ return ('%s tests %s' % (name, ' '.join(flags))).strip()
+
+
+def TestStep(name, mode, system, compiler, runtime, targets, flags):
+ step_name = TestStepName(name, flags)
+ print '@@@BUILD_STEP %s@@@' % step_name
+ sys.stdout.flush()
+
+ cmd = [
+ sys.executable, os.path.join(os.curdir, 'tools', 'test.py'),
+ '--step_name=' + step_name,
+ '--mode=' + mode,
+ '--compiler=' + compiler,
+ '--runtime=' + runtime,
+ '--progress=buildbot',
+ '-v', '--time', '--use-sdk', '--checked', '--report'
+ ]
+
+ if flags:
+ cmd.extend(flags)
+ cmd.extend(targets)
+
+ print 'Running: %s' % (' '.join(cmd))
+ exit_code = subprocess.call(cmd, env=NO_COLOR_ENV)
+ return CheckFailure(exit_code)
+
+
+def BuildSDK(mode, system):
Emily Fortuna 2012/10/19 21:35:53 A lot of this is pretty much exactly copied code f
Bob Nystrom 2012/10/20 01:06:38 I don't want to add pub stuff to the original scri
+ """ build the SDK.
+ Args:
+ - mode: either 'debug' or 'release'
+ - system: either 'linux', 'mac', or 'win7'
+ """
+ print '@@@BUILD_STEP build sdk@@@'
+ args = [sys.executable, './tools/build.py', '--mode=' + mode, 'create_sdk']
+ print 'Building SDK: %s' % (' '.join(args))
+ return subprocess.call(args, env=NO_COLOR_ENV)
+
+
+def ClobberBuilder(mode):
+ """ Clobber the builder before we do the build, if appropriate.
+ Args:
+ - mode: either 'debug' or 'release'
+ """
+ if os.environ.get(BUILDER_CLOBBER) != "1":
+ return 0
+
+ print '@@@BUILD_STEP Clobber@@@'
+ cmd = [sys.executable,
+ './tools/clean_output_directory.py',
+ '--mode=' + mode]
+ print 'Clobbering %s' % (' '.join(cmd))
+ return subprocess.call(cmd, env=NO_COLOR_ENV)
+
+
+def CheckFailure(status):
+ """ Prints the appropriate buildbot message if status is a failure code.
+ """
+ if status != 0:
+ print '@@@STEP_FAILURE@@@'
+
+ return status
+
+
+def main():
+ if len(sys.argv) == 0:
+ print 'Script pathname not known, giving up.'
+ return 1
+
+ (mode, system) = GetBuildInfo()
+
+ # Make sure we are in the dart directory
+ os.chdir(DART_PATH)
+
+ status = ClobberBuilder(mode)
+ if CheckFailure(status): return status
+
+ status = BuildSDK(mode, system)
+ if CheckFailure(status): return status
+
+ # TODO(rnystrom): Eventually test other targets here like 'utils'?
+ status = TestStep('pub', mode, system, 'none', 'vm', ['pub'], [])
+ if CheckFailure(status): return status
+
+if __name__ == '__main__':
+ sys.exit(main())
« no previous file with comments | « client/tools/buildbot_annotated_steps.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698