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

Side by Side Diff: tools/rebaseline.py

Issue 19112002: svndiff.py: add ability to compare before-and-after JSON files, not just raw images (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: add_CreateGmActualURL Created 7 years, 5 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
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 '''
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 def __init__(self, expectations_root, expectations_filename, 94 def __init__(self, expectations_root, expectations_filename,
95 actuals_base_url, actuals_filename, 95 actuals_base_url, actuals_filename,
96 tests=None, configs=None, add_new=False): 96 tests=None, configs=None, add_new=False):
97 self._expectations_root = expectations_root 97 self._expectations_root = expectations_root
98 self._expectations_filename = expectations_filename 98 self._expectations_filename = expectations_filename
99 self._tests = tests 99 self._tests = tests
100 self._configs = configs 100 self._configs = configs
101 self._actuals_base_url = actuals_base_url 101 self._actuals_base_url = actuals_base_url
102 self._actuals_filename = actuals_filename 102 self._actuals_filename = actuals_filename
103 self._add_new = add_new 103 self._add_new = add_new
104 self._testname_pattern = re.compile('(\S+)_(\S+).png') 104 self._image_filename_re = re.compile(gm_json.IMAGE_FILENAME_PATTERN)
105 105
106 # Returns the full contents of filepath, as a single string. 106 # Returns the full contents of filepath, as a single string.
107 # If filepath looks like a URL, try to read it that way instead of as 107 # If filepath looks like a URL, try to read it that way instead of as
108 # a path on local storage. 108 # a path on local storage.
109 # 109 #
110 # Raises _InternalException if there is a problem. 110 # Raises _InternalException if there is a problem.
111 def _GetFileContents(self, filepath): 111 def _GetFileContents(self, filepath):
112 if filepath.startswith('http:') or filepath.startswith('https:'): 112 if filepath.startswith('http:') or filepath.startswith('https:'):
113 try: 113 try:
114 return urllib2.urlopen(filepath).read() 114 return urllib2.urlopen(filepath).read()
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 # Read in current expectations. 178 # Read in current expectations.
179 expectations_json_filepath = os.path.join( 179 expectations_json_filepath = os.path.join(
180 self._expectations_root, subdir, self._expectations_filename) 180 self._expectations_root, subdir, self._expectations_filename)
181 expectations_dict = gm_json.LoadFromFile(expectations_json_filepath) 181 expectations_dict = gm_json.LoadFromFile(expectations_json_filepath)
182 182
183 # Update the expectations in memory, skipping any tests/configs that 183 # Update the expectations in memory, skipping any tests/configs that
184 # the caller asked to exclude. 184 # the caller asked to exclude.
185 skipped_images = [] 185 skipped_images = []
186 if results_to_update: 186 if results_to_update:
187 for (image_name, image_results) in results_to_update.iteritems(): 187 for (image_name, image_results) in results_to_update.iteritems():
188 (test, config) = self._testname_pattern.match(image_name).groups () 188 (test, config) = self._image_filename_re.match(image_name).group s()
borenet 2013/07/16 18:31:03 nit: 80 chars Also, why are we using four space i
epoger 2013/07/16 18:42:32 Thanks to Python's whitespace-sensitivity, I could
borenet 2013/07/16 18:48:37 It's ugly, but what about: (test, config) = \
189 if self._tests: 189 if self._tests:
190 if test not in self._tests: 190 if test not in self._tests:
191 skipped_images.append(image_name) 191 skipped_images.append(image_name)
192 continue 192 continue
193 if self._configs: 193 if self._configs:
194 if config not in self._configs: 194 if config not in self._configs:
195 skipped_images.append(image_name) 195 skipped_images.append(image_name)
196 continue 196 continue
197 expectations_dict[gm_json.JSONKEY_EXPECTEDRESULTS] \ 197 expectations_dict[gm_json.JSONKEY_EXPECTEDRESULTS] \
198 [image_name] \ 198 [image_name] \
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 dry_run=args.dry_run, 297 dry_run=args.dry_run,
298 json_base_url=args.actuals_base_url, 298 json_base_url=args.actuals_base_url,
299 json_filename=args.actuals_filename, 299 json_filename=args.actuals_filename,
300 add_new=args.add_new, 300 add_new=args.add_new,
301 missing_json_is_fatal=missing_json_is_fatal) 301 missing_json_is_fatal=missing_json_is_fatal)
302 try: 302 try:
303 rebaseliner.RebaselineSubdir(subdir=subdir, builder=builder) 303 rebaseliner.RebaselineSubdir(subdir=subdir, builder=builder)
304 except BaseException as e: 304 except BaseException as e:
305 print >> sys.stderr, e 305 print >> sys.stderr, e
306 sys.exit(1) 306 sys.exit(1)
OLDNEW
« no previous file with comments | « tools/jsondiff.py ('k') | tools/rebaseline_imagefiles.py » ('j') | tools/svndiff.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698