blob: 021592a729d914ed9228adeff998d3e1bd4727f8 [file] [log] [blame]
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Top-level presubmit script for blimp.
for more details about the presubmit API built into depot_tools.
import re
def CheckChangeLintsClean(input_api, output_api):
source_filter = lambda x: input_api.FilterSourceFile(
x, white_list=BLIMP_SOURCE_FILES, black_list=None)
return input_api.canned_checks.CheckChangeLintsClean(
input_api, output_api, source_filter, lint_filters=[], verbose_level=1)
def CheckNewFilesHaveTests(input_api, output_api):
unittest_files = set()
files_needing_unittest = set()
for source_file in input_api.AffectedFiles():
if source_file.Action() == 'A':
name = source_file.LocalPath()
if name.endswith(''):
elif name.endswith('.cc') and not name.endswith(''):
missing_unittest_files = []
for name in files_needing_unittest:
unittest_name = re.sub(r'\.cc$', '', name)
if unittest_name not in unittest_files:
if missing_unittest_files:
message = 'The following new files are missing unit tests:'
return [output_api.PresubmitPromptWarning(message, missing_unittest_files)]
return []
def CheckChangeOnUpload(input_api, output_api):
results = []
results += CheckChangeLintsClean(input_api, output_api)
results += CheckNewFilesHaveTests(input_api, output_api)
return results