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