blob: b5b23fe56522b97dc7c53b03a489522462f455f8 [file] [log] [blame]
Avi Drissmandfd880852022-09-15 20:11:091# Copyright 2012 The Chromium Authors
maruel74e1ca72015-04-01 12:31:552# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5"""Enforces json format.
6
7See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8for more details on the presubmit API built into depot_tools.
9"""
10
Garrett Beaty9d7590b12021-06-16 00:17:1811PRESUBMIT_VERSION = '2.0.0'
Josip Sokcevic2f4f9f62021-06-14 04:27:4612
Garrett Beatyac48e8c92021-12-14 01:28:4813
14def CheckFreeze(input_api, output_api):
Garrett Beatyee198432024-01-25 00:08:4115 return input_api.canned_checks.CheckInfraFreeze(
16 input_api, output_api, files_to_exclude=['.+/filters/.+'])
Garrett Beatyac48e8c92021-12-14 01:28:4817
maruel74e1ca72015-04-01 12:31:5518
Garrett Beaty9d7590b12021-06-16 00:17:1819def CheckSourceSideSpecs(input_api, output_api):
20 return input_api.RunTests([
21 input_api.Command(name='check source side specs',
Garrett Beaty7e866fc2021-06-16 14:12:1022 cmd=[
23 input_api.python3_executable,
24 'generate_buildbot_json.py', '--check', '--verbose'
25 ],
Jamie Madillcf4f8c72021-05-20 19:24:2326 kwargs={},
27 message=output_api.PresubmitError),
Garrett Beaty9d7590b12021-06-16 00:17:1828 ])
29
30
31def CheckTests(input_api, output_api):
Ben Pastene66e03182023-05-08 17:01:4932 for f in input_api.AffectedFiles():
33 # If the only files changed here match //testing/buildbot/*.(pyl|json),
34 # then we can assume the unit tests are unaffected.
35 if (len(f.LocalPath().split(input_api.os_path.sep)) != 3
36 or not f.LocalPath().endswith(('.json', '.pyl'))):
37 break
38 else:
39 return []
Garrett Beaty9d7590b12021-06-16 00:17:1840 glob = input_api.os_path.join(input_api.PresubmitLocalPath(), '*test.py')
Takuto Ikuta40def482023-06-02 02:23:4941 tests = input_api.canned_checks.GetUnitTests(input_api, output_api,
42 input_api.glob(glob))
Garrett Beaty9d7590b12021-06-16 00:17:1843 return input_api.RunTests(tests)
44
45
Garrett Beatybabf03eb2023-06-23 16:04:3446def CheckJsonFiles(input_api, output_api):
Garrett Beaty9d7590b12021-06-16 00:17:1847 return input_api.RunTests([
Garrett Beatybabf03eb2023-06-23 16:04:3448 input_api.Command(name='check JSON files',
Garrett Beaty6735f432023-06-23 16:24:3049 cmd=[input_api.python3_executable, 'check.py'],
Garrett Beatybabf03eb2023-06-23 16:04:3450 kwargs={},
51 message=output_api.PresubmitError),
Garrett Beaty9d7590b12021-06-16 00:17:1852 ])
Garrett Beatyec1e3392023-04-12 19:01:1353
54
Garrett Beaty96802d02023-07-07 14:18:0555def CheckPylFilesSynced(input_api, output_api):
56 return input_api.RunTests([
57 input_api.Command(
58 name='check-pyl-files-synced',
59 cmd=[
60 input_api.python3_executable,
61 '../../infra/config/scripts/sync-pyl-files.py',
62 '--check',
63 ],
64 kwargs={},
65 message=output_api.PresubmitError,
66 ),
67 ])