[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( |
| 23 | input_api, output_api, '.', [r'^.+_unittest\.py$'])) |
Brian Sheedy | 75fc515 | 2021-06-28 20:07:13 | [diff] [blame] | 24 | output.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
| 25 | input_api, |
| 26 | output_api, |
| 27 | input_api.os_path.join(input_api.PresubmitLocalPath(), |
| 28 | 'unexpected_passes_common'), |
| 29 | [r'^.+_unittest\.py$'], |
| 30 | env=testing_env)) |
[email protected] | e615e9c | 2012-03-07 21:39:00 | [diff] [blame] | 31 | output.extend(input_api.canned_checks.RunPylint( |
Ben Pastene | 4b514ab | 2020-09-16 01:07:13 | [diff] [blame] | 32 | input_api, output_api, files_to_skip=[r'gmock.*', r'gtest.*'])) |
[email protected] | e615e9c | 2012-03-07 21:39:00 | [diff] [blame] | 33 | return output |
| 34 | |
| 35 | |
| 36 | def CheckChangeOnUpload(input_api, output_api): |
| 37 | return CommonChecks(input_api, output_api) |
| 38 | |
| 39 | |
| 40 | def CheckChangeOnCommit(input_api, output_api): |
| 41 | return CommonChecks(input_api, output_api) |