OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Runs all the buildbot steps for ChromeDriver except for update/compile.""" | 6 """Runs all the buildbot steps for ChromeDriver except for update/compile.""" |
7 | 7 |
8 import optparse | 8 import optparse |
9 import os | 9 import os |
10 import subprocess | 10 import subprocess |
| 11 import shutil |
11 import sys | 12 import sys |
| 13 import tempfile |
12 import urllib2 | 14 import urllib2 |
13 import zipfile | 15 import zipfile |
14 | 16 |
15 _THIS_DIR = os.path.abspath(os.path.dirname(__file__)) | 17 _THIS_DIR = os.path.abspath(os.path.dirname(__file__)) |
16 sys.path.insert(0, os.path.join(_THIS_DIR, os.pardir, 'pylib')) | 18 sys.path.insert(0, os.path.join(_THIS_DIR, os.pardir, 'pylib')) |
17 | 19 |
18 from common import chrome_paths | 20 from common import chrome_paths |
19 from common import util | 21 from common import util |
20 | 22 |
21 GS_BUCKET = 'gs://chromedriver-prebuilts' | 23 GS_BUCKET = 'gs://chromedriver-prebuilts' |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 '--project', 'chromedriver', | 125 '--project', 'chromedriver', |
124 '--user', 'chromedriver.bot@gmail.com', | 126 '--user', 'chromedriver.bot@gmail.com', |
125 '--label', 'Release', | 127 '--label', 'Release', |
126 zip_path | 128 zip_path |
127 ] | 129 ] |
128 with open(os.devnull, 'wb') as no_output: | 130 with open(os.devnull, 'wb') as no_output: |
129 if subprocess.Popen(cmd, stdout=no_output, stderr=no_output).wait(): | 131 if subprocess.Popen(cmd, stdout=no_output, stderr=no_output).wait(): |
130 print '@@@STEP_FAILURE@@@' | 132 print '@@@STEP_FAILURE@@@' |
131 | 133 |
132 | 134 |
| 135 def KillChromes(): |
| 136 chrome_map = { |
| 137 'win': 'chrome.exe', |
| 138 'mac': 'Chromium', |
| 139 'linux': 'chrome', |
| 140 } |
| 141 if util.IsWindows(): |
| 142 cmd = ['taskkill', '/F', '/IM'] |
| 143 else: |
| 144 cmd = ['pkill', '-9'] |
| 145 cmd.append(chrome_map[util.GetPlatformName()]) |
| 146 util.RunCommand(cmd) |
| 147 |
| 148 |
| 149 def CleanTmpDir(): |
| 150 tmp_dir = tempfile.gettempdir() |
| 151 print 'cleaning temp directory:', tmp_dir |
| 152 for file_name in os.listdir(tmp_dir): |
| 153 if os.path.isdir(os.path.join(tmp_dir, file_name)): |
| 154 print 'deleting sub-directory', file_name |
| 155 shutil.rmtree(os.path.join(tmp_dir, file_name), True) |
| 156 |
| 157 |
133 def main(): | 158 def main(): |
134 parser = optparse.OptionParser() | 159 parser = optparse.OptionParser() |
135 parser.add_option( | 160 parser.add_option( |
136 '', '--android-package', | 161 '', '--android-package', |
137 help='Application package name, if running tests on Android.') | 162 help='Application package name, if running tests on Android.') |
138 parser.add_option( | 163 parser.add_option( |
139 '-r', '--revision', type='string', default=None, | 164 '-r', '--revision', type='string', default=None, |
140 help='Chromium revision') | 165 help='Chromium revision') |
141 options, _ = parser.parse_args() | 166 options, _ = parser.parse_args() |
142 | 167 |
| 168 if not options.android_package: |
| 169 KillChromes() |
| 170 CleanTmpDir() |
| 171 |
143 if options.android_package: | 172 if options.android_package: |
144 Download() | 173 Download() |
145 else: | 174 else: |
146 if options.revision is None: | 175 if options.revision is None: |
147 parser.error('Must supply a --revision') | 176 parser.error('Must supply a --revision') |
148 | 177 |
149 platform = util.GetPlatformName() | 178 platform = util.GetPlatformName() |
150 if 'linux' in platform: | 179 if 'linux' in platform: |
151 Archive(options.revision) | 180 Archive(options.revision) |
152 | 181 |
153 cmd = [ | 182 cmd = [ |
154 sys.executable, | 183 sys.executable, |
155 os.path.join(_THIS_DIR, 'run_all_tests.py'), | 184 os.path.join(_THIS_DIR, 'run_all_tests.py'), |
156 ] | 185 ] |
157 if options.android_package: | 186 if options.android_package: |
158 cmd.append('--android-package=' + options.android_package) | 187 cmd.append('--android-package=' + options.android_package) |
159 | 188 |
160 passed = (util.RunCommand(cmd) == 0) | 189 passed = (util.RunCommand(cmd) == 0) |
161 | 190 |
162 if not options.android_package and passed: | 191 if not options.android_package and passed: |
163 MaybeRelease(options.revision) | 192 MaybeRelease(options.revision) |
164 | 193 |
165 | 194 |
166 if __name__ == '__main__': | 195 if __name__ == '__main__': |
167 main() | 196 main() |
OLD | NEW |