[email protected] | e615e9c | 2012-03-07 21:39:00 | [diff] [blame] | 1 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | """Top-level presubmit script for testing. |
| 6 | |
tfarina | 78bb92f4 | 2015-01-31 00:20:48 | [diff] [blame] | 7 | See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 8 | for more details on the presubmit API built into depot_tools. |
[email protected] | e615e9c | 2012-03-07 21:39:00 | [diff] [blame] | 9 | """ |
| 10 | |
Josip Sokcevic | 3d5cd73 | 2021-06-14 17:59:57 | [diff] [blame] | 11 | USE_PYTHON3 = True |
| 12 | |
[email protected] | e615e9c | 2012-03-07 21:39:00 | [diff] [blame] | 13 | |
| 14 | def CommonChecks(input_api, output_api): |
Brian Sheedy | 75fc515 | 2021-06-28 20:07:13 | [diff] [blame] | 15 | testing_env = dict(input_api.environ) |
Brian Sheedy | 75fc515 | 2021-06-28 20:07:13 | [diff] [blame] | 16 | testing_env.update({ |
Brian Sheedy | 20b6368e | 2021-07-15 00:17:10 | [diff] [blame] | 17 | 'PYTHONPATH': input_api.PresubmitLocalPath(), |
Brian Sheedy | 75fc515 | 2021-06-28 20:07:13 | [diff] [blame] | 18 | 'PYTHONDONTWRITEBYTECODE': '1', |
| 19 | }) |
| 20 | |
[email protected] | e615e9c | 2012-03-07 21:39:00 | [diff] [blame] | 21 | output = [] |
Ilia Samsonov | a0083530 | 2019-04-19 17:37:59 | [diff] [blame] | 22 | output.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
Joshua Hood | 7827f5f0 | 2022-03-01 16:31:00 | [diff] [blame] | 23 | input_api, |
| 24 | output_api, |
| 25 | '.', |
Sebastien Lalancette | 53ef7d3 | 2022-04-26 20:53:45 | [diff] [blame] | 26 | [r'^.+_unittest\.py$'])) |
Brian Sheedy | 75fc515 | 2021-06-28 20:07:13 | [diff] [blame] | 27 | output.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
| 28 | input_api, |
| 29 | output_api, |
| 30 | input_api.os_path.join(input_api.PresubmitLocalPath(), |
| 31 | 'unexpected_passes_common'), |
| 32 | [r'^.+_unittest\.py$'], |
Joshua Hood | 330454c7 | 2022-03-09 17:59:03 | [diff] [blame] | 33 | env=testing_env, |
| 34 | run_on_python3=USE_PYTHON3, |
| 35 | skip_shebang_check=True)) |
[email protected] | e615e9c | 2012-03-07 21:39:00 | [diff] [blame] | 36 | output.extend(input_api.canned_checks.RunPylint( |
Joshua Hood | 7827f5f0 | 2022-03-01 16:31:00 | [diff] [blame] | 37 | input_api, |
| 38 | output_api, |
Sebastien Lalancette | 53ef7d3 | 2022-04-26 20:53:45 | [diff] [blame] | 39 | files_to_skip=[r'gmock.*', r'gtest.*', |
| 40 | r'buildbot.*', r'merge_scripts.*', r'trigger_scripts.*', |
| 41 | r'unexpected_passes_common.*', |
| 42 | r'clusterfuzz.*', |
| 43 | r'libfuzzer.*'])) |
| 44 | # Pylint2.7 is run on subdirs whose presubmit checks are migrated to Python3 |
| 45 | output.extend(input_api.canned_checks.RunPylint( |
| 46 | input_api, |
| 47 | output_api, |
| 48 | files_to_check=[r'buildbot.*\.py$', |
| 49 | r'merge_scripts.*\.py$', |
| 50 | r'trigger_scripts.*\.py$', |
| 51 | r'unexpected_passes_common.*\.py$', |
| 52 | r'clusterfuzz.*\.py$', |
| 53 | r'libfuzzer.*\.py$'], |
Joshua Hood | 7827f5f0 | 2022-03-01 16:31:00 | [diff] [blame] | 54 | version='2.7')) |
| 55 | |
[email protected] | e615e9c | 2012-03-07 21:39:00 | [diff] [blame] | 56 | return output |
| 57 | |
| 58 | |
| 59 | def CheckChangeOnUpload(input_api, output_api): |
| 60 | return CommonChecks(input_api, output_api) |
| 61 | |
| 62 | |
| 63 | def CheckChangeOnCommit(input_api, output_api): |
| 64 | return CommonChecks(input_api, output_api) |