1 # Copyright 2012 The Chromium Authors
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Top-level presubmit script for testing.
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details on the presubmit API built into depot_tools.
11 PRESUBMIT_VERSION = '2.0.0'
14 def _GetTestingEnv(input_api):
15 """Gets the common environment for running testing/ tests."""
16 testing_env = dict(input_api.environ)
17 testing_path = input_api.PresubmitLocalPath()
18 # TODO(crbug.com/1358733): This is temporary till gpu code in
19 # flake_suppressor_commonis moved to gpu dir.
20 # Only common code will reside under /testing.
21 gpu_test_path = input_api.os_path.join(
22 input_api.PresubmitLocalPath(), '..', 'content', 'test', 'gpu')
24 'PYTHONPATH': input_api.os_path.pathsep.join(
25 [testing_path, gpu_test_path]),
26 'PYTHONDONTWRITEBYTECODE': '1',
31 def CheckFlakeSuppressorCommonUnittests(input_api, output_api):
32 """Runs unittests in the testing/flake_suppressor_common/ directory."""
33 return input_api.canned_checks.RunUnitTestsInDirectory(
36 input_api.os_path.join(input_api.PresubmitLocalPath(),
37 'flake_suppressor_common'),
38 [r'^.+_unittest\.py$'],
39 env=_GetTestingEnv(input_api))
42 def CheckUnexpectedPassesCommonUnittests(input_api, output_api):
43 """Runs unittests in the testing/unexpected_passes_common/ directory."""
44 return input_api.canned_checks.RunUnitTestsInDirectory(
47 input_api.os_path.join(input_api.PresubmitLocalPath(),
48 'unexpected_passes_common'),
49 [r'^.+_unittest\.py$'],
50 env=_GetTestingEnv(input_api))
53 def CheckPylint(input_api, output_api):
54 """Runs pylint on all directory content and subdirectories."""
55 files_to_skip = input_api.DEFAULT_FILES_TO_SKIP
56 if input_api.is_windows:
57 # These scripts don't run on Windows and should not be linted on Windows -
58 # trying to do so will lead to spurious errors.
59 files_to_skip += ('xvfb.py', '.*host_info.py')
60 pylint_checks = input_api.canned_checks.GetPylint(
63 files_to_skip=files_to_skip,
65 return input_api.RunTests(pylint_checks)