Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
| 3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #!/usr/bin/python | 5 #!/usr/bin/python |
| 6 | 6 |
| 7 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 7 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 8 # Use of this source code is governed by a BSD-style license that can be | 8 # Use of this source code is governed by a BSD-style license that can be |
| 9 # found in the LICENSE file. | 9 # found in the LICENSE file. |
| 10 | 10 |
| 11 """Dart client buildbot steps | 11 """Dart client buildbot steps |
| 12 | 12 |
| 13 Compiles dart client apps with dartc, and run the client tests both in headless | 13 Compiles dart client apps with dartc, and run the client tests both in headless |
| 14 chromium and headless dartium. | 14 chromium and headless dartium. |
| 15 """ | 15 """ |
| 16 | 16 |
| 17 import os | 17 import os |
| 18 import re | 18 import re |
| 19 import socket | 19 import socket |
| 20 import subprocess | 20 import subprocess |
| 21 import sys | 21 import sys |
| 22 import shutil | 22 import shutil |
| 23 import glob | 23 import glob |
| 24 | 24 |
| 25 BUILDER_NAME = 'BUILDBOT_BUILDERNAME' | 25 BUILDER_NAME = 'BUILDBOT_BUILDERNAME' |
| 26 REVISION = 'BUILDBOT_REVISION' | 26 REVISION = 'BUILDBOT_REVISION' |
| 27 | 27 |
| 28 # latest dartium location | 28 # latest dartium location |
| 29 DARTIUM_VERSION_FILE = 'tests/drt/LAST_VERSION' | 29 DARTIUM_VERSION_FILE = 'client/tests/drt/LAST_VERSION' |
| 30 DARTIUM_V_MATCHER = ( | 30 DARTIUM_V_MATCHER = ( |
| 31 'gs://dartium-archive/[^/]*/dartium-\w*-inc-([0-9]*).([0-9]*).zip') | 31 'gs://dartium-archive/[^/]*/dartium-\w*-inc-([0-9]*).([0-9]*).zip') |
| 32 | 32 |
| 33 # Patterns are of the form "dart_client-linux-ia32-debug" | 33 # Patterns are of the form "dart_client-linux-ia32-debug" |
| 34 BUILDER_PATTERN = r'dart_client-(\w+)-(\w+)-(\w+)' | 34 BUILDER_PATTERN = r'dart_client-(\w+)-(\w+)-(\w+)' |
| 35 | 35 |
| 36 | 36 |
| 37 def GetBuildInfo(srcpath): | 37 def GetBuildInfo(): |
| 38 """Returns a tuple (name, version, arch, mode, platform) where: | 38 """Returns a tuple (name, version, arch, mode, platform) where: |
| 39 - name: A name for the build - the buildbot host if a buildbot. | 39 - name: A name for the build - the buildbot host if a buildbot. |
| 40 - version: A version string corresponding to this build. | 40 - version: A version string corresponding to this build. |
| 41 - arch: 'dartium' (default) or 'chromium' | 41 - arch: 'dartium' (default) or 'chromium' |
| 42 - mode: 'debug' or 'release' (default) | 42 - mode: 'debug' or 'release' (default) |
| 43 - platform: 'linux' or 'mac' | 43 - platform: 'linux' or 'mac' |
| 44 """ | 44 """ |
| 45 name = None | 45 name = None |
| 46 version = None | 46 version = None |
| 47 mode = 'release' | 47 mode = 'release' |
| 48 arch = 'dartium' | 48 arch = 'dartium' |
| 49 platform = 'linux' | 49 platform = 'linux' |
| 50 | 50 |
| 51 # Populate via builder environment variables. | 51 # Populate via builder environment variables. |
| 52 name = os.environ.get(BUILDER_NAME) | 52 name = os.environ.get(BUILDER_NAME) |
| 53 version = os.environ.get(REVISION) | 53 version = os.environ.get(REVISION) |
| 54 | 54 |
| 55 if name: | 55 if name: |
| 56 pattern = re.match(BUILDER_PATTERN, name) | 56 pattern = re.match(BUILDER_PATTERN, name) |
| 57 if pattern: | 57 if pattern: |
| 58 platform = pattern.group(1) | 58 platform = pattern.group(1) |
| 59 arch = pattern.group(2) | 59 arch = pattern.group(2) |
| 60 mode = pattern.group(3) | 60 mode = pattern.group(3) |
| 61 | 61 |
| 62 # Fall back if not on builder. | 62 # Fall back if not on builder. |
| 63 if not name: | 63 if not name: |
| 64 name = socket.gethostname().split('.')[0] | 64 name = socket.gethostname().split('.')[0] |
| 65 if not version: | 65 if not version: |
| 66 os.chdir(srcpath) | |
| 67 pipe = subprocess.Popen( | 66 pipe = subprocess.Popen( |
| 68 ['svnversion', '-n'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 67 ['svnversion', '-n'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 69 output = pipe.communicate() | 68 output = pipe.communicate() |
| 70 if pipe.returncode == 0: | 69 if pipe.returncode == 0: |
| 71 version = output[0] | 70 version = output[0] |
| 72 else: | 71 else: |
| 73 version = 'unknown' | 72 version = 'unknown' |
| 74 return (name, version, arch, mode, platform) | 73 return (name, version, arch, mode, platform) |
| 75 | 74 |
| 76 | 75 |
| 77 def RunDartcCompiler(client_path, mode, outdir): | 76 def RunDartcCompiler(mode, outdir): |
| 78 """Compiles the client code to javascript for dartc tests.""" | 77 """Compiles the client code to javascript for dartc tests.""" |
| 79 # Move to the client directory and call the build script | |
| 80 os.chdir(client_path) | |
| 81 return subprocess.call( | 78 return subprocess.call( |
| 82 [sys.executable, '../tools/build.py', '--mode=' + mode]) | 79 [sys.executable, './tools/build.py', '--mode=' + mode]) |
| 83 | 80 |
| 84 def RunBrowserTests(client_path, arch, mode, platform): | 81 def RunBrowserTests(arch, mode, platform): |
| 85 """Runs the Dart client tests.""" | 82 """Runs the Dart client tests.""" |
| 86 if platform == 'linux': | 83 if platform == 'linux': |
| 87 cmd = ['xvfb-run'] | 84 cmd = ['xvfb-run'] |
| 88 else: | 85 else: |
| 89 cmd = [] | 86 cmd = [] |
| 90 # Move to the client directory and call the test script | 87 cmd += [sys.executable, './tools/test.py', |
| 91 os.chdir(client_path) | |
| 92 cmd += [sys.executable, '../tools/test.py', | |
| 93 '--arch=' + arch, '--mode=' + mode, | 88 '--arch=' + arch, '--mode=' + mode, |
| 94 '--time', '--report', '--progress=buildbot', '-v'] | 89 '--time', '--report', '--progress=buildbot', '-v'] |
| 95 return subprocess.call(cmd) | 90 return subprocess.call(cmd) |
| 96 | 91 |
| 97 def GetUtils(srcpath): | 92 def GetUtils(): |
| 98 ''' | 93 ''' |
| 99 dynamically get the utils module | 94 dynamically get the utils module |
| 100 We use a dynamic import for tools/util.py because we derive its location | 95 We use a dynamic import for tools/util.py because we derive its location |
| 101 dynamically using sys.argv[0]. This allows us to run this script from | 96 dynamically using sys.argv[0]. This allows us to run this script from |
| 102 different directories. | 97 different directories. |
| 103 | |
| 104 args: | |
| 105 srcpath - the location of the source code to build | |
| 106 ''' | 98 ''' |
| 107 sys.path.append(os.path.abspath(os.path.join(srcpath, '..', 'tools'))) | 99 sys.path.append(os.path.abspath(os.path.join('.', 'tools'))) |
| 108 utils = __import__('utils') | 100 utils = __import__('utils') |
| 109 return utils | 101 return utils |
| 110 | 102 |
| 111 def GetOutDir(utils, mode, name): | 103 def GetOutDir(utils, mode): |
| 112 ''' | 104 ''' |
| 113 get the location to place the output | 105 get the location to place the output |
| 114 | 106 |
| 115 args: | 107 args: |
| 116 utils - the tools/utils.py module | 108 utils - the tools/utils.py module |
| 117 mode - the mode release or debug | 109 mode - the mode release or debug |
| 118 name - the name of the builder | |
| 119 ''' | 110 ''' |
| 120 return utils.GetBuildRoot(utils.GuessOS(), mode, name) | 111 return utils.GetBuildRoot(utils.GuessOS(), mode, utils.ARCH_GUESS) |
| 121 | 112 |
| 122 def ProcessDartClientTests(srcpath, arch, mode, platform, name): | 113 def ProcessDartClientTests(arch, mode, platform, name): |
| 123 ''' | 114 ''' |
| 124 build and test the dart client applications | 115 build and test the dart client applications |
| 125 | 116 |
| 126 args: | 117 args: |
| 127 srcpath - the location of the source code to build | |
| 128 arch - the architecture we are building for | 118 arch - the architecture we are building for |
| 129 mode - the mode release or debug | 119 mode - the mode release or debug |
| 130 platform - the platform we are building for | 120 platform - the platform we are building for |
| 131 ''' | 121 ''' |
| 132 print 'ProcessDartClientTests' | 122 print 'ProcessDartClientTests' |
| 133 if arch == 'chromium': | 123 if arch == 'chromium': |
| 134 print ('@@@BUILD_STEP dartc dart clients: %s@@@' % name) | 124 print ('@@@BUILD_STEP dartc dart clients: %s@@@' % name) |
| 135 | 125 |
| 136 utils = GetUtils(srcpath) | 126 utils = GetUtils() |
| 137 outdir = GetOutDir(utils, mode, "dartc") | 127 outdir = GetOutDir(utils, mode) |
| 138 status = RunDartcCompiler(srcpath, mode, outdir) | 128 status = RunDartcCompiler(mode, outdir) |
| 139 if status != 0: | 129 if status != 0: |
| 140 return status | 130 return status |
| 141 | 131 |
| 142 if arch == 'dartium': | 132 if arch == 'dartium': |
| 143 version_file = os.path.join(srcpath, DARTIUM_VERSION_FILE) | 133 version_file = os.path.join('.', DARTIUM_VERSION_FILE) |
|
Siggi Cherem (dart-lang)
2011/11/01 23:09:43
is this needed anymore? i.e can we simply inline D
ngeoffray
2011/11/02 13:51:34
Done.
| |
| 144 if os.path.exists(version_file): | 134 if os.path.exists(version_file): |
| 145 latest = open(version_file, 'r').read() | 135 latest = open(version_file, 'r').read() |
| 146 match = re.match(DARTIUM_V_MATCHER, latest) | 136 match = re.match(DARTIUM_V_MATCHER, latest) |
| 147 if match: | 137 if match: |
| 148 print '@@@BUILD_STEP vm r%s (dartium r%s)@@@' % ( | 138 print '@@@BUILD_STEP vm r%s (dartium r%s)@@@' % ( |
| 149 match.group(2), match.group(1)) | 139 match.group(2), match.group(1)) |
| 150 print '@@@BUILD_STEP browser unit tests@@@' | 140 print '@@@BUILD_STEP browser unit tests@@@' |
| 151 return RunBrowserTests(srcpath, arch, mode, platform) | 141 return RunBrowserTests(arch, mode, platform) |
| 152 | 142 |
| 153 def ProcessTools(srcpath, mode, name, version): | 143 def ProcessTools(mode, name, version): |
| 154 ''' | 144 ''' |
| 155 build and test the tools | 145 build and test the tools |
| 156 | 146 |
| 157 args: | 147 args: |
| 158 srcpath - the location of the source code to build | |
| 159 mode - the mode release or debug | 148 mode - the mode release or debug |
| 160 version - the svn version of the currently checked out code | 149 version - the svn version of the currently checked out code |
| 161 ''' | 150 ''' |
| 162 print 'ProcessTools' | 151 print 'ProcessTools' |
| 163 | 152 |
| 164 toolsBuildScript = os.path.join(srcpath, '..', 'editor', 'build', 'build.py') | 153 toolsBuildScript = os.path.join('editor', 'build', 'build.py') |
| 165 | 154 |
| 166 #TODO: debug statements to be removed in the future. | 155 #TODO: debug statements to be removed in the future. |
| 167 print "srcpath = " + srcpath | |
| 168 print "mode = " + mode | 156 print "mode = " + mode |
| 169 print "name = " + name | 157 print "name = " + name |
| 170 print "version = " + version | 158 print "version = " + version |
| 171 print "toolsBuildScript = " + os.path.abspath(toolsBuildScript) | 159 print "toolsBuildScript = " + os.path.abspath(toolsBuildScript) |
| 172 | 160 |
| 173 utils = GetUtils(srcpath) | 161 utils = GetUtils() |
| 174 outdir = GetOutDir(utils, mode, "tools") | 162 outdir = GetOutDir(utils, mode) |
| 175 cmds = [sys.executable, toolsBuildScript, | 163 cmds = [sys.executable, toolsBuildScript, |
| 176 '--mode=' + mode, '--revision=' + version, | 164 '--mode=' + mode, '--revision=' + version, |
| 177 '--name=' + name, '--out=' + outdir] | 165 '--name=' + name, '--out=' + outdir] |
| 178 return subprocess.call(cmds) | 166 return subprocess.call(cmds) |
| 179 | 167 |
| 180 def ProcessFrog(srcpath): | 168 def ProcessFrog(): |
| 181 ''' | 169 ''' |
| 182 build and test experimental frog build | 170 build and test experimental frog build |
| 183 | |
| 184 args: | |
| 185 srcpath - the location of the source code to build | |
| 186 ''' | 171 ''' |
| 187 print 'ProcessFrog' | 172 print 'ProcessFrog' |
| 188 | 173 |
| 189 return subprocess.call([sys.executable, | 174 return subprocess.call([sys.executable, |
| 190 os.path.join(srcpath, '..', 'frog', | 175 os.path.join('.', 'frog', |
|
Siggi Cherem (dart-lang)
2011/11/01 23:09:43
remove first arg? possibly merge this line and the
ngeoffray
2011/11/02 13:51:34
Done.
| |
| 191 'scripts', 'buildbot_annotated_steps.py')]) | 176 'scripts', 'buildbot_annotated_steps.py')]) |
| 192 | 177 |
| 193 def main(): | 178 def main(): |
| 194 print 'main' | 179 print 'main' |
| 195 if len(sys.argv) == 0: | 180 if len(sys.argv) == 0: |
| 196 print 'Script pathname not known, giving up.' | 181 print 'Script pathname not known, giving up.' |
| 197 return 1 | 182 return 1 |
| 198 | 183 |
| 199 scriptdir = os.path.dirname(sys.argv[0]) | 184 scriptdir = os.path.dirname(sys.argv[0]) |
| 200 srcpath = os.path.abspath(os.path.join(scriptdir, '..')) | 185 # Get at the top-level directory. This script is in client/tools. |
| 186 os.chdir(os.path.abspath(os.path.join(scriptdir, '../..'))) | |
| 201 | 187 |
| 202 (name, version, arch, mode, platform) = GetBuildInfo(srcpath) | 188 (name, version, arch, mode, platform) = GetBuildInfo() |
| 203 if name == 'dart-editor': | 189 if name == 'dart-editor': |
| 204 status = ProcessTools(srcpath, mode, name, version) | 190 status = ProcessTools(mode, name, version) |
| 205 #TODO(sigmund): remove this indirection once we update out bots | 191 #TODO(sigmund): remove this indirection once we update our bots |
| 206 elif name.startswith('frog'): | 192 elif name.startswith('frog'): |
| 207 status = ProcessFrog(srcpath) | 193 status = ProcessFrog() |
| 208 else: | 194 else: |
| 209 status = ProcessDartClientTests(srcpath, arch, mode, platform, name) | 195 status = ProcessDartClientTests(arch, mode, platform, name) |
| 210 | 196 |
| 211 if status: | 197 if status: |
| 212 print '@@@STEP_FAILURE@@@' | 198 print '@@@STEP_FAILURE@@@' |
| 213 | 199 |
| 214 return status | 200 return status |
| 215 | 201 |
| 216 | 202 |
| 217 if __name__ == '__main__': | 203 if __name__ == '__main__': |
| 218 sys.exit(main()) | 204 sys.exit(main()) |
| OLD | NEW |