Christoffer Jansson | 4e8a773 | 2022-02-08 09:01:12 +0100 | [diff] [blame] | 1 | #!/usr/bin/env vpython3 |
| 2 | |
kjellander | a013a02 | 2016-11-14 05:54:22 -0800 | [diff] [blame] | 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 | |
Christoffer Jansson | 4e8a773 | 2022-02-08 09:01:12 +0100 | [diff] [blame] | 12 | # Runs PRESUBMIT.py in py3 mode by git cl presubmit. |
| 13 | USE_PYTHON3 = True |
| 14 | |
| 15 | |
kjellander | a013a02 | 2016-11-14 05:54:22 -0800 | [diff] [blame] | 16 | def _CommonChecks(input_api, output_api): |
| 17 | results = [] |
| 18 | |
kjellander | a013a02 | 2016-11-14 05:54:22 -0800 | [diff] [blame] | 19 | # Run the MB unittests. |
Christoffer Jansson | 4e8a773 | 2022-02-08 09:01:12 +0100 | [diff] [blame] | 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)) |
kjellander | a013a02 | 2016-11-14 05:54:22 -0800 | [diff] [blame] | 27 | |
| 28 | # Validate the format of the mb_config.pyl file. |
Christoffer Jansson | 4e8a773 | 2022-02-08 09:01:12 +0100 | [diff] [blame] | 29 | cmd = [input_api.python3_executable, 'mb.py', 'validate'] |
kjellander | a013a02 | 2016-11-14 05:54:22 -0800 | [diff] [blame] | 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 | |
| 46 | def CheckChangeOnUpload(input_api, output_api): |
| 47 | return _CommonChecks(input_api, output_api) |
| 48 | |
| 49 | |
| 50 | def CheckChangeOnCommit(input_api, output_api): |
| 51 | return _CommonChecks(input_api, output_api) |