From d824a90b6fc908020d8f264447fd348c7ffe72c5 Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Fri, 19 May 2017 15:59:49 -0400 Subject: Add test duplicate check in presubmit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL adds a presubmit check to avoid adding both .in and .pdf file to javascript and pixel tests. Change-Id: If2f252d20c3bfd3f9cd5963bb3428b57f6bee1b5 Reviewed-on: https://pdfium-review.googlesource.com/5710 Reviewed-by: Lei Zhang Commit-Queue: Nicolás Peña --- PRESUBMIT.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'PRESUBMIT.py') diff --git a/PRESUBMIT.py b/PRESUBMIT.py index db1bf00eb3..26d559a33f 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -249,6 +249,33 @@ def _CheckIncludeOrder(input_api, output_api): warnings)) return results +def _CheckTestDuplicates(input_api, output_api): + """Checks that pixel and javascript tests don't contain duplicates. + We use .in and .pdf files, having both can cause race conditions on the bots, + which run the tests in parallel. + """ + tests_added = [] + results = [] + for f in input_api.AffectedFiles(): + if not f.LocalPath().startswith(('testing/resources/pixel/', + 'testing/resources/javascript/')): + continue + end_len = 0 + if f.LocalPath().endswith('.in'): + end_len = 3 + elif f.LocalPath().endswith('.pdf'): + end_len = 4 + else: + continue + path = f.LocalPath()[:-end_len]; + if path in tests_added: + results.append(output_api.PresubmitError( + 'Remove %s to prevent shadowing %s' % (path + '.pdf', + path + '.in'))) + else: + tests_added.append(path) + return results + def CheckChangeOnUpload(input_api, output_api): results = [] @@ -257,5 +284,6 @@ def CheckChangeOnUpload(input_api, output_api): results += input_api.canned_checks.CheckChangeLintsClean( input_api, output_api, None, LINT_FILTERS) results += _CheckIncludeOrder(input_api, output_api) + results += _CheckTestDuplicates(input_api, output_api) return results -- cgit v1.2.3