OLD | NEW |
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 argparse |
17 import os | 17 import os |
18 import subprocess | 18 import subprocess |
19 import sys | 19 import sys |
20 import tempfile | |
21 | 20 |
22 # Mapping of gm-expectations subdir (under | 21 # Mapping of gm-expectations subdir (under |
23 # https://skia.googlecode.com/svn/gm-expected/ ) | 22 # https://skia.googlecode.com/svn/gm-expected/ ) |
24 # to builder name (see list at http://108.170.217.252:10117/builders ) | 23 # to builder name (see list at http://108.170.217.252:10117/builders ) |
25 SUBDIR_MAPPING = { | 24 SUBDIR_MAPPING = { |
26 'base-shuttle-win7-intel-float': | 25 'base-shuttle-win7-intel-float': |
27 'Test-Win7-ShuttleA-HD2000-x86-Release', | 26 'Test-Win7-ShuttleA-HD2000-x86-Release', |
28 'base-shuttle-win7-intel-angle': | 27 'base-shuttle-win7-intel-angle': |
29 'Test-Win7-ShuttleA-HD2000-x86-Release-ANGLE', | 28 'Test-Win7-ShuttleA-HD2000-x86-Release-ANGLE', |
30 'base-shuttle-win7-intel-directwrite': | 29 'base-shuttle-win7-intel-directwrite': |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 self._subdirs = subdirs | 68 self._subdirs = subdirs |
70 self._dry_run = dry_run | 69 self._dry_run = dry_run |
71 self._is_svn_checkout = ( | 70 self._is_svn_checkout = ( |
72 os.path.exists('.svn') or | 71 os.path.exists('.svn') or |
73 os.path.exists(os.path.join(os.pardir, '.svn'))) | 72 os.path.exists(os.path.join(os.pardir, '.svn'))) |
74 self._is_git_checkout = ( | 73 self._is_git_checkout = ( |
75 os.path.exists('.git') or | 74 os.path.exists('.git') or |
76 os.path.exists(os.path.join(os.pardir, '.git'))) | 75 os.path.exists(os.path.join(os.pardir, '.git'))) |
77 | 76 |
78 # Execute subprocess.call(), unless dry_run is True | 77 # Execute subprocess.call(), unless dry_run is True |
79 def _Call(self, cmd, stdout=None): | 78 def _Call(self, cmd): |
80 if self._dry_run: | 79 if self._dry_run: |
81 print '%s' % ' '.join(cmd) | 80 print '%s' % ' '.join(cmd) |
82 return 0 | 81 return 0 |
83 if stdout: | |
84 return subprocess.call(cmd, stdout=stdout) | |
85 else: | 82 else: |
86 return subprocess.call(cmd) | 83 return subprocess.call(cmd) |
87 | 84 |
88 # Rebaseline a single file. | 85 # Rebaseline a single file. |
89 def _RebaselineOneFile(self, expectations_subdir, builder_name, | 86 def _RebaselineOneFile(self, expectations_subdir, builder_name, |
90 infilename, outfilename): | 87 infilename, outfilename): |
91 url = ('http://skia-autogen.googlecode.com/svn/gm-actual/' + | 88 url = ('http://skia-autogen.googlecode.com/svn/gm-actual/' + |
92 expectations_subdir + '/' + builder_name + '/' + | 89 expectations_subdir + '/' + builder_name + '/' + |
93 expectations_subdir + '/' + infilename) | 90 expectations_subdir + '/' + infilename) |
94 cmd = [ 'curl', '--fail', '--silent', url ] | 91 cmd = [ 'curl', '--fail', '--silent', url, '--output', outfilename ] |
95 temp = tempfile.NamedTemporaryFile() | 92 ret = self._Call(cmd) |
96 ret = self._Call(cmd, stdout=temp) | |
97 if ret != 0: | 93 if ret != 0: |
98 print '# Couldn\'t fetch ' + url | 94 print '# Couldn\'t fetch ' + url |
99 return | 95 return |
100 cmd = [ 'cp', temp.name, outfilename ] | |
101 self._Call(cmd); | |
102 if self._is_svn_checkout: | 96 if self._is_svn_checkout: |
103 cmd = [ 'svn', 'add', '--quiet', outfilename ] | 97 cmd = [ 'svn', 'add', '--quiet', outfilename ] |
104 self._Call(cmd) | 98 self._Call(cmd) |
105 cmd = [ 'svn', 'propset', '--quiet', 'svn:mime-type', 'image/png', | 99 cmd = [ 'svn', 'propset', '--quiet', 'svn:mime-type', 'image/png', |
106 outfilename ]; | 100 outfilename ]; |
107 self._Call(cmd) | 101 self._Call(cmd) |
108 elif self._is_git_checkout: | 102 elif self._is_git_checkout: |
109 cmd = [ 'git', 'add', outfilename ] | 103 cmd = [ 'git', 'add', outfilename ] |
110 self._Call(cmd) | 104 self._Call(cmd) |
111 | 105 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 help='which platform subdirectories to rebaseline; ' + | 157 help='which platform subdirectories to rebaseline; ' + |
164 'if unspecified, rebaseline all subdirs, same as ' + | 158 'if unspecified, rebaseline all subdirs, same as ' + |
165 '"--subdirs %s"' % ' '.join(sorted(SUBDIR_MAPPING.keys()))) | 159 '"--subdirs %s"' % ' '.join(sorted(SUBDIR_MAPPING.keys()))) |
166 parser.add_argument('--tests', metavar='TEST', nargs='+', required=True, | 160 parser.add_argument('--tests', metavar='TEST', nargs='+', required=True, |
167 help='which tests to rebaseline, e.g. ' + | 161 help='which tests to rebaseline, e.g. ' + |
168 '"--tests aaclip bigmatrix"') | 162 '"--tests aaclip bigmatrix"') |
169 args = parser.parse_args() | 163 args = parser.parse_args() |
170 rebaseliner = Rebaseliner(tests=args.tests, configs=args.configs, | 164 rebaseliner = Rebaseliner(tests=args.tests, configs=args.configs, |
171 subdirs=args.subdirs, dry_run=args.dry_run) | 165 subdirs=args.subdirs, dry_run=args.dry_run) |
172 rebaseliner.RebaselineAll() | 166 rebaseliner.RebaselineAll() |
OLD | NEW |