summaryrefslogtreecommitdiff
path: root/PRESUBMIT.py
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2017-06-26 11:45:06 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-06-26 16:23:13 +0000
commitc4479c5d68e91a1b0a8d610ba1063aff7c27f5de (patch)
treee1b1f4a5f1bdd0ece71b544f70d13d00690c5cf3 /PRESUBMIT.py
parentb9776c71718bba353225e6a2010cf0ab1e926658 (diff)
downloadpdfium-c4479c5d68e91a1b0a8d610ba1063aff7c27f5de.tar.xz
Add presubmit check for png files
This CL adds a presubmit check for png files so that they are in the form _expected{,_mac,_win}.pdf.BLA.png and updates the corpus test repository hash. Change-Id: I5397a091b77a339eba7d370b291b7a6e61754744 Reviewed-on: https://pdfium-review.googlesource.com/6951 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'PRESUBMIT.py')
-rw-r--r--PRESUBMIT.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 26d559a33f..e8d8458ec0 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -267,7 +267,7 @@ def _CheckTestDuplicates(input_api, output_api):
end_len = 4
else:
continue
- path = f.LocalPath()[:-end_len];
+ path = f.LocalPath()[:-end_len]
if path in tests_added:
results.append(output_api.PresubmitError(
'Remove %s to prevent shadowing %s' % (path + '.pdf',
@@ -276,6 +276,21 @@ def _CheckTestDuplicates(input_api, output_api):
tests_added.append(path)
return results
+def _CheckPNGFormat(input_api, output_api):
+ """Checks that .png files have a format that will be considered valid by our
+ test runners. If a file ends with .png, then it must be of the form
+ NAME_expected{,mac,win}.pdf.#.png"""
+ expected_pattern = input_api.re.compile(
+ r'.*_expected(_(mac|win))?\.pdf\..*\.png')
+ results = []
+ for f in input_api.AffectedFiles():
+ if not f.LocalPath().endswith('.png'):
+ continue
+ if expected_pattern.match(f.LocalPath()):
+ continue
+ results.append(output_api.PresubmitError(
+ 'PNG file %s does not have the correct format' % f.LocalPath()))
+ return results
def CheckChangeOnUpload(input_api, output_api):
results = []
@@ -285,5 +300,6 @@ def CheckChangeOnUpload(input_api, output_api):
input_api, output_api, None, LINT_FILTERS)
results += _CheckIncludeOrder(input_api, output_api)
results += _CheckTestDuplicates(input_api, output_api)
+ results += _CheckPNGFormat(input_api, output_api)
return results