Movatterモバイル変換


[0]ホーム

URL:


Google Git
Sign in
chromium /chromium /src /refs/heads/main /. /testing /PRESUBMIT.py
blob: f68c001138e65c2cadbe9fe6d95e82dd3b2a128e [file] [log] [blame]
Avi Drissmandfd880852022-09-15 20:11:09[diff] [blame]1# Copyright 2012 The Chromium Authors
maruel@chromium.orge615e9c2012-03-07 21:39:00[diff] [blame]2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
maruel@chromium.orge615e9c2012-03-07 21:39:00[diff] [blame]4"""Top-level presubmit script for testing.
5
tfarina78bb92f42015-01-31 00:20:48[diff] [blame]6See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
7for more details on the presubmit API built into depot_tools.
maruel@chromium.orge615e9c2012-03-07 21:39:00[diff] [blame]8"""
9
Brian Sheedyf4c13942023-01-25 00:19:45[diff] [blame]10PRESUBMIT_VERSION='2.0.0'
maruel@chromium.orge615e9c2012-03-07 21:39:00[diff] [blame]11
Brian Sheedyfe2702e2024-12-13 21:48:20[diff] [blame]12PYLINT_PATHS_COMPONENTS=[
13('build',),
14('build','android'),
15('build','util'),
16('content','test','gpu'),
17('testing',),
18('testing','buildbot'),
19('testing','scripts'),
20('testing','variations','presubmit'),
21('third_party',),
22('third_party','blink','renderer','bindings','scripts'),
23('third_party','blink','tools'),
24('third_party','catapult','telemetry'),
25('third_party','catapult','third_party','typ'),
26('third_party','catapult','tracing'),
27('third_party','domato','src'),
28('third_party','js_code_coverage'),
29('third_party','webdriver','pylib'),
30('tools','perf'),
31]
32
Brian Sheedyf4c13942023-01-25 00:19:45[diff] [blame]33
Brian Sheedyc68beba2024-07-24 02:29:23[diff] [blame]34def_GetChromiumSrcPath(input_api):
35"""Returns the path to the Chromium src directory."""
36return input_api.os_path.realpath(
37 input_api.os_path.join(input_api.PresubmitLocalPath(),'..'))
38
39
Brian Sheedyf4c13942023-01-25 00:19:45[diff] [blame]40def_GetTestingEnv(input_api):
41"""Gets the common environment for running testing/ tests."""
Brian Sheedy75fc5152021-06-28 20:07:13[diff] [blame]42 testing_env= dict(input_api.environ)
Preethi Mohan8a6d7e822022-09-03 08:04:57[diff] [blame]43 testing_path= input_api.PresubmitLocalPath()
Alison Gale81f4f2c72024-04-22 19:33:31[diff] [blame]44# TODO(crbug.com/40237086): This is temporary till gpu code in
Preethi Mohan8a6d7e822022-09-03 08:04:57[diff] [blame]45# flake_suppressor_commonis moved to gpu dir.
46# Only common code will reside under /testing.
Ben Pasteneb5c67262024-05-15 21:24:01[diff] [blame]47 gpu_test_path= input_api.os_path.join(input_api.PresubmitLocalPath(),'..',
48'content','test','gpu')
Brian Sheedyb10e844732025-03-21 17:03:34[diff] [blame]49 typ_path= input_api.os_path.join(input_api.PresubmitLocalPath(),'..',
50'third_party','catapult','third_party',
51'typ')
Brian Sheedy75fc5152021-06-28 20:07:13[diff] [blame]52 testing_env.update({
Ben Pasteneb5c67262024-05-15 21:24:01[diff] [blame]53'PYTHONPATH':
Brian Sheedyb10e844732025-03-21 17:03:34[diff] [blame]54 input_api.os_path.pathsep.join([testing_path, gpu_test_path, typ_path]),
Ben Pasteneb5c67262024-05-15 21:24:01[diff] [blame]55'PYTHONDONTWRITEBYTECODE':
56'1',
Brian Sheedy75fc5152021-06-28 20:07:13[diff] [blame]57})
Brian Sheedyf4c13942023-01-25 00:19:45[diff] [blame]58return testing_env
Brian Sheedy75fc5152021-06-28 20:07:13[diff] [blame]59
Brian Sheedyf4c13942023-01-25 00:19:45[diff] [blame]60
Brian Sheedyf4c13942023-01-25 00:19:45[diff] [blame]61defCheckFlakeSuppressorCommonUnittests(input_api, output_api):
62"""Runs unittests in the testing/flake_suppressor_common/ directory."""
63return input_api.canned_checks.RunUnitTestsInDirectory(
Brian Sheedy75fc5152021-06-28 20:07:13[diff] [blame]64 input_api,
65 output_api,
66 input_api.os_path.join(input_api.PresubmitLocalPath(),
Ben Pasteneb5c67262024-05-15 21:24:01[diff] [blame]67'flake_suppressor_common'),[r'^.+_unittest\.py$'],
Takuto Ikuta40def482023-06-02 02:23:49[diff] [blame]68 env=_GetTestingEnv(input_api))
Brian Sheedyf4c13942023-01-25 00:19:45[diff] [blame]69
70
71defCheckUnexpectedPassesCommonUnittests(input_api, output_api):
72"""Runs unittests in the testing/unexpected_passes_common/ directory."""
73return input_api.canned_checks.RunUnitTestsInDirectory(
Preethi Mohan8a6d7e822022-09-03 08:04:57[diff] [blame]74 input_api,
75 output_api,
76 input_api.os_path.join(input_api.PresubmitLocalPath(),
Brian Sheedy75fc5152021-06-28 20:07:13[diff] [blame]77'unexpected_passes_common'),
78[r'^.+_unittest\.py$'],
Takuto Ikuta40def482023-06-02 02:23:49[diff] [blame]79 env=_GetTestingEnv(input_api))
Brian Sheedyf4c13942023-01-25 00:19:45[diff] [blame]80
81
82defCheckPylint(input_api, output_api):
83"""Runs pylint on all directory content and subdirectories."""
Bruce Dawson53f1d1c22022-05-23 18:29:01[diff] [blame]84 files_to_skip= input_api.DEFAULT_FILES_TO_SKIP
Brian Sheedyc68beba2024-07-24 02:29:23[diff] [blame]85 chromium_src_path=_GetChromiumSrcPath(input_api)
Brian Sheedyc68beba2024-07-24 02:29:23[diff] [blame]86 pylint_extra_paths=[
87 input_api.os_path.join(chromium_src_path,*component)
Brian Sheedyfe2702e2024-12-13 21:48:20[diff] [blame]88for componentin PYLINT_PATHS_COMPONENTS
Brian Sheedyc68beba2024-07-24 02:29:23[diff] [blame]89]
Bruce Dawson53f1d1c22022-05-23 18:29:01[diff] [blame]90if input_api.is_windows:
91# These scripts don't run on Windows and should not be linted on Windows -
92# trying to do so will lead to spurious errors.
93 files_to_skip+=('xvfb.py','.*host_info.py')
Brian Sheedyc68beba2024-07-24 02:29:23[diff] [blame]94 pylint_checks= input_api.canned_checks.GetPylint(
95 input_api,
96 output_api,
97 extra_paths_list=pylint_extra_paths,
98 files_to_skip=files_to_skip,
99# TODO(crbug.com/355016915): Remove this directory-specific pylintrc
100# file as the default one gets its disable list cleaned up.
101 pylintrc='pylintrc',
102 version='2.7')
Ben Pasteneb5c67262024-05-15 21:24:01[diff] [blame]103return input_api.RunTests(pylint_checks)
104
105
106defCheckPatchFormatted(input_api, output_api):
107return input_api.canned_checks.CheckPatchFormatted(
Joshua Hood7827f5f02022-03-01 16:31:00[diff] [blame]108 input_api,
109 output_api,
Ben Pasteneb5c67262024-05-15 21:24:01[diff] [blame]110 result_factory=output_api.PresubmitError,
111)

[8]ページ先頭

©2009-2025 Movatter.jp