1# Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2# 3# Use of this source code is governed by a BSD-style license 4# that can be found in the LICENSE file in the root of the source 5# tree. An additional intellectual property rights grant can be found 6# in the file PATENTS. All contributing project authors may 7# be found in the AUTHORS file in the root of the source tree. 8 9 10def _CommonChecks(input_api, output_api): 11 results = [] 12 13 # Run Pylint over the files in the directory. 14 pylint_checks = input_api.canned_checks.GetPylint(input_api, output_api) 15 results.extend(input_api.RunTests(pylint_checks)) 16 17 # Run the MB unittests. 18 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( 19 input_api, output_api, '.', [ r'^.+_unittest\.py$'])) 20 21 # Validate the format of the mb_config.pyl file. 22 cmd = [input_api.python_executable, 'mb.py', 'validate'] 23 kwargs = {'cwd': input_api.PresubmitLocalPath()} 24 results.extend(input_api.RunTests([ 25 input_api.Command(name='mb_validate', 26 cmd=cmd, kwargs=kwargs, 27 message=output_api.PresubmitError)])) 28 29 results.extend( 30 input_api.canned_checks.CheckLongLines( 31 input_api, 32 output_api, 33 maxlen=80, 34 source_file_filter=lambda x: 'mb_config.pyl' in x.LocalPath())) 35 36 return results 37 38 39def CheckChangeOnUpload(input_api, output_api): 40 return _CommonChecks(input_api, output_api) 41 42 43def CheckChangeOnCommit(input_api, output_api): 44 return _CommonChecks(input_api, output_api) 45