diff options
Diffstat (limited to 'testing/tools/pngdiffer.py')
-rwxr-xr-x | testing/tools/pngdiffer.py | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/testing/tools/pngdiffer.py b/testing/tools/pngdiffer.py index 35eaaa437a..bef252674f 100755 --- a/testing/tools/pngdiffer.py +++ b/testing/tools/pngdiffer.py @@ -4,9 +4,10 @@ # found in the LICENSE file. import os -import subprocess import sys +import common + class PNGDiffer(): ACTUAL_TEMPLATE = '.pdf.%d.png' EXPECTED_TEMPLATE = '_expected' + ACTUAL_TEMPLATE @@ -37,33 +38,33 @@ class PNGDiffer(): i += 1 return actual_paths - def HasDifferences(self, input_filename, source_dir, working_dir): + def HasDifferences(self, input_filename, source_dir, working_dir, + redirect_output=False): template_paths = self._GetTemplatePaths( input_filename, source_dir, working_dir) actual_path_template = template_paths[0]; expected_path_template = template_paths[1] platform_expected_path_template = template_paths[2] i = 0 - try: - while True: - actual_path = actual_path_template % i - expected_path = expected_path_template % i - platform_expected_path = ( - platform_expected_path_template % (self.os_name, i)) - if os.path.exists(platform_expected_path): - expected_path = platform_expected_path - elif not os.path.exists(expected_path): - if i == 0: - print "WARNING: no expected results files for " + input_filename - break - print "Checking " + actual_path - sys.stdout.flush() - subprocess.check_call( - [self.pdfium_diff_path, expected_path, actual_path]) - i += 1 - except subprocess.CalledProcessError as e: - print "FAILURE: " + input_filename + "; " + str(e) - return True + while True: + actual_path = actual_path_template % i + expected_path = expected_path_template % i + platform_expected_path = ( + platform_expected_path_template % (self.os_name, i)) + if os.path.exists(platform_expected_path): + expected_path = platform_expected_path + elif not os.path.exists(expected_path): + if i == 0: + print "WARNING: no expected results files for " + input_filename + break + print "Checking " + actual_path + sys.stdout.flush() + error = common.RunCommand( + [self.pdfium_diff_path, expected_path, actual_path], redirect_output) + if error: + print "FAILURE: " + input_filename + "; " + str(error) + return True + i += 1 return False def _GetTemplatePaths(self, input_filename, source_dir, working_dir): |