summaryrefslogtreecommitdiff
path: root/testing/tools
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2017-10-26 11:22:52 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-10-26 15:36:06 +0000
commit352e251c6af1f2a3c2eca24468f98eae30099185 (patch)
treea529bc3eccb5f678311c4f007e3377aa6a9af785 /testing/tools
parent53d443f042b590ae2d920def16bc9daf66f8427d (diff)
downloadpdfium-352e251c6af1f2a3c2eca24468f98eae30099185.tar.xz
Add option to regenerate only platform-specific expected pngs.
Change-Id: Id4798fe9a4d297678a76d0511cde7fecbf130e3e Reviewed-on: https://pdfium-review.googlesource.com/16613 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
Diffstat (limited to 'testing/tools')
-rwxr-xr-xtesting/tools/pngdiffer.py11
-rw-r--r--testing/tools/test_runner.py34
2 files changed, 32 insertions, 13 deletions
diff --git a/testing/tools/pngdiffer.py b/testing/tools/pngdiffer.py
index 95acb198a6..a9bc9d6529 100755
--- a/testing/tools/pngdiffer.py
+++ b/testing/tools/pngdiffer.py
@@ -66,7 +66,7 @@ class PNGDiffer():
i += 1
return False
- def Regenerate(self, input_filename, source_dir, working_dir):
+ def Regenerate(self, input_filename, source_dir, working_dir, platform_only):
path_templates = PathTemplates(input_filename, source_dir, working_dir)
page = 0
@@ -81,13 +81,16 @@ class PNGDiffer():
self.os_name, page)
# If there is a platform expected png, we will overwrite it. Otherwise,
- # overwrite the generic png.
+ # overwrite the generic png in "all" mode, or do nothing in "platform"
+ # mode.
if os.path.exists(platform_expected_path):
expected_path = platform_expected_path
- else:
+ elif not platform_only:
expected_path = path_templates.GetExpectedPath(page)
+ else:
+ expected_path = None
- if os.path.exists(expected_path):
+ if expected_path is not None and os.path.exists(expected_path):
shutil.copyfile(actual_path, expected_path)
page += 1
diff --git a/testing/tools/test_runner.py b/testing/tools/test_runner.py
index ea8f2b8eaf..8921b2f005 100644
--- a/testing/tools/test_runner.py
+++ b/testing/tools/test_runner.py
@@ -84,8 +84,9 @@ class TestRunner:
if (self.options.regenerate_expected
and not self.test_suppressor.IsResultSuppressed(input_filename)
and not self.test_suppressor.IsImageDiffSuppressed(input_filename)):
+ platform_only = (self.options.regenerate_expected == 'platform')
self.image_differ.Regenerate(input_filename, source_dir,
- self.working_dir)
+ self.working_dir, platform_only)
return False, results
else:
if (self.enforce_expected_images
@@ -165,25 +166,40 @@ class TestRunner:
help='run NUM_WORKERS jobs in parallel')
parser.add_option('--gold_properties', default='', dest="gold_properties",
- help='Key value pairs that are written to the top level of the JSON file that is ingested by Gold.')
+ help='Key value pairs that are written to the top level '
+ 'of the JSON file that is ingested by Gold.')
parser.add_option('--gold_key', default='', dest="gold_key",
- help='Key value pairs that are added to the "key" field of the JSON file that is ingested by Gold.')
+ help='Key value pairs that are added to the "key" field '
+ 'of the JSON file that is ingested by Gold.')
parser.add_option('--gold_output_dir', default='', dest="gold_output_dir",
- help='Path of where to write the JSON output to be uploaded to Gold.')
+ help='Path of where to write the JSON output to be '
+ 'uploaded to Gold.')
- parser.add_option('--gold_ignore_hashes', default='', dest="gold_ignore_hashes",
+ 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('--regenerate_expected', default='',
+ dest="regenerate_expected",
+ help='Regenerates expected images. Valid values are '
+ '"all" to regenerate all expected pngs, and '
+ '"platform" to regenerate only platform-specific '
+ 'expected pngs.')
- parser.add_option('--ignore_errors', action="store_true", dest="ignore_errors",
- help='Prevents the return value from being non-zero when image comparison fails.')
+ parser.add_option('--ignore_errors', action="store_true",
+ dest="ignore_errors",
+ help='Prevents the return value from being non-zero '
+ 'when image comparison fails.')
self.options, self.args = parser.parse_args()
+ if (self.options.regenerate_expected
+ and self.options.regenerate_expected not in ['all', 'platform']) :
+ print 'FAILURE: --regenerate_expected must be "all" or "platform"'
+ return 1
+
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')