From 6f3c2ffd369af00e1a4f0ac5413b816f464cba78 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 9 Oct 2015 13:49:17 -0700 Subject: 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 . --- testing/tools/pngdiffer.py | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) (limited to 'testing/tools/pngdiffer.py') 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): -- cgit v1.2.3