blob: 61df560126145e075bb67c93864b922fad13f6ee [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 = [
20 join('tests', 'gtest_fake'),
21 ] + sys.path
22 output.extend(input_api.canned_checks.RunPylint(input_api, output_api))
23 finally:
24 sys.path = sys_path_backup
25
maruel@chromium.org7a144f82013-05-28 14:46:07 +000026 integation_tests = []
27 if not input_api.is_committing:
28 # These tests are touching the live infrastructure. It's a pain if your IP
29 # is not whitelisted so only run these on commit.
30 integation_tests = [
31 r'.*isolateserver_archive_smoke_test\.py$',
32 r'.*swarm_get_results_smoke_test\.py$',
33 ]
34
maruel@chromium.orgfb155e92012-09-28 20:36:54 +000035 output.extend(
36 input_api.canned_checks.RunUnitTestsInDirectory(
37 input_api, output_api,
38 input_api.os_path.join(input_api.PresubmitLocalPath(), 'tests'),
maruel@chromium.org7a144f82013-05-28 14:46:07 +000039 whitelist=[r'.+_test\.py$'],
40 blacklist=integation_tests))
maruel@chromium.orgfb155e92012-09-28 20:36:54 +000041
42 if input_api.is_committing:
43 output.extend(input_api.canned_checks.PanProjectChecks(input_api,
44 output_api,
45 owners_check=False))
46 return output
47
48
49def CheckChangeOnUpload(input_api, output_api):
50 return CommonChecks(input_api, output_api)
51
52
53def CheckChangeOnCommit(input_api, output_api):
54 return CommonChecks(input_api, output_api)