summaryrefslogtreecommitdiff
path: root/testing/tools/test_runner.py
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2017-10-25 17:31:13 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-10-25 21:42:45 +0000
commit06673ede2dda783187fb05f9a97d0bec2f34dd32 (patch)
tree93be59d46c54aff5a5df6b7046f2d9cddf1cf9c5 /testing/tools/test_runner.py
parent5614d119e91264c428396f9eb84afea866011fca (diff)
downloadpdfium-06673ede2dda783187fb05f9a97d0bec2f34dd32.tar.xz
Add --regenerate_expected option to test_runner.py.chromium/3250
After a change in rendering, corpus and pixel test expected pngs need to be regenerated manually. This option reduces the toil by automating renaming and moving the new expected files over the old ones. Change-Id: I9d490369ccf946d4d4567e440b7b5252469eec46 Reviewed-on: https://pdfium-review.googlesource.com/16451 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
Diffstat (limited to 'testing/tools/test_runner.py')
-rw-r--r--testing/tools/test_runner.py32
1 files changed, 20 insertions, 12 deletions
diff --git a/testing/tools/test_runner.py b/testing/tools/test_runner.py
index 86e05636ab..ea8f2b8eaf 100644
--- a/testing/tools/test_runner.py
+++ b/testing/tools/test_runner.py
@@ -81,6 +81,11 @@ class TestRunner:
if actual_images:
if self.image_differ.HasDifferences(input_filename, source_dir,
self.working_dir):
+ if (self.options.regenerate_expected
+ and not self.test_suppressor.IsResultSuppressed(input_filename)
+ and not self.test_suppressor.IsImageDiffSuppressed(input_filename)):
+ self.image_differ.Regenerate(input_filename, source_dir,
+ self.working_dir)
return False, results
else:
if (self.enforce_expected_images
@@ -171,12 +176,15 @@ class TestRunner:
parser.add_option('--gold_ignore_hashes', default='', dest="gold_ignore_hashes",
help='Path to a file with MD5 hashes we wish to ignore.')
+ parser.add_option('--regenerate_expected', action="store_true", dest="regenerate_expected",
+ help='Regenerates expected images.')
+
parser.add_option('--ignore_errors', action="store_true", dest="ignore_errors",
help='Prevents the return value from being non-zero when image comparison fails.')
- options, args = parser.parse_args()
+ self.options, self.args = parser.parse_args()
- finder = common.DirectoryFinder(options.build_dir)
+ finder = common.DirectoryFinder(self.options.build_dir)
self.fixup_path = finder.ScriptPath('fixup_pdf_template.py')
self.text_diff_path = finder.ScriptPath('text_diff.py')
@@ -206,8 +214,8 @@ class TestRunner:
self.test_cases = []
self.execution_suppressed_cases = []
input_file_re = re.compile('^.+[.](in|pdf)$')
- if args:
- for file_name in args:
+ if self.args:
+ for file_name in self.args:
file_name.replace('.pdf', '.in')
input_path = os.path.join(walk_from_dir, file_name)
if not os.path.isfile(input_path):
@@ -233,16 +241,16 @@ class TestRunner:
# Collect Gold results if an output directory was named.
self.gold_results = None
- if options.gold_output_dir:
+ if self.options.gold_output_dir:
self.gold_results = gold.GoldResults('pdfium',
- options.gold_output_dir,
- options.gold_properties,
- options.gold_key,
- options.gold_ignore_hashes)
+ self.options.gold_output_dir,
+ self.options.gold_properties,
+ self.options.gold_key,
+ self.options.gold_ignore_hashes)
- if options.num_workers > 1 and len(self.test_cases) > 1:
+ if self.options.num_workers > 1 and len(self.test_cases) > 1:
try:
- pool = multiprocessing.Pool(options.num_workers)
+ pool = multiprocessing.Pool(self.options.num_workers)
worker_func = functools.partial(TestOneFileParallel, self)
worker_results = pool.imap(worker_func, self.test_cases)
@@ -282,7 +290,7 @@ class TestRunner:
self._PrintSummary()
if self.failures:
- if not options.ignore_errors:
+ if not self.options.ignore_errors:
return 1
return 0