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

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: 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):
Emily Fortuna 2012/04/09 19:39:29 brief comments explaining what these parameters ar
95 system = platform.system() 102 system = platform.system()
96 if system == 'Darwin': 103 if system == 'Darwin':
97 osname = 'mac' 104 osname = 'mac'
98 elif system == 'Linux': 105 elif system == 'Linux':
99 osname = 'lucid64' 106 osname = 'lucid64'
100 else: 107 else:
101 print >>sys.stderr, ('WARNING: platform "%s" does not support' 108 print >>sys.stderr, ('WARNING: platform "%s" does not support'
102 'DumpRenderTree for tests') % system 109 'DumpRenderTree for tests') % system
103 return 0 110 return 0
104 111
105 ensure_config() 112 ensure_config()
106 113
107 # Query for the lastest version 114 # Query for the lastest version
108 pattern = DRT_DARTIUM_LATEST_PATTERN % { 'osname' : osname } 115 pattern = latest_pattern % { 'osname' : osname }
109 result, out = gsutil('ls', pattern) 116 result, out = gsutil('ls', pattern)
110 if result == 0: 117 if result == 0:
111 latest = out.split()[-1] 118 latest = out.split()[-1]
112 # use permanent link instead, just in case the latest zip entry gets deleted 119 # use permanent link instead, just in case the latest zip entry gets deleted
113 # while we are downloading it. 120 # while we are downloading it.
114 latest = (DRT_DARTIUM_PERMANENT_PREFIX % { 'osname' : osname } 121 latest = (permanent_prefix % { 'osname' : osname }
115 + latest[latest.rindex('/'):]) 122 + latest[latest.rindex('/'):])
116 else: # e.g. no access 123 else: # e.g. no access
117 print "Couldn't download DumpRenderTree: %s\n%s" % (pattern, out) 124 print "Couldn't download DumpRenderTree: %s\n%s" % (pattern, out)
118 if not os.path.exists(VERSION): 125 if not os.path.exists(version_file):
119 print "Tests using DumpRenderTree will not work. Please try again later." 126 print "Tests using DumpRenderTree will not work. Please try again later."
120 return 0 127 return 0
121 128
122 # Check if we need to update the file 129 # Check if we need to update the file
123 if os.path.exists(VERSION): 130 if os.path.exists(version_file):
124 v = open(VERSION, 'r').read() 131 v = open(version_file, 'r').read()
125 if v == latest: 132 if v == latest:
126 if not in_runhooks(): 133 if not in_runhooks():
127 print 'DumpRenderTree is up to date.\nVersion: ' + latest 134 print 'DumpRenderTree is up to date.\nVersion: ' + latest
128 return 0 # up to date 135 return 0 # up to date
129 136
130 if os.path.exists(DRT_DIR): 137 if os.path.exists(directory):
131 print 'Removing old DumpRenderTree tree %s' % DRT_DIR 138 print 'Removing old DumpRenderTree tree %s' % directory
132 shutil.rmtree(DRT_DIR) 139 shutil.rmtree(directory)
133 140
134 # download the zip file to a temporary path, and unzip to the target location 141 # download the zip file to a temporary path, and unzip to the target location
135 temp_dir = tempfile.mkdtemp() 142 temp_dir = tempfile.mkdtemp()
136 try: 143 try:
137 temp_zip = temp_dir + '/drt.zip' 144 temp_zip = temp_dir + '/drt.zip'
138 # It's nice to show download progress 145 # It's nice to show download progress
139 gsutil_visible('cp', latest, temp_zip) 146 gsutil_visible('cp', latest, temp_zip)
140 147
141 result, out = execute_command('unzip', temp_zip, '-d', temp_dir) 148 result, out = execute_command('unzip', temp_zip, '-d', temp_dir)
142 if result != 0: 149 if result != 0:
143 raise Exception('Execution of "unzip %s -d %s" failed: %s' % 150 raise Exception('Execution of "unzip %s -d %s" failed: %s' %
144 (temp_zip, temp_dir, str(out))) 151 (temp_zip, temp_dir, str(out)))
145 unzipped_dir = temp_dir + '/' + os.path.basename(latest)[:-4] # remove .zip 152 unzipped_dir = temp_dir + '/' + os.path.basename(latest)[:-4] # remove .zip
146 shutil.move(unzipped_dir, DRT_DIR) 153 shutil.move(unzipped_dir, directory)
147 finally: 154 finally:
148 shutil.rmtree(temp_dir) 155 shutil.rmtree(temp_dir)
149 156
150 # create the version stamp 157 # create the version stamp
151 v = open(VERSION, 'w') 158 v = open(version_file, 'w')
152 v.write(latest) 159 v.write(latest)
153 v.close() 160 v.close()
154 161
155 print 'Successfully downloaded to %s' % DRT_DIR 162 print 'Successfully downloaded to %s' % directory
156 return 0 163 return 0
157 164
165
166 def main():
167 parser = optparse.OptionParser()
168 parser.add_option('--dartium', dest='dartium',
169 help='Get latest Dartium', action='store_true',
170 default=False)
171 args, _ = parser.parse_args()
172
173 if args.dartium:
174 get_latest(DARTIUM_DIR, DARTIUM_VERSION,
175 DARTIUM_LATEST_PATTERN, DARTIUM_PERMANENT_PREFIX)
176 else:
177 get_latest(DRT_DIR, DRT_VERSION, DRT_LATEST_PATTERN, DRT_PERMANENT_PREFIX)
Siggi Cherem (dart-lang) 2012/04/09 20:58:18 do we need to always get the latest? Or could we u
178
158 if __name__ == '__main__': 179 if __name__ == '__main__':
159 sys.exit(main()) 180 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