Add presubmit to avoid .in files in corpus
This CL adds a presubmit check so .in files are not added to corpus.
Change-Id: If99d93d4084fdbb871b5df5e788f4e28f244755b
Reviewed-on: https://pdfium-review.googlesource.com/6990
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 2184d0b..9e6999c 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -8,10 +8,21 @@
for more details about the presubmit API built into depot_tools.
"""
+def _CheckNoIn(input_api, output_api):
+ """Checks that corpus tests don't contain .in files. Corpus tests should be
+ .pdf files, having both can cause race conditions on the bots, which run the
+ tests in parallel.
+ """
+ results = []
+ for f in input_api.AffectedFiles(include_deletes=False):
+ if f.LocalPath().endswith('.in'):
+ results.append(output_api.PresubmitError(
+ 'Remove %s since corpus tests should not use .in files' % f.LocalPath()))
+ return results
+
def _CheckPngNames(input_api, output_api):
"""Checks that .png files have the right file name pattern"""
- import re
- png_regex = re.compile('.+_expected(_(win|mac|linux))?\.pdf\.\d+.png')
+ png_regex = input_api.re.compile('.+_expected(_(win|mac|linux))?\.pdf\.\d+.png')
warnings = []
for f in input_api.AffectedFiles(include_deletes=False):
local_path = f.LocalPath()
@@ -26,8 +37,8 @@
warnings))
return results
-
def CheckChangeOnUpload(input_api, output_api):
results = []
results += _CheckPngNames(input_api, output_api)
+ results += _CheckNoIn(input_api, output_api)
return results