blob: 59619ce3506be5c7fef3c49475e24d619caed94b [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.org7a144f82013-05-28 14:46:07 +000028 integation_tests = []
29 if not input_api.is_committing:
30 # These tests are touching the live infrastructure. It's a pain if your IP
31 # is not whitelisted so only run these on commit.
32 integation_tests = [
33 r'.*isolateserver_archive_smoke_test\.py$',
34 r'.*swarm_get_results_smoke_test\.py$',
35 ]
36
maruel@chromium.orgfb155e92012-09-28 20:36:54 +000037 output.extend(
38 input_api.canned_checks.RunUnitTestsInDirectory(
39 input_api, output_api,
40 input_api.os_path.join(input_api.PresubmitLocalPath(), 'tests'),
maruel@chromium.org7a144f82013-05-28 14:46:07 +000041 whitelist=[r'.+_test\.py$'],
42 blacklist=integation_tests))
maruel@chromium.org86681e92013-07-25 13:34:09 +000043 output.extend(
44 input_api.canned_checks.RunUnitTestsInDirectory(
45 input_api, output_api,
46 input_api.os_path.join(
47 input_api.PresubmitLocalPath(), 'googletest', 'tests'),
48 whitelist=[r'.+_test\.py$']))
maruel@chromium.orgfb155e92012-09-28 20:36:54 +000049
50 if input_api.is_committing:
51 output.extend(input_api.canned_checks.PanProjectChecks(input_api,
52 output_api,
53 owners_check=False))
54 return output
55
56
57def CheckChangeOnUpload(input_api, output_api):
58 return CommonChecks(input_api, output_api)
59
60
61def CheckChangeOnCommit(input_api, output_api):
62 return CommonChecks(input_api, output_api)