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