maruel@chromium.org | fb155e9 | 2012-09-28 20:36:54 +0000 | [diff] [blame] | 1 | # 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 | |
| 7 | See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for |
| 8 | details on the presubmit API built into gcl. |
| 9 | """ |
| 10 | |
| 11 | def CommonChecks(input_api, output_api): |
maruel@chromium.org | 8b056ba | 2012-10-16 14:04:49 +0000 | [diff] [blame] | 12 | import sys |
| 13 | def join(*args): |
| 14 | return input_api.os_path.join(input_api.PresubmitLocalPath(), *args) |
maruel@chromium.org | fb155e9 | 2012-09-28 20:36:54 +0000 | [diff] [blame] | 15 | |
maruel@chromium.org | 8b056ba | 2012-10-16 14:04:49 +0000 | [diff] [blame] | 16 | output = [] |
| 17 | sys_path_backup = sys.path |
| 18 | try: |
| 19 | sys.path = [ |
maruel@chromium.org | 86681e9 | 2013-07-25 13:34:09 +0000 | [diff] [blame^] | 20 | input_api.PresubmitLocalPath(), |
| 21 | join('googletest'), |
maruel@chromium.org | 8b056ba | 2012-10-16 14:04:49 +0000 | [diff] [blame] | 22 | 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.org | 7a144f8 | 2013-05-28 14:46:07 +0000 | [diff] [blame] | 28 | 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.org | fb155e9 | 2012-09-28 20:36:54 +0000 | [diff] [blame] | 37 | 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.org | 7a144f8 | 2013-05-28 14:46:07 +0000 | [diff] [blame] | 41 | whitelist=[r'.+_test\.py$'], |
| 42 | blacklist=integation_tests)) |
maruel@chromium.org | 86681e9 | 2013-07-25 13:34:09 +0000 | [diff] [blame^] | 43 | 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.org | fb155e9 | 2012-09-28 20:36:54 +0000 | [diff] [blame] | 49 | |
| 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 | |
| 57 | def CheckChangeOnUpload(input_api, output_api): |
| 58 | return CommonChecks(input_api, output_api) |
| 59 | |
| 60 | |
| 61 | def CheckChangeOnCommit(input_api, output_api): |
| 62 | return CommonChecks(input_api, output_api) |