diff options
author | Nicolas Pena <npm@chromium.org> | 2017-05-19 15:59:49 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-19 20:47:17 +0000 |
commit | d824a90b6fc908020d8f264447fd348c7ffe72c5 (patch) | |
tree | 5173b1ee2befb43154e6ba25a66561090bfc4ff7 | |
parent | 76020fc9751e55661d1c01b6cd92dfcb1fd56e6a (diff) | |
download | pdfium-d824a90b6fc908020d8f264447fd348c7ffe72c5.tar.xz |
Add test duplicate check in presubmit
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 <thestig@chromium.org>
Commit-Queue: Nicolás Peña <npm@chromium.org>
-rw-r--r-- | PRESUBMIT.py | 28 |
1 files changed, 28 insertions, 0 deletions
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 |