OLD | NEW |
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 argparse |
14 import fnmatch | 14 import fnmatch |
15 import json | 15 import json |
16 import logging | 16 import logging |
17 import os | 17 import os |
18 import re | 18 import re |
19 import sys | 19 import sys |
20 import time | 20 import time |
21 | 21 |
22 # Imports from within Skia | 22 # Imports from within Skia |
23 import fix_pythonpath # must do this first | 23 # |
24 from pyutils import url_utils | 24 # TODO(epoger): Once we move the create_filepath_url() function out of |
| 25 # download_actuals into a shared utility module, we won't need to import |
| 26 # download_actuals anymore. |
| 27 # |
| 28 # 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 # written out by the GM tool. |
| 31 # Make sure that the 'gm' dir is in the PYTHONPATH, but add it at the *end* |
| 32 # so any dirs that are already in the PYTHONPATH will be preferred. |
| 33 PARENT_DIRECTORY = os.path.dirname(os.path.realpath(__file__)) |
| 34 GM_DIRECTORY = os.path.dirname(PARENT_DIRECTORY) |
| 35 TRUNK_DIRECTORY = os.path.dirname(GM_DIRECTORY) |
| 36 if GM_DIRECTORY not in sys.path: |
| 37 sys.path.append(GM_DIRECTORY) |
| 38 import download_actuals |
25 import gm_json | 39 import gm_json |
26 import imagediffdb | 40 import imagediffdb |
27 import imagepair | 41 import imagepair |
28 import imagepairset | 42 import imagepairset |
29 import results | 43 import results |
30 | 44 |
31 EXPECTATION_FIELDS_PASSED_THRU_VERBATIM = [ | 45 EXPECTATION_FIELDS_PASSED_THRU_VERBATIM = [ |
32 results.KEY__EXPECTATIONS__BUGS, | 46 results.KEY__EXPECTATIONS__BUGS, |
33 results.KEY__EXPECTATIONS__IGNOREFAILURE, | 47 results.KEY__EXPECTATIONS__IGNOREFAILURE, |
34 results.KEY__EXPECTATIONS__REVIEWED, | 48 results.KEY__EXPECTATIONS__REVIEWED, |
35 ] | 49 ] |
36 TRUNK_DIRECTORY = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) | |
37 DEFAULT_EXPECTATIONS_DIR = os.path.join(TRUNK_DIRECTORY, 'expectations', 'gm') | 50 DEFAULT_EXPECTATIONS_DIR = os.path.join(TRUNK_DIRECTORY, 'expectations', 'gm') |
38 DEFAULT_IGNORE_FAILURES_FILE = 'ignored-tests.txt' | 51 DEFAULT_IGNORE_FAILURES_FILE = 'ignored-tests.txt' |
39 | 52 |
40 IMAGEPAIR_SET_DESCRIPTIONS = ('expected image', 'actual image') | 53 IMAGEPAIR_SET_DESCRIPTIONS = ('expected image', 'actual image') |
41 | 54 |
42 | 55 |
43 class ExpectationComparisons(results.BaseComparisons): | 56 class ExpectationComparisons(results.BaseComparisons): |
44 """Loads actual and expected GM results into an ImagePairSet. | 57 """Loads actual and expected GM results into an ImagePairSet. |
45 | 58 |
46 Loads actual and expected results from all builders, except for those skipped | 59 Loads actual and expected results from all builders, except for those skipped |
(...skipping 21 matching lines...) Expand all Loading... |
68 of generated_images_root | 81 of generated_images_root |
69 builder_regex_list: List of regular expressions specifying which builders | 82 builder_regex_list: List of regular expressions specifying which builders |
70 we will process. If None, process all builders. | 83 we will process. If None, process all builders. |
71 """ | 84 """ |
72 time_start = int(time.time()) | 85 time_start = int(time.time()) |
73 if builder_regex_list != None: | 86 if builder_regex_list != None: |
74 self.set_match_builders_pattern_list(builder_regex_list) | 87 self.set_match_builders_pattern_list(builder_regex_list) |
75 self._image_diff_db = imagediffdb.ImageDiffDB(generated_images_root) | 88 self._image_diff_db = imagediffdb.ImageDiffDB(generated_images_root) |
76 self._diff_base_url = ( | 89 self._diff_base_url = ( |
77 diff_base_url or | 90 diff_base_url or |
78 url_utils.create_filepath_url(generated_images_root)) | 91 download_actuals.create_filepath_url(generated_images_root)) |
79 self._actuals_root = actuals_root | 92 self._actuals_root = actuals_root |
80 self._expected_root = expected_root | 93 self._expected_root = expected_root |
81 self._ignore_failures_on_these_tests = [] | 94 self._ignore_failures_on_these_tests = [] |
82 if ignore_failures_file: | 95 if ignore_failures_file: |
83 self._ignore_failures_on_these_tests = ( | 96 self._ignore_failures_on_these_tests = ( |
84 ExpectationComparisons._read_noncomment_lines( | 97 ExpectationComparisons._read_noncomment_lines( |
85 os.path.join(expected_root, ignore_failures_file))) | 98 os.path.join(expected_root, ignore_failures_file))) |
86 self._load_actual_and_expected() | 99 self._load_actual_and_expected() |
87 self._timestamp = int(time.time()) | 100 self._timestamp = int(time.time()) |
88 logging.info('Results complete; took %d seconds.' % | 101 logging.info('Results complete; took %d seconds.' % |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 expected_root=args.expectations, | 395 expected_root=args.expectations, |
383 ignore_failures_file=args.ignore_failures_file, | 396 ignore_failures_file=args.ignore_failures_file, |
384 generated_images_root=args.workdir) | 397 generated_images_root=args.workdir) |
385 gm_json.WriteToFile( | 398 gm_json.WriteToFile( |
386 results_obj.get_packaged_results_of_type(results_type=args.results), | 399 results_obj.get_packaged_results_of_type(results_type=args.results), |
387 args.outfile) | 400 args.outfile) |
388 | 401 |
389 | 402 |
390 if __name__ == '__main__': | 403 if __name__ == '__main__': |
391 main() | 404 main() |
OLD | NEW |