maruel | ea586f3 | 2016-04-05 11:11:33 -0700 | [diff] [blame] | 1 | # Copyright 2012 The LUCI Authors. All rights reserved. |
maruel | f1f5e2a | 2016-05-25 17:10:39 -0700 | [diff] [blame] | 2 | # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 | # that can be found in the LICENSE file. |
maruel@chromium.org | fb155e9 | 2012-09-28 20:36:54 +0000 | [diff] [blame] | 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(), |
Marc-Antoine Ruel | 5906fcd | 2013-11-08 21:02:24 -0500 | [diff] [blame] | 21 | join('tests'), |
Marc-Antoine Ruel | 3525b33 | 2013-11-12 13:51:20 -0500 | [diff] [blame] | 22 | join('third_party'), |
maruel@chromium.org | 8b056ba | 2012-10-16 14:04:49 +0000 | [diff] [blame] | 23 | ] + sys.path |
aludwin | 0bafa45 | 2016-11-24 05:49:09 -0800 | [diff] [blame^] | 24 | black_list = list(input_api.DEFAULT_BLACK_LIST) + [ |
| 25 | r'.*_pb2\.py$', |
| 26 | ] |
| 27 | output.extend(input_api.canned_checks.RunPylint( |
| 28 | input_api, output_api, |
| 29 | black_list=black_list)) |
maruel@chromium.org | 8b056ba | 2012-10-16 14:04:49 +0000 | [diff] [blame] | 30 | finally: |
| 31 | sys.path = sys_path_backup |
| 32 | |
maruel@chromium.org | 11f5411 | 2013-09-16 23:16:42 +0000 | [diff] [blame] | 33 | # These tests are touching the live infrastructure. It's a pain if your IP |
| 34 | # is not whitelisted so do not run them for now. They should use a local fake |
| 35 | # web service instead. |
| 36 | blacklist = [ |
| 37 | r'.*isolateserver_smoke_test\.py$', |
dnj | e5eea0f | 2016-05-17 08:28:18 -0700 | [diff] [blame] | 38 | r'.*isolateserver_load_test\.py$', |
maruel@chromium.org | 11f5411 | 2013-09-16 23:16:42 +0000 | [diff] [blame] | 39 | r'.*swarming_smoke_test\.py$', |
| 40 | ] |
maruel@chromium.org | 1455004 | 2013-09-17 20:36:38 +0000 | [diff] [blame] | 41 | if not input_api.is_committing: |
| 42 | # Remove all slow tests, e.g. the ones that take >1s to complete. |
| 43 | blacklist.extend([ |
| 44 | r'.*isolate_smoke_test\.py$', |
| 45 | r'.*trace_inputs_smoke_test\.py$', |
| 46 | r'.*url_open_timeout_test\.py$', |
| 47 | ]) |
maruel@chromium.org | 7a144f8 | 2013-05-28 14:46:07 +0000 | [diff] [blame] | 48 | |
dnj | e5eea0f | 2016-05-17 08:28:18 -0700 | [diff] [blame] | 49 | unit_tests = input_api.canned_checks.GetUnitTestsRecursively( |
| 50 | input_api, output_api, |
| 51 | input_api.os_path.join(input_api.PresubmitLocalPath()), |
| 52 | whitelist=[r'.+_test\.py$'], |
| 53 | blacklist=blacklist) |
| 54 | output.extend(input_api.RunTests(unit_tests)) |
maruel@chromium.org | fb155e9 | 2012-09-28 20:36:54 +0000 | [diff] [blame] | 55 | return output |
| 56 | |
| 57 | |
| 58 | def CheckChangeOnUpload(input_api, output_api): |
| 59 | return CommonChecks(input_api, output_api) |
| 60 | |
| 61 | |
| 62 | def CheckChangeOnCommit(input_api, output_api): |
maruel | ea586f3 | 2016-04-05 11:11:33 -0700 | [diff] [blame] | 63 | return CommonChecks(input_api, output_api) |