From c4479c5d68e91a1b0a8d610ba1063aff7c27f5de Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Mon, 26 Jun 2017 11:45:06 -0400 Subject: Add presubmit check for png files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Commit-Queue: Nicolás Peña --- PRESUBMIT.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'PRESUBMIT.py') 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 -- cgit v1.2.3