diff options
author | Lei Zhang <thestig@chromium.org> | 2015-10-09 13:49:17 -0700 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-10-09 13:49:17 -0700 |
commit | 6f3c2ffd369af00e1a4f0ac5413b816f464cba78 (patch) | |
tree | 23e91ac9d6ef93f9dc02d7da47057e23a80a6932 /testing/tools/pngdiffer.py | |
parent | 79c38e39d5094b03bfddd80dd39a666a96bbcdcc (diff) | |
download | pdfium-6f3c2ffd369af00e1a4f0ac5413b816f464cba78.tar.xz |
Merge to XFA: Parallelize run_corpus_tests.py.
- Use the number of cores as the default -j value
- Fall back to old code for -j 1
TBR=nparker@chromium.org
Review URL: https://codereview.chromium.org/1398793003 .
(cherry picked from commit fd751f28cecce61ab36038799043639d570e0b26)
Review URL: https://codereview.chromium.org/1395253002 .
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): |