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

Side by Side Diff: tools/get_drt.py

Issue 10014004: Preliminary selenium support for Dartium (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added more comments Created 8 years, 8 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
« no previous file with comments | « no previous file | tools/testing/run_selenium.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a 4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file. 5 # BSD-style license that can be found in the LICENSE file.
6 6
7 # Gets or updates a DumpRenderTree (a nearly headless build of chrome). This is 7 # Gets or updates a DumpRenderTree (a nearly headless build of chrome). This is
8 # used for running browser tests of client applications. 8 # used for running browser tests of client applications.
9 9
10 import optparse
10 import os 11 import os
11 import sys
12 import platform 12 import platform
13 import errno
14 import tempfile
15 import shutil 13 import shutil
16 import subprocess 14 import subprocess
15 import sys
16 import tempfile
17 17
18 def NormJoin(path1, path2): 18 def NormJoin(path1, path2):
19 return os.path.normpath(os.path.join(path1, path2)) 19 return os.path.normpath(os.path.join(path1, path2))
20 20
21 # Change into the dart directory as we want the project to be rooted here. 21 # Change into the dart directory as we want the project to be rooted here.
22 dart_src = NormJoin(os.path.dirname(sys.argv[0]), os.pardir) 22 dart_src = NormJoin(os.path.dirname(sys.argv[0]), os.pardir)
23 os.chdir(dart_src) 23 os.chdir(dart_src)
24 24
25 GSUTIL_DIR = 'third_party/gsutil/20110627' 25 GSUTIL_DIR = 'third_party/gsutil/20110627'
26 GSUTIL = GSUTIL_DIR + '/gsutil' 26 GSUTIL = GSUTIL_DIR + '/gsutil'
27
27 DRT_DIR = 'client/tests/drt' 28 DRT_DIR = 'client/tests/drt'
28 VERSION = DRT_DIR + '/LAST_VERSION' 29 DRT_VERSION = DRT_DIR + '/LAST_VERSION'
29 DRT_DARTIUM_LATEST_PATTERN = ( 30 DRT_LATEST_PATTERN = (
30 'gs://dartium-archive/latest/drt-%(osname)s-inc-*.zip') 31 'gs://dartium-archive/latest/drt-%(osname)s-inc-*.zip')
31 DRT_DARTIUM_PERMANENT_PREFIX = 'gs://dartium-archive/drt-%(osname)s-inc' 32 DRT_PERMANENT_PREFIX = 'gs://dartium-archive/drt-%(osname)s-inc'
33
34 DARTIUM_DIR = 'client/tests/dartium'
35 DARTIUM_VERSION = DARTIUM_DIR + '/LAST_VERSION'
36 DARTIUM_LATEST_PATTERN = (
37 'gs://dartium-archive/latest/dartium-%(osname)s-inc-*.zip')
38 DARTIUM_PERMANENT_PREFIX = 'gs://dartium-archive/dartium-%(osname)s-inc'
32 39
33 sys.path.append(GSUTIL_DIR + '/boto') 40 sys.path.append(GSUTIL_DIR + '/boto')
34 import boto 41 import boto
35 42
36 43
37 def execute_command(*cmd): 44 def execute_command(*cmd):
38 """Execute a command in a subprocess.""" 45 """Execute a command in a subprocess."""
39 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 46 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
40 output, error = pipe.communicate() 47 output, error = pipe.communicate()
41 return pipe.returncode, output 48 return pipe.returncode, output
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 * You need to do a one-time configuration step to access Google Storage. 91 * You need to do a one-time configuration step to access Google Storage.
85 * Please run this command and follow the instructions: 92 * Please run this command and follow the instructions:
86 * %s config 93 * %s config
87 * 94 *
88 * NOTE: When prompted you can leave "project-id" blank. Just hit enter. 95 * NOTE: When prompted you can leave "project-id" blank. Just hit enter.
89 ******************************************************************************* 96 *******************************************************************************
90 ''' % GSUTIL 97 ''' % GSUTIL
91 sys.exit(1) 98 sys.exit(1)
92 99
93 100
94 def main(): 101 def get_latest(directory, version_file, latest_pattern, permanent_prefix):
102 """Get the latest DumpRenderTree or Dartium binary depending on arguments.
103
104 Args:
105 directory: target directory (recreated) to install binary
106 version_file: name of file with the current version stamp
107 latest_pattern: the google store url pattern pointing to the latest binary
108 permanent_prefix: stable google store folder used to download versions
109 """
95 system = platform.system() 110 system = platform.system()
96 if system == 'Darwin': 111 if system == 'Darwin':
97 osname = 'mac' 112 osname = 'mac'
98 elif system == 'Linux': 113 elif system == 'Linux':
99 osname = 'lucid64' 114 osname = 'lucid64'
100 else: 115 else:
101 print >>sys.stderr, ('WARNING: platform "%s" does not support' 116 print >>sys.stderr, ('WARNING: platform "%s" does not support'
102 'DumpRenderTree for tests') % system 117 'DumpRenderTree for tests') % system
103 return 0 118 return 0
104 119
105 ensure_config() 120 ensure_config()
106 121
107 # Query for the lastest version 122 # Query for the lastest version
108 pattern = DRT_DARTIUM_LATEST_PATTERN % { 'osname' : osname } 123 pattern = latest_pattern % { 'osname' : osname }
109 result, out = gsutil('ls', pattern) 124 result, out = gsutil('ls', pattern)
110 if result == 0: 125 if result == 0:
111 latest = out.split()[-1] 126 latest = out.split()[-1]
112 # use permanent link instead, just in case the latest zip entry gets deleted 127 # use permanent link instead, just in case the latest zip entry gets deleted
113 # while we are downloading it. 128 # while we are downloading it.
114 latest = (DRT_DARTIUM_PERMANENT_PREFIX % { 'osname' : osname } 129 latest = (permanent_prefix % { 'osname' : osname }
115 + latest[latest.rindex('/'):]) 130 + latest[latest.rindex('/'):])
116 else: # e.g. no access 131 else: # e.g. no access
117 print "Couldn't download DumpRenderTree: %s\n%s" % (pattern, out) 132 print "Couldn't download DumpRenderTree: %s\n%s" % (pattern, out)
118 if not os.path.exists(VERSION): 133 if not os.path.exists(version_file):
119 print "Tests using DumpRenderTree will not work. Please try again later." 134 print "Tests using DumpRenderTree will not work. Please try again later."
120 return 0 135 return 0
121 136
122 # Check if we need to update the file 137 # Check if we need to update the file
123 if os.path.exists(VERSION): 138 if os.path.exists(version_file):
124 v = open(VERSION, 'r').read() 139 v = open(version_file, 'r').read()
125 if v == latest: 140 if v == latest:
126 if not in_runhooks(): 141 if not in_runhooks():
127 print 'DumpRenderTree is up to date.\nVersion: ' + latest 142 print 'DumpRenderTree is up to date.\nVersion: ' + latest
128 return 0 # up to date 143 return 0 # up to date
129 144
130 if os.path.exists(DRT_DIR): 145 if os.path.exists(directory):
131 print 'Removing old DumpRenderTree tree %s' % DRT_DIR 146 print 'Removing old DumpRenderTree tree %s' % directory
132 shutil.rmtree(DRT_DIR) 147 shutil.rmtree(directory)
133 148
134 # download the zip file to a temporary path, and unzip to the target location 149 # download the zip file to a temporary path, and unzip to the target location
135 temp_dir = tempfile.mkdtemp() 150 temp_dir = tempfile.mkdtemp()
136 try: 151 try:
137 temp_zip = temp_dir + '/drt.zip' 152 temp_zip = temp_dir + '/drt.zip'
138 # It's nice to show download progress 153 # It's nice to show download progress
139 gsutil_visible('cp', latest, temp_zip) 154 gsutil_visible('cp', latest, temp_zip)
140 155
141 result, out = execute_command('unzip', temp_zip, '-d', temp_dir) 156 result, out = execute_command('unzip', temp_zip, '-d', temp_dir)
142 if result != 0: 157 if result != 0:
143 raise Exception('Execution of "unzip %s -d %s" failed: %s' % 158 raise Exception('Execution of "unzip %s -d %s" failed: %s' %
144 (temp_zip, temp_dir, str(out))) 159 (temp_zip, temp_dir, str(out)))
145 unzipped_dir = temp_dir + '/' + os.path.basename(latest)[:-4] # remove .zip 160 unzipped_dir = temp_dir + '/' + os.path.basename(latest)[:-4] # remove .zip
146 shutil.move(unzipped_dir, DRT_DIR) 161 shutil.move(unzipped_dir, directory)
147 finally: 162 finally:
148 shutil.rmtree(temp_dir) 163 shutil.rmtree(temp_dir)
149 164
150 # create the version stamp 165 # create the version stamp
151 v = open(VERSION, 'w') 166 v = open(version_file, 'w')
152 v.write(latest) 167 v.write(latest)
153 v.close() 168 v.close()
154 169
155 print 'Successfully downloaded to %s' % DRT_DIR 170 print 'Successfully downloaded to %s' % directory
156 return 0 171 return 0
157 172
173
174 def main():
175 parser = optparse.OptionParser()
176 parser.add_option('--dartium', dest='dartium',
177 help='Get latest Dartium', action='store_true',
178 default=False)
179 args, _ = parser.parse_args()
180
181 if args.dartium:
182 get_latest(DARTIUM_DIR, DARTIUM_VERSION,
183 DARTIUM_LATEST_PATTERN, DARTIUM_PERMANENT_PREFIX)
184 else:
185 get_latest(DRT_DIR, DRT_VERSION, DRT_LATEST_PATTERN, DRT_PERMANENT_PREFIX)
186
158 if __name__ == '__main__': 187 if __name__ == '__main__':
159 sys.exit(main()) 188 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | tools/testing/run_selenium.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698