Avi Drissman | dfd88085 | 2022-09-15 20:11:09 | [diff] [blame] | 1 | # Copyright 2015 The Chromium Authors |
dpranke | 1d30631 | 2015-08-11 21:17:33 | [diff] [blame] | 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
Keren Zhu | c96dacd | 2021-06-29 00:03:44 | [diff] [blame] | 5 | |
Garrett Beaty | b97c9697 | 2024-01-02 22:25:17 | [diff] [blame] | 6 | PRESUBMIT_VERSION = '2.0.0' |
| 7 | |
dpranke | 1d30631 | 2015-08-11 21:17:33 | [diff] [blame] | 8 | |
Garrett Beaty | ac48e8c9 | 2021-12-14 01:28:48 | [diff] [blame] | 9 | def CheckFreeze(input_api, output_api): |
Garrett Beaty | ee19843 | 2024-01-25 00:08:41 | [diff] [blame] | 10 | return input_api.canned_checks.CheckInfraFreeze(input_api, output_api) |
Garrett Beaty | ac48e8c9 | 2021-12-14 01:28:48 | [diff] [blame] | 11 | |
| 12 | |
| 13 | def CheckTests(input_api, output_api): |
Garrett Beaty | b97c9697 | 2024-01-02 22:25:17 | [diff] [blame] | 14 | return input_api.RunTests( |
Takuto Ikuta | e108f10 | 2023-06-01 21:38:30 | [diff] [blame] | 15 | input_api.canned_checks.GetUnitTestsInDirectory(input_api, output_api, |
Jonathan Njeunje | e45f2bd | 2021-10-12 16:21:58 | [diff] [blame] | 16 | '.', |
Garrett Beaty | b97c9697 | 2024-01-02 22:25:17 | [diff] [blame] | 17 | [r'.+_(unit)?test\.py$'])) |
dpranke | 1d30631 | 2015-08-11 21:17:33 | [diff] [blame] | 18 | |
Garrett Beaty | b97c9697 | 2024-01-02 22:25:17 | [diff] [blame] | 19 | |
| 20 | def CheckPylint(input_api, output_api): |
| 21 | return input_api.canned_checks.RunPylint( |
| 22 | input_api, |
| 23 | output_api, |
| 24 | version='2.7', |
| 25 | # pylint complains about Checkfreeze not being defined, its probably |
| 26 | # finding a different PRESUBMIT.py. Note that this warning only |
| 27 | # appears if the number of Pylint jobs is greater than one. |
| 28 | files_to_skip=['PRESUBMIT_test.py'], |
| 29 | # Disabling this warning because this pattern involving ToSrcRelPath |
| 30 | # seems intrinsic to how mb_unittest.py is implemented. |
| 31 | disabled_warnings=[ |
| 32 | 'attribute-defined-outside-init', |
| 33 | ], |
| 34 | ) |
| 35 | |
| 36 | |
| 37 | def CheckMbValidate(input_api, output_api): |
Ben Pastene | d512e09 | 2022-04-29 21:48:51 | [diff] [blame] | 38 | cmd = [input_api.python3_executable, 'mb.py', 'validate'] |
dpranke | a3326787 | 2015-08-12 15:45:17 | [diff] [blame] | 39 | kwargs = {'cwd': input_api.PresubmitLocalPath()} |
Garrett Beaty | b97c9697 | 2024-01-02 22:25:17 | [diff] [blame] | 40 | return input_api.RunTests([ |
dpranke | a3326787 | 2015-08-12 15:45:17 | [diff] [blame] | 41 | input_api.Command(name='mb_validate', |
Erik Staab | ab20a09 | 2022-12-13 23:36:09 | [diff] [blame] | 42 | cmd=cmd, |
| 43 | kwargs=kwargs, |
Garrett Beaty | b97c9697 | 2024-01-02 22:25:17 | [diff] [blame] | 44 | message=output_api.PresubmitError), |
| 45 | ]) |