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

Side by Side Diff: visual_studio/NativeClientVSAddIn/buildbot_run.py

Issue 11088016: Run tests on buildbot. (Closed) Base URL: http://nativeclient-sdk.googlecode.com/svn/trunk/src
Patch Set: fixes based on review 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file 3 # found in the LICENSE file
4 4
5 """Entry point for the AddIn build bot. 5 """Entry point for the AddIn build bot.
6 6
7 Perform build steps and output results using the buildbot 7 Perform build steps and output results using the buildbot
8 annootator syntax 8 annootator syntax
9 """ 9 """
10 10
11 import os 11 import os
12 import sys 12 import sys
13 import subprocess 13 import subprocess
14 import urllib2
15 import zipfile
16 from os.path import join
14 17
15 GSURL = 'https://commondatastorage.googleapis.com' 18 GSURL = 'https://commondatastorage.googleapis.com'
16 GSPATH = 'nativeclient-mirror/nacl/nacl_sdk/sdk' 19 GSPATH = 'nativeclient-mirror/nacl/nacl_sdk/sdk'
20 SDKROOT = join('..', '..', 'out', 'sdk')
21
17 22
18 def Log(msg): 23 def Log(msg):
19 sys.stdout.write(msg + '\n') 24 sys.stdout.write(msg + '\n')
20 sys.stdout.flush() 25 sys.stdout.flush()
21 26
22 27
23 def RunCommand(cmd): 28 def RunCommand(cmd, env=None):
24 Log("Running: %s" % cmd) 29 Log("Running: %s" % cmd)
25 Log("CWD: %s" % os.getcwd()) 30 Log("CWD: %s" % os.getcwd())
26 rtn = subprocess.call(cmd, shell=True) 31 if type(cmd) == str:
32 cmd = cmd.split()
33
34 if sys.platform == 'cygwin':
35 # allow bat files in the current working directory to
36 # be executed on cygwin as they are on win32
37 if not os.path.dirname(cmd[0]) and os.path.exists(cmd[0]):
38 cmd = './' + cmd
39
40 rtn = subprocess.call(cmd, shell=True, env=env)
27 if rtn: 41 if rtn:
28 Log('@@@STEP_FAILURE@@@') 42 Log('@@@STEP_FAILURE@@@')
29 sys.exit(1) 43 sys.exit(1)
30 44
31 45
32 def StepBuild(): 46 def StepBuild():
33 Log('@@@BUILD_STEP build AddIn@@@') 47 Log('@@@BUILD_STEP build AddIn@@@')
34 if sys.platform == 'cygwin': 48 RunCommand('build.bat')
35 RunCommand(['./build.bat']) 49
36 else: 50
37 RunCommand(['build.bat']) 51 def StepInstall():
52 Log('@@@BUILD_STEP Install AddIn@@@')
53 RunCommand('developer_deploy.bat')
54
55
56 def StepInstallSDK():
57 Log('@@@BUILD_STEP Install SDK@@@')
58 naclsdk = join(SDKROOT, 'nacl_sdk', 'naclsdk.bat')
59 if not os.path.exists(naclsdk):
60 if not os.path.exists(SDKROOT):
61 os.makedirs(SDKROOT)
62 filename = join(SDKROOT, 'nacl_sdk.zip')
63 url = GSURL + "/nativeclient-mirror/nacl/nacl_sdk/nacl_sdk.zip"
64 contents = urllib2.urlopen(url).read()
65 with open(filename, 'wb') as zfileout:
66 zfileout.write(contents)
67 zfile = zipfile.ZipFile(filename)
68 zfile.extractall(SDKROOT)
69
70 RunCommand([naclsdk, 'update', '--force', 'pepper_23'])
71 RunCommand([naclsdk, 'update', '--force', 'pepper_canary'])
38 72
39 73
40 def StepTest(): 74 def StepTest():
41 Log('@@@BUILD_STEP Testing AddIn@@@') 75 Log('@@@BUILD_STEP Testing AddIn@@@')
42 # Don't actually test yet 76 # Don't actually test yet
43 #RunCommand(['test.bat']) 77 env = dict(os.environ)
78 sdkroot = os.path.abspath(join(SDKROOT, 'nacl_sdk'))
79 env['NACL_SDK_ROOT'] = join(sdkroot, 'pepper_23')
80 RunCommand('test.bat', env)
81 env['NACL_SDK_ROOT'] = join(sdkroot, 'pepper_canary')
82 RunCommand('test.bat', env)
44 83
45 84
46 def _FindInPath(filename): 85 def _FindInPath(filename):
47 for path in os.environ['PATH'].split(os.pathsep): 86 for path in os.environ['PATH'].split(os.pathsep):
48 result = os.path.join(path, filename) 87 result = join(path, filename)
49 if os.path.exists(result): 88 if os.path.exists(result):
50 return result 89 return result
51 90
52 Log('%s not found in PATH' % filename) 91 Log('%s not found in PATH' % filename)
53 Log('@@@STEP_FAILURE@@@') 92 Log('@@@STEP_FAILURE@@@')
54 sys.exit(1) 93 sys.exit(1)
55 94
56 95
57 def _GetGsutil(): 96 def _GetGsutil():
58 if os.environ.get('BUILDBOT_BUILDERNAME'): 97 if os.environ.get('BUILDBOT_BUILDERNAME'):
59 # When running in a buildbot slave use 98 # When running in a buildbot slave use
60 # gsutil from the slave scripts folder 99 # gsutil from the slave scripts folder
61 import slave 100 import slave
62 slave_dir = os.path.dirname(slave.__file__) 101 slave_dir = os.path.dirname(slave.__file__)
63 gsutil = os.path.join(slave_dir, 'gsutil') 102 gsutil = join(slave_dir, 'gsutil')
64 if os.name == 'nt': 103 if os.name == 'nt':
65 gsutil += '.bat' 104 gsutil += '.bat'
66 gsutil = [gsutil] 105 gsutil = [gsutil]
67 else: 106 else:
68 if os.name == 'nt': 107 if os.name == 'nt':
69 gsutil = [sys.executable, _FindInPath('gsutil')] 108 gsutil = [sys.executable, _FindInPath('gsutil')]
70 else: 109 else:
71 gsutil = ['gsutil'] 110 gsutil = ['gsutil']
72 111
73 return gsutil 112 return gsutil
74 113
75 114
76 def StepArchive(): 115 def StepArchive():
77 rev = os.environ.get('BUILDBOT_GOT_REVISION') 116 rev = os.environ.get('BUILDBOT_GOT_REVISION')
78 if not rev: 117 if not rev:
79 Log('No BUILDBOT_GOT_REVISION found in environ') 118 Log('No BUILDBOT_GOT_REVISION found in environ')
80 Log('@@@STEP_FAILURE@@@') 119 Log('@@@STEP_FAILURE@@@')
81 sys.exit(1) 120 sys.exit(1)
82 Log('@@@BUILD_STEP Archiving %s@@@' % rev) 121 Log('@@@BUILD_STEP Archiving %s@@@' % rev)
83 basename = 'vs_addin.tgz' 122 basename = 'vs_addin.tgz'
84 remote_name = '%s/%s/%s' % (GSPATH, rev, basename) 123 remote_name = '%s/%s/%s' % (GSPATH, rev, basename)
85 local_filename = os.path.join('..', '..', 'out', 124 local_filename = join('..', '..', 'out',
86 'vs_addin', basename) 125 'vs_addin', basename)
87 cmd = _GetGsutil() 126 cmd = _GetGsutil()
88 cmd += ['cp', '-a', 'public-read', local_filename, 127 cmd += ['cp', '-a', 'public-read', local_filename,
89 'gs://' + remote_name] 128 'gs://' + remote_name]
90 RunCommand(cmd) 129 RunCommand(cmd)
91 url = "%s/%s" % (GSURL, remote_name) 130 url = "%s/%s" % (GSURL, remote_name)
92 Log('@@@STEP_LINK@download@%s@@@' % url) 131 Log('@@@STEP_LINK@download@%s@@@' % url)
93 132
94 133
95 def main(): 134 def main():
96 StepBuild() 135 StepBuild()
136 StepInstall()
137 StepInstallSDK()
97 StepTest() 138 StepTest()
98 StepArchive() 139 StepArchive()
99 140
100 141
101 if __name__ == '__main__': 142 if __name__ == '__main__':
102 main() 143 main()
OLDNEW
« no previous file with comments | « visual_studio/NativeClientVSAddIn/build.bat ('k') | visual_studio/NativeClientVSAddIn/developer_deploy.bat » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698