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

Side by Side Diff: tools/rebaseline.py

Issue 20017009: rebaseline.py: set text mimetype for all .json files, so text diffs work (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 4 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 12
13 TODO(epoger): Fix indentation in this file (2-space indents, not 4-space). 13 TODO(epoger): Fix indentation in this file (2-space indents, not 4-space).
14 ''' 14 '''
15 15
16 # System-level imports 16 # System-level imports
17 import argparse 17 import argparse
18 import os 18 import os
19 import re 19 import re
20 import subprocess
20 import sys 21 import sys
21 import urllib2 22 import urllib2
22 23
23 # Imports from local directory 24 # Imports from local directory
24 import rebaseline_imagefiles 25 import rebaseline_imagefiles
25 26
26 # Imports from within Skia 27 # Imports from within Skia
27 # 28 #
28 # We need to add the 'gm' directory, so that we can import gm_json.py within 29 # We need to add the 'gm' directory, so that we can import gm_json.py within
29 # that directory. That script allows us to parse the actual-results.json file 30 # that directory. That script allows us to parse the actual-results.json file
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 tests=None, configs=None, add_new=False): 141 tests=None, configs=None, add_new=False):
141 self._expectations_root = expectations_root 142 self._expectations_root = expectations_root
142 self._expectations_filename = expectations_filename 143 self._expectations_filename = expectations_filename
143 self._tests = tests 144 self._tests = tests
144 self._configs = configs 145 self._configs = configs
145 self._actuals_base_url = actuals_base_url 146 self._actuals_base_url = actuals_base_url
146 self._actuals_filename = actuals_filename 147 self._actuals_filename = actuals_filename
147 self._exception_handler = exception_handler 148 self._exception_handler = exception_handler
148 self._add_new = add_new 149 self._add_new = add_new
149 self._image_filename_re = re.compile(gm_json.IMAGE_FILENAME_PATTERN) 150 self._image_filename_re = re.compile(gm_json.IMAGE_FILENAME_PATTERN)
151 self._using_svn = os.path.isdir(os.path.join(expectations_root, '.svn'))
152
153 # Executes subprocess.call(cmd).
154 # Raises an Exception if the command fails.
155 def _Call(self, cmd):
156 if subprocess.call(cmd) != 0:
157 raise _InternalException('error running command: ' + ' '.join(cmd))
150 158
151 # Returns the full contents of filepath, as a single string. 159 # Returns the full contents of filepath, as a single string.
152 # If filepath looks like a URL, try to read it that way instead of as 160 # If filepath looks like a URL, try to read it that way instead of as
153 # a path on local storage. 161 # a path on local storage.
154 # 162 #
155 # Raises _InternalException if there is a problem. 163 # Raises _InternalException if there is a problem.
156 def _GetFileContents(self, filepath): 164 def _GetFileContents(self, filepath):
157 if filepath.startswith('http:') or filepath.startswith('https:'): 165 if filepath.startswith('http:') or filepath.startswith('https:'):
158 try: 166 try:
159 return urllib2.urlopen(filepath).read() 167 return urllib2.urlopen(filepath).read()
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 continue 255 continue
248 if not expected_results.get(image_name): 256 if not expected_results.get(image_name):
249 expected_results[image_name] = {} 257 expected_results[image_name] = {}
250 expected_results[image_name] \ 258 expected_results[image_name] \
251 [gm_json.JSONKEY_EXPECTEDRESULTS_ALLOWEDDIGESTS] = \ 259 [gm_json.JSONKEY_EXPECTEDRESULTS_ALLOWEDDIGESTS] = \
252 [image_results] 260 [image_results]
253 261
254 # Write out updated expectations. 262 # Write out updated expectations.
255 gm_json.WriteToFile(expectations_dict, expectations_json_filepath) 263 gm_json.WriteToFile(expectations_dict, expectations_json_filepath)
256 264
265 # Mark the JSON file as plaintext, so text-style diffs can be applied.
266 # Fixes https://code.google.com/p/skia/issues/detail?id=1442
267 if self._using_svn:
268 self._Call(['svn', 'propset', '--quiet', 'svn:mime-type',
269 'text/x-json', expectations_json_filepath])
257 270
258 # main... 271 # main...
259 272
260 parser = argparse.ArgumentParser() 273 parser = argparse.ArgumentParser()
261 parser.add_argument('--actuals-base-url', 274 parser.add_argument('--actuals-base-url',
262 help='base URL from which to read files containing JSON ' + 275 help='base URL from which to read files containing JSON ' +
263 'summaries of actual GM results; defaults to %(default)s', 276 'summaries of actual GM results; defaults to %(default)s',
264 default='http://skia-autogen.googlecode.com/svn/gm-actual') 277 default='http://skia-autogen.googlecode.com/svn/gm-actual')
265 parser.add_argument('--actuals-filename', 278 parser.add_argument('--actuals-filename',
266 help='filename (within platform-specific subdirectories ' + 279 help='filename (within platform-specific subdirectories ' +
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 exception_handler=exception_handler, 372 exception_handler=exception_handler,
360 add_new=args.add_new, 373 add_new=args.add_new,
361 missing_json_is_fatal=missing_json_is_fatal) 374 missing_json_is_fatal=missing_json_is_fatal)
362 375
363 try: 376 try:
364 rebaseliner.RebaselineSubdir(subdir=subdir, builder=builder) 377 rebaseliner.RebaselineSubdir(subdir=subdir, builder=builder)
365 except BaseException as e: 378 except BaseException as e:
366 exception_handler.RaiseExceptionOrContinue(e) 379 exception_handler.RaiseExceptionOrContinue(e)
367 380
368 exception_handler.ReportAllFailures() 381 exception_handler.ReportAllFailures()
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