| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
| 3 | 3 |
| 4 from __future__ import print_function | 4 from __future__ import print_function |
| 5 import argparse | 5 import argparse |
| 6 import BaseHTTPServer | 6 import BaseHTTPServer |
| 7 import json | 7 import json |
| 8 import os | 8 import os |
| 9 import os.path | 9 import os.path |
| 10 import re | 10 import re |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 skpdiff_path = None | 61 skpdiff_path = None |
| 62 possible_paths = [] | 62 possible_paths = [] |
| 63 | 63 |
| 64 # Use the user given path, or try out some good default paths. | 64 # Use the user given path, or try out some good default paths. |
| 65 if user_path: | 65 if user_path: |
| 66 possible_paths.append(user_path) | 66 possible_paths.append(user_path) |
| 67 else: | 67 else: |
| 68 possible_paths.append(os.path.join(SKIA_ROOT_DIR, 'out', | 68 possible_paths.append(os.path.join(SKIA_ROOT_DIR, 'out', |
| 69 'Release', 'skpdiff')) | 69 'Release', 'skpdiff')) |
| 70 possible_paths.append(os.path.join(SKIA_ROOT_DIR, 'out', | 70 possible_paths.append(os.path.join(SKIA_ROOT_DIR, 'out', |
| 71 'Release', 'skpdiff.exe')) |
| 72 possible_paths.append(os.path.join(SKIA_ROOT_DIR, 'out', |
| 71 'Debug', 'skpdiff')) | 73 'Debug', 'skpdiff')) |
| 74 possible_paths.append(os.path.join(SKIA_ROOT_DIR, 'out', |
| 75 'Debug', 'skpdiff.exe')) |
| 72 # Use the first path that actually points to the binary | 76 # Use the first path that actually points to the binary |
| 73 for possible_path in possible_paths: | 77 for possible_path in possible_paths: |
| 74 if os.path.isfile(possible_path): | 78 if os.path.isfile(possible_path): |
| 75 skpdiff_path = possible_path | 79 skpdiff_path = possible_path |
| 76 break | 80 break |
| 77 | 81 |
| 78 # If skpdiff was not found, print out diagnostic info for the user. | 82 # If skpdiff was not found, print out diagnostic info for the user. |
| 79 if skpdiff_path is None: | 83 if skpdiff_path is None: |
| 80 print('Could not find skpdiff binary. Either build it into the ' + | 84 print('Could not find skpdiff binary. Either build it into the ' + |
| 81 'default directory, or specify the path on the command line.') | 85 'default directory, or specify the path on the command line.') |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 156 |
| 153 def get_head_version(path): | 157 def get_head_version(path): |
| 154 """Get the version of the file at the given path stored inside the HEAD of | 158 """Get the version of the file at the given path stored inside the HEAD of |
| 155 the git repository. It is returned as a string. | 159 the git repository. It is returned as a string. |
| 156 | 160 |
| 157 @param path The path of the file whose HEAD is returned. It is assumed the | 161 @param path The path of the file whose HEAD is returned. It is assumed the |
| 158 path is inside a git repo rooted at SKIA_ROOT_DIR. | 162 path is inside a git repo rooted at SKIA_ROOT_DIR. |
| 159 """ | 163 """ |
| 160 | 164 |
| 161 # git-show will not work with absolute paths. This ensures we give it a path | 165 # git-show will not work with absolute paths. This ensures we give it a path |
| 162 # relative to the skia root. | 166 # relative to the skia root. This path also has to use forward slashes, even |
| 163 git_path = os.path.relpath(path, SKIA_ROOT_DIR) | 167 # on windows. |
| 168 git_path = os.path.relpath(path, SKIA_ROOT_DIR).replace('\\', '/') |
| 164 git_show_proc = subprocess.Popen(['git', 'show', 'HEAD:' + git_path], | 169 git_show_proc = subprocess.Popen(['git', 'show', 'HEAD:' + git_path], |
| 165 stdout=subprocess.PIPE) | 170 stdout=subprocess.PIPE) |
| 166 | 171 |
| 167 # When invoked outside a shell, git will output the last committed version | 172 # When invoked outside a shell, git will output the last committed version |
| 168 # of the file directly to stdout. | 173 # of the file directly to stdout. |
| 169 git_version_content, _ = git_show_proc.communicate() | 174 git_version_content, _ = git_show_proc.communicate() |
| 170 return git_version_content | 175 return git_version_content |
| 171 | 176 |
| 172 | 177 |
| 173 class GMInstance: | 178 class GMInstance: |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 - determine which GMs changed | 219 - determine which GMs changed |
| 215 - download the changed images | 220 - download the changed images |
| 216 - compare them with skpdiff | 221 - compare them with skpdiff |
| 217 """ | 222 """ |
| 218 | 223 |
| 219 # Get the expectations and compare them with actual hashes | 224 # Get the expectations and compare them with actual hashes |
| 220 self._get_expectations() | 225 self._get_expectations() |
| 221 | 226 |
| 222 | 227 |
| 223 # Create a temporary file tree that makes sense for skpdiff to operate | 228 # Create a temporary file tree that makes sense for skpdiff to operate |
| 224 # on. | 229 # on. We take the realpath of the new temp directory because some OSs |
| 225 image_output_dir = tempfile.mkdtemp('skpdiff') | 230 # (*cough* osx) put the temp directory behind a symlink that gets |
| 231 # resolved later down the pipeline and breaks the image map. |
| 232 image_output_dir = os.path.realpath(tempfile.mkdtemp('skpdiff')) |
| 226 expected_image_dir = os.path.join(image_output_dir, 'expected') | 233 expected_image_dir = os.path.join(image_output_dir, 'expected') |
| 227 actual_image_dir = os.path.join(image_output_dir, 'actual') | 234 actual_image_dir = os.path.join(image_output_dir, 'actual') |
| 228 os.mkdir(expected_image_dir) | 235 os.mkdir(expected_image_dir) |
| 229 os.mkdir(actual_image_dir) | 236 os.mkdir(actual_image_dir) |
| 230 | 237 |
| 231 # Download expected and actual images that differed into the temporary | 238 # Download expected and actual images that differed into the temporary |
| 232 # file tree. | 239 # file tree. |
| 233 self._download_expectation_images(expected_image_dir, actual_image_dir) | 240 self._download_expectation_images(expected_image_dir, actual_image_dir) |
| 234 | 241 |
| 235 # Invoke skpdiff with our downloaded images and place its results in the | 242 # Invoke skpdiff with our downloaded images and place its results in the |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 | 571 |
| 565 expectations_manager = ExpectationsManager(args['expectations_dir'], | 572 expectations_manager = ExpectationsManager(args['expectations_dir'], |
| 566 args['expected'], | 573 args['expected'], |
| 567 args['updated'], | 574 args['updated'], |
| 568 skpdiff_path) | 575 skpdiff_path) |
| 569 | 576 |
| 570 run_server(expectations_manager, port=args['port']) | 577 run_server(expectations_manager, port=args['port']) |
| 571 | 578 |
| 572 if __name__ == '__main__': | 579 if __name__ == '__main__': |
| 573 main() | 580 main() |
| OLD | NEW |