blob: a08eafe03c95b667a8f22348fcb2876a97e7d110 [file] [log] [blame]
maruel@chromium.orgfb155e92012-09-28 20:36:54 +00001# 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 swarm_client.
6
7See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for
8details on the presubmit API built into gcl.
9"""
10
11def CommonChecks(input_api, output_api):
maruel@chromium.org8b056ba2012-10-16 14:04:49 +000012 import sys
13 def join(*args):
14 return input_api.os_path.join(input_api.PresubmitLocalPath(), *args)
maruel@chromium.orgfb155e92012-09-28 20:36:54 +000015
maruel@chromium.org8b056ba2012-10-16 14:04:49 +000016 output = []
17 sys_path_backup = sys.path
18 try:
19 sys.path = [
maruel@chromium.org86681e92013-07-25 13:34:09 +000020 input_api.PresubmitLocalPath(),
21 join('googletest'),
maruel@chromium.org8b056ba2012-10-16 14:04:49 +000022 join('tests', 'gtest_fake'),
23 ] + sys.path
24 output.extend(input_api.canned_checks.RunPylint(input_api, output_api))
25 finally:
26 sys.path = sys_path_backup
27
maruel@chromium.org11f54112013-09-16 23:16:42 +000028 # These tests are touching the live infrastructure. It's a pain if your IP
29 # is not whitelisted so do not run them for now. They should use a local fake
30 # web service instead.
31 blacklist = [
32 r'.*isolateserver_smoke_test\.py$',
33 r'.*swarming_smoke_test\.py$',
34 ]
maruel@chromium.org7a144f82013-05-28 14:46:07 +000035
maruel@chromium.orgfb155e92012-09-28 20:36:54 +000036 output.extend(
37 input_api.canned_checks.RunUnitTestsInDirectory(
38 input_api, output_api,
39 input_api.os_path.join(input_api.PresubmitLocalPath(), 'tests'),
maruel@chromium.org7a144f82013-05-28 14:46:07 +000040 whitelist=[r'.+_test\.py$'],
maruel@chromium.org11f54112013-09-16 23:16:42 +000041 blacklist=blacklist))
maruel@chromium.org86681e92013-07-25 13:34:09 +000042 output.extend(
43 input_api.canned_checks.RunUnitTestsInDirectory(
44 input_api, output_api,
45 input_api.os_path.join(
46 input_api.PresubmitLocalPath(), 'googletest', 'tests'),
47 whitelist=[r'.+_test\.py$']))
maruel@chromium.orgfb155e92012-09-28 20:36:54 +000048
49 if input_api.is_committing:
50 output.extend(input_api.canned_checks.PanProjectChecks(input_api,
51 output_api,
52 owners_check=False))
53 return output
54
55
56def CheckChangeOnUpload(input_api, output_api):
57 return CommonChecks(input_api, output_api)
58
59
60def CheckChangeOnCommit(input_api, output_api):
61 return CommonChecks(input_api, output_api)