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

Side by Side Diff: tools/rebaseline.py

Issue 15675010: rebaseline.py: use argparse command-line flags for more flexibility (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: tweaks Created 7 years, 6 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 | no next file » | 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/python 1 #!/usr/bin/python
2 2
3 ''' 3 '''
4 Copyright 2012 Google Inc. 4 Copyright 2012 Google Inc.
5 5
6 Use of this source code is governed by a BSD-style license that can be 6 Use of this source code is governed by a BSD-style license that can be
7 found in the LICENSE file. 7 found in the LICENSE file.
8 ''' 8 '''
9 9
10 ''' 10 '''
11 Rebaselines the given GM tests, on all bots and all configurations. 11 Rebaselines the given GM tests, on all bots and all configurations.
12 Must be run from the gm-expected directory. If run from a git or SVN 12 Must be run from the gm-expected directory. If run from a git or SVN
13 checkout, the files will be added to the staging area for commit. 13 checkout, the files will be added to the staging area for commit.
14 ''' 14 '''
15 15
16 import argparse
16 import os 17 import os
17 import subprocess 18 import subprocess
18 import sys 19 import sys
19 import tempfile 20 import tempfile
20 21
21 # Mapping of gm-expectations subdir (under 22 # Mapping of gm-expectations subdir (under
22 # https://skia.googlecode.com/svn/gm-expected/ ) 23 # https://skia.googlecode.com/svn/gm-expected/ )
23 # to builder name (see list at http://108.170.217.252:10117/builders ) 24 # to builder name (see list at http://108.170.217.252:10117/builders )
24 subdir_mapping = { 25 SUBDIR_MAPPING = {
25 'base-shuttle-win7-intel-float': 26 'base-shuttle-win7-intel-float':
26 'Test-Win7-ShuttleA-HD2000-x86-Release', 27 'Test-Win7-ShuttleA-HD2000-x86-Release',
27 'base-shuttle-win7-intel-angle': 28 'base-shuttle-win7-intel-angle':
28 'Test-Win7-ShuttleA-HD2000-x86-Release-ANGLE', 29 'Test-Win7-ShuttleA-HD2000-x86-Release-ANGLE',
29 'base-shuttle-win7-intel-directwrite': 30 'base-shuttle-win7-intel-directwrite':
30 'Test-Win7-ShuttleA-HD2000-x86-Release-DirectWrite', 31 'Test-Win7-ShuttleA-HD2000-x86-Release-DirectWrite',
31 'base-shuttle_ubuntu12_ati5770': 32 'base-shuttle_ubuntu12_ati5770':
32 'Test-Ubuntu12-ShuttleA-ATI5770-x86_64-Release', 33 'Test-Ubuntu12-ShuttleA-ATI5770-x86_64-Release',
33 'base-macmini': 34 'base-macmini':
34 'Test-Mac10.6-MacMini4.1-GeForce320M-x86-Release', 35 'Test-Mac10.6-MacMini4.1-GeForce320M-x86-Release',
35 'base-macmini-lion-float': 36 'base-macmini-lion-float':
36 'Test-Mac10.7-MacMini4.1-GeForce320M-x86-Release', 37 'Test-Mac10.7-MacMini4.1-GeForce320M-x86-Release',
37 'base-android-galaxy-nexus': 38 'base-android-galaxy-nexus':
38 'Test-Android-GalaxyNexus-SGX540-Arm7-Debug', 39 'Test-Android-GalaxyNexus-SGX540-Arm7-Debug',
39 'base-android-nexus-7': 40 'base-android-nexus-7':
40 'Test-Android-Nexus7-Tegra3-Arm7-Release', 41 'Test-Android-Nexus7-Tegra3-Arm7-Release',
41 'base-android-nexus-s': 42 'base-android-nexus-s':
42 'Test-Android-NexusS-SGX540-Arm7-Release', 43 'Test-Android-NexusS-SGX540-Arm7-Release',
43 'base-android-xoom': 44 'base-android-xoom':
44 'Test-Android-Xoom-Tegra2-Arm7-Release', 45 'Test-Android-Xoom-Tegra2-Arm7-Release',
45 'base-android-nexus-10': 46 'base-android-nexus-10':
46 'Test-Android-Nexus10-MaliT604-Arm7-Release', 47 'Test-Android-Nexus10-MaliT604-Arm7-Release',
47 } 48 }
48 49
49 IS_SVN_CHECKOUT = (os.path.exists('.svn') or 50
50 os.path.exists(os.path.join('..', '.svn'))) 51 class Rebaseliner(object):
51 IS_GIT_CHECKOUT = (os.path.exists('.git') or 52
52 os.path.exists(os.path.join('..', '.git'))) 53 # params:
54 # tests: list of tests to rebaseline
55 # configs: which configs to run for each test
56 # subdirs: which platform subdirectories to rebaseline; if an empty list,
57 # rebaseline all platform subdirectories
58 # dry_run: if True, instead of actually downloading files or adding
59 # files to checkout, display a list of operations that
60 # we would normally perform
61 def __init__(self, tests, configs=[], subdirs=[], dry_run=False):
62 if not tests:
63 raise Exception('at least one test must be specified')
64 self._tests = tests
65 self._configs = configs
66 if not subdirs:
67 self._subdirs = sorted(SUBDIR_MAPPING.keys())
68 else:
69 self._subdirs = subdirs
70 self._dry_run = dry_run
71 self._is_svn_checkout = (
72 os.path.exists('.svn') or
73 os.path.exists(os.path.join(os.pardir, '.svn')))
74 self._is_git_checkout = (
75 os.path.exists('.git') or
76 os.path.exists(os.path.join(os.pardir, '.git')))
77
78 # Execute subprocess.call(), unless dry_run is True
79 def _Call(self, cmd, stdout=None):
80 if self._dry_run:
81 print '%s' % ' '.join(cmd)
82 return 0
83 if stdout:
84 return subprocess.call(cmd, stdout=stdout)
85 else:
86 return subprocess.call(cmd)
87
88 # Rebaseline a single file.
89 def _RebaselineOneFile(self, expectations_subdir, builder_name,
90 infilename, outfilename):
91 url = ('http://skia-autogen.googlecode.com/svn/gm-actual/' +
92 expectations_subdir + '/' + builder_name + '/' +
93 expectations_subdir + '/' + infilename)
94 cmd = [ 'curl', '--fail', '--silent', url ]
95 temp = tempfile.NamedTemporaryFile()
96 ret = self._Call(cmd, stdout=temp)
97 if ret != 0:
98 print '# Couldn\'t fetch ' + url
99 return
100 cmd = [ 'cp', temp.name, outfilename ]
101 self._Call(cmd);
102 if self._is_svn_checkout:
103 cmd = [ 'svn', 'add', '--quiet', outfilename ]
104 self._Call(cmd)
105 cmd = [ 'svn', 'propset', '--quiet', 'svn:mime-type', 'image/png',
106 outfilename ];
107 self._Call(cmd)
108 elif self._is_git_checkout:
109 cmd = [ 'git', 'add', outfilename ]
110 self._Call(cmd)
111
112 # Rebaseline the given configs for a single test.
113 #
114 # params:
115 # expectations_subdir
116 # builder_name
117 # test: a single test to rebaseline
118 def _RebaselineOneTest(self, expectations_subdir, builder_name, test):
119 if self._configs:
120 configs = self._configs
121 else:
122 if (expectations_subdir == 'base-shuttle-win7-intel-angle'):
123 configs = [ 'angle', 'anglemsaa16' ]
124 else:
125 configs = [ '565', '8888', 'gpu', 'pdf', 'mesa', 'msaa16',
126 'msaa4' ]
127 print '# ' + expectations_subdir + ':'
128 for config in configs:
129 infilename = test + '_' + config + '.png'
130 print '# ' + infilename
131 outfilename = os.path.join(expectations_subdir, infilename);
132 self._RebaselineOneFile(expectations_subdir=expectations_subdir,
133 builder_name=builder_name,
134 infilename=infilename,
135 outfilename=outfilename)
136
137 # Rebaseline all platforms/tests/types we specified in the constructor.
138 def RebaselineAll(self):
139 for test in self._tests:
140 for subdir in self._subdirs:
141 if not subdir in SUBDIR_MAPPING.keys():
142 raise Exception(('unrecognized platform subdir "%s"; ' +
143 'should be one of %s') % (
144 subdir, SUBDIR_MAPPING.keys()))
145 builder_name = SUBDIR_MAPPING[subdir]
146 self._RebaselineOneTest(expectations_subdir=subdir,
147 builder_name=builder_name,
148 test=test)
53 149
54 150
55 # Rebaseline a single file. 151 # main...
56 def RebaselineOneFile(expectations_subdir, builder_name,
57 infilename, outfilename):
58 url = ('http://skia-autogen.googlecode.com/svn/gm-actual/' +
59 expectations_subdir + '/' + builder_name + '/' +
60 expectations_subdir + '/' + infilename)
61 cmd = [ 'curl', '--fail', '--silent', url ]
62 temp = tempfile.NamedTemporaryFile()
63 ret = subprocess.call(cmd, stdout=temp)
64 if ret != 0:
65 print 'Couldn\'t fetch ' + url
66 return
67 cmd = [ 'cp', temp.name, outfilename ]
68 subprocess.call(cmd);
69 if IS_SVN_CHECKOUT:
70 cmd = [ 'svn', 'add', '--quiet', outfilename ]
71 subprocess.call(cmd)
72 cmd = [ 'svn', 'propset', '--quiet', 'svn:mime-type', 'image/png',
73 outfilename ];
74 subprocess.call(cmd)
75 elif IS_GIT_CHECKOUT:
76 cmd = [ 'git', 'add', outfilename ]
77 subprocess.call(cmd)
78 152
79 153 parser = argparse.ArgumentParser()
80 # Rebaseline all testtypes for a single test. 154 parser.add_argument('--configs', metavar='CONFIG', nargs='+',
epoger 2013/05/30 15:39:28 This means: if "--configs" is given, it MUST be fo
81 def RebaselineOneTest(expectations_subdir, builder_name, testname): 155 help='which configurations to rebaseline, e.g. ' +
82 if (expectations_subdir == 'base-shuttle-win7-intel-angle'): 156 '"--configs 565 8888"; if unspecified, run a default ' +
83 testtypes = [ 'angle', 'anglemsaa16' ] 157 'set of configs')
84 else: 158 parser.add_argument('--dry_run', action='store_true',
85 testtypes = [ '565', '8888', 'gpu', 'pdf', 'mesa', 'msaa16', 'msaa4' ] 159 help='instead of actually downloading files or adding ' +
86 print expectations_subdir + ':' 160 'files to checkout, display a list of operations that ' +
87 for testtype in testtypes: 161 'we would normally perform')
88 infilename = testname + '_' + testtype + '.png' 162 parser.add_argument('--subdirs', metavar='SUBDIR', nargs='+',
89 print infilename 163 help='which platform subdirectories to rebaseline; ' +
90 outfilename = os.path.join(expectations_subdir, infilename); 164 'if unspecified, rebaseline all subdirs, same as ' +
91 RebaselineOneFile(expectations_subdir=expectations_subdir, 165 '"--subdirs %s"' % ' '.join(sorted(SUBDIR_MAPPING.keys())))
92 builder_name=builder_name, 166 parser.add_argument('--tests', metavar='TEST', nargs='+', required=True,
93 infilename=infilename, 167 help='which tests to rebaseline, e.g. ' +
94 outfilename=outfilename) 168 '"--tests aaclip bigmatrix"')
95 169 args = parser.parse_args()
96 170 rebaseliner = Rebaseliner(tests=args.tests, configs=args.configs,
97 171 subdirs=args.subdirs, dry_run=args.dry_run)
98 if len(sys.argv) < 2: 172 rebaseliner.RebaselineAll()
99 print ('Usage: ' + os.path.basename(sys.argv[0]) +
100 ' <testname> [ <testname> ... ]')
101 exit(1)
102
103 for testname in sys.argv[1:]:
104 for expectations_subdir in sorted(subdir_mapping.keys()):
105 builder_name = subdir_mapping[expectations_subdir]
106 RebaselineOneTest(expectations_subdir=expectations_subdir,
107 builder_name=builder_name,
108 testname=testname)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698