[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) |
| 16 | # TODO(crbug.com/1222826): Remove this path addition once all GPU-specific |
| 17 | # code is pulled out of the common code. |
| 18 | gpu_path = input_api.os_path.join( |
| 19 | input_api.PresubmitLocalPath(), '..', 'content', 'test', 'gpu') |
| 20 | testing_env.update({ |
Kyle Farnung | 24859c4 | 2021-07-08 23:02:35 | [diff] [blame] | 21 | 'PYTHONPATH': input_api.os_path.pathsep.join( |
| 22 | [input_api.PresubmitLocalPath(), gpu_path]), |
Brian Sheedy | 75fc515 | 2021-06-28 20:07:13 | [diff] [blame] | 23 | 'PYTHONDONTWRITEBYTECODE': '1', |
| 24 | }) |
| 25 | |
[email protected] | e615e9c | 2012-03-07 21:39:00 | [diff] [blame] | 26 | output = [] |
Ilia Samsonov | a0083530 | 2019-04-19 17:37:59 | [diff] [blame] | 27 | output.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
| 28 | input_api, output_api, '.', [r'^.+_unittest\.py$'])) |
Brian Sheedy | 75fc515 | 2021-06-28 20:07:13 | [diff] [blame] | 29 | output.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
| 30 | input_api, |
| 31 | output_api, |
| 32 | input_api.os_path.join(input_api.PresubmitLocalPath(), |
| 33 | 'unexpected_passes_common'), |
| 34 | [r'^.+_unittest\.py$'], |
| 35 | env=testing_env)) |
[email protected] | e615e9c | 2012-03-07 21:39:00 | [diff] [blame] | 36 | output.extend(input_api.canned_checks.RunPylint( |
Ben Pastene | 4b514ab | 2020-09-16 01:07:13 | [diff] [blame] | 37 | input_api, output_api, files_to_skip=[r'gmock.*', r'gtest.*'])) |
[email protected] | e615e9c | 2012-03-07 21:39:00 | [diff] [blame] | 38 | return output |
| 39 | |
| 40 | |
| 41 | def CheckChangeOnUpload(input_api, output_api): |
| 42 | return CommonChecks(input_api, output_api) |
| 43 | |
| 44 | |
| 45 | def CheckChangeOnCommit(input_api, output_api): |
| 46 | return CommonChecks(input_api, output_api) |