summaryrefslogtreecommitdiff
path: root/testing/tools
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-10-10 23:18:14 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-10 23:18:14 +0000
commit40be505a7023925a65ec905865df3a5b42dd427d (patch)
tree990aea4fefd02a3b28c32c142af2069c4f6d5f4b /testing/tools
parent673b90ad5b21a3d17e64ef65d7053d582920fcbe (diff)
downloadpdfium-40be505a7023925a65ec905865df3a5b42dd427d.tar.xz
Use optipng to optimize expected .pngs when regenerating them.
Bug: pdfium:1127 Change-Id: I5371ecf6f704761320a021fbee07a79839fb80b7 Reviewed-on: https://pdfium-review.googlesource.com/c/43810 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'testing/tools')
-rwxr-xr-xtesting/tools/pngdiffer.py9
-rw-r--r--testing/tools/test_runner.py5
2 files changed, 14 insertions, 0 deletions
diff --git a/testing/tools/pngdiffer.py b/testing/tools/pngdiffer.py
index f40cc2596f..baed33be0c 100755
--- a/testing/tools/pngdiffer.py
+++ b/testing/tools/pngdiffer.py
@@ -3,6 +3,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import distutils.spawn
import itertools
import os
import shutil
@@ -15,6 +16,13 @@ class PNGDiffer():
self.pdfium_diff_path = finder.ExecutablePath('pdfium_diff')
self.os_name = finder.os_name
+ def CheckMissingTools(self, regenerate_expected):
+ if (regenerate_expected and
+ self.os_name == 'linux' and
+ not distutils.spawn.find_executable('optipng')):
+ return 'Please install "optipng" to regenerate expected images.'
+ return None
+
def GetActualFiles(self, input_filename, source_dir, working_dir):
actual_paths = []
path_templates = PathTemplates(input_filename, source_dir, working_dir)
@@ -93,6 +101,7 @@ class PNGDiffer():
continue
shutil.copyfile(actual_path, expected_path)
+ common.RunCommand(['optipng', expected_path])
ACTUAL_TEMPLATE = '.pdf.%d.png'
diff --git a/testing/tools/test_runner.py b/testing/tools/test_runner.py
index 43dc578a90..7dea24299a 100644
--- a/testing/tools/test_runner.py
+++ b/testing/tools/test_runner.py
@@ -256,6 +256,11 @@ class TestRunner:
'--show-config'])
self.test_suppressor = suppressor.Suppressor(finder, self.feature_string)
self.image_differ = pngdiffer.PNGDiffer(finder)
+ error_message = self.image_differ.CheckMissingTools(
+ self.options.regenerate_expected)
+ if error_message:
+ print "FAILURE: %s" % error_message
+ return 1
self.gold_baseline = gold.GoldBaseline(self.options.gold_properties)