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

Side by Side Diff: gm/rebaseline_server/results.py

Issue 117413006: create unittest for gm/rebaseline_server/results.py (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address comments Created 6 years, 12 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
« no previous file with comments | « no previous file | gm/rebaseline_server/results_test.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/python 1 #!/usr/bin/python
2 2
3 """ 3 """
4 Copyright 2013 Google Inc. 4 Copyright 2013 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 Repackage expected/actual GM results as needed by our HTML rebaseline viewer. 9 Repackage expected/actual GM results as needed by our HTML rebaseline viewer.
10 """ 10 """
11 11
12 # System-level imports 12 # System-level imports
13 import argparse
13 import fnmatch 14 import fnmatch
14 import json 15 import json
15 import logging 16 import logging
16 import os 17 import os
17 import re 18 import re
18 import sys 19 import sys
19 import time 20 import time
20 21
21 # Imports from within Skia 22 # Imports from within Skia
22 # 23 #
23 # We need to add the 'gm' directory, so that we can import gm_json.py within 24 # We need to add the 'gm' directory, so that we can import gm_json.py within
24 # that directory. That script allows us to parse the actual-results.json file 25 # that directory. That script allows us to parse the actual-results.json file
25 # written out by the GM tool. 26 # written out by the GM tool.
26 # Make sure that the 'gm' dir is in the PYTHONPATH, but add it at the *end* 27 # Make sure that the 'gm' dir is in the PYTHONPATH, but add it at the *end*
27 # so any dirs that are already in the PYTHONPATH will be preferred. 28 # so any dirs that are already in the PYTHONPATH will be preferred.
28 GM_DIRECTORY = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) 29 PARENT_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
30 GM_DIRECTORY = os.path.dirname(PARENT_DIRECTORY)
29 if GM_DIRECTORY not in sys.path: 31 if GM_DIRECTORY not in sys.path:
30 sys.path.append(GM_DIRECTORY) 32 sys.path.append(GM_DIRECTORY)
31 import gm_json 33 import gm_json
32 import imagediffdb 34 import imagediffdb
33 35
34 IMAGE_FILENAME_RE = re.compile(gm_json.IMAGE_FILENAME_PATTERN) 36 IMAGE_FILENAME_RE = re.compile(gm_json.IMAGE_FILENAME_PATTERN)
35 IMAGE_FILENAME_FORMATTER = '%s_%s.png' # pass in (testname, config) 37 IMAGE_FILENAME_FORMATTER = '%s_%s.png' # pass in (testname, config)
36 38
37 FIELDS_PASSED_THRU_VERBATIM = [ 39 FIELDS_PASSED_THRU_VERBATIM = [
38 gm_json.JSONKEY_EXPECTEDRESULTS_BUGS, 40 gm_json.JSONKEY_EXPECTEDRESULTS_BUGS,
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 category_dict: category dict-of-dicts to modify 491 category_dict: category dict-of-dicts to modify
490 category_name: category name, as a string 492 category_name: category name, as a string
491 category_values: list of values we want to make sure are represented 493 category_values: list of values we want to make sure are represented
492 for this category 494 for this category
493 """ 495 """
494 if not category_dict.get(category_name): 496 if not category_dict.get(category_name):
495 category_dict[category_name] = {} 497 category_dict[category_name] = {}
496 for category_value in category_values: 498 for category_value in category_values:
497 if not category_dict[category_name].get(category_value): 499 if not category_dict[category_name].get(category_value):
498 category_dict[category_name][category_value] = 0 500 category_dict[category_name][category_value] = 0
501
502
503 def main():
504 logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
505 datefmt='%m/%d/%Y %H:%M:%S',
506 level=logging.INFO)
507 parser = argparse.ArgumentParser()
508 parser.add_argument(
509 '--actuals', required=True,
510 help='Directory containing all actual-result JSON files')
511 parser.add_argument(
512 '--expectations', required=True,
513 help='Directory containing all expected-result JSON files')
514 parser.add_argument(
515 '--outfile', required=True,
516 help='File to write result summary into, in JSON format')
517 parser.add_argument(
518 '--workdir', default='.workdir',
519 help='Directory within which to download images and generate diffs')
520 args = parser.parse_args()
521 results = Results(actuals_root=args.actuals,
522 expected_root=args.expectations,
523 generated_images_root=args.workdir)
524 gm_json.WriteToFile(results.get_results_of_type(RESULTS_ALL), args.outfile)
525
526
527 if __name__ == '__main__':
528 main()
OLDNEW
« no previous file with comments | « no previous file | gm/rebaseline_server/results_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698