chase@chromium.org | b9a9832 | 2010-12-23 22:32:45 +0000 | [diff] [blame] | 1 | # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
maruel@chromium.org | 3d23524 | 2009-05-15 12:40:48 +0000 | [diff] [blame] | 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 depot tools. |
| 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 | |
maruel@chromium.org | ce30ef7 | 2009-05-25 15:20:42 +0000 | [diff] [blame] | 11 | UNIT_TESTS = [ |
| 12 | 'tests.gcl_unittest', |
maruel@chromium.org | ad80e3b | 2010-09-09 14:18:28 +0000 | [diff] [blame] | 13 | 'tests.gclient_scm_test', |
maruel@chromium.org | 888b835 | 2010-08-11 18:42:03 +0000 | [diff] [blame] | 14 | 'tests.gclient_smoketest', |
maruel@chromium.org | d5800f1 | 2009-11-12 20:03:43 +0000 | [diff] [blame] | 15 | 'tests.gclient_utils_test', |
dpranke@chromium.org | 5fe603e | 2011-03-09 21:02:50 +0000 | [diff] [blame] | 16 | 'tests.owners_unittest', |
maruel@chromium.org | ce30ef7 | 2009-05-25 15:20:42 +0000 | [diff] [blame] | 17 | 'tests.presubmit_unittest', |
maruel@chromium.org | d5800f1 | 2009-11-12 20:03:43 +0000 | [diff] [blame] | 18 | 'tests.scm_unittest', |
maruel@chromium.org | ce30ef7 | 2009-05-25 15:20:42 +0000 | [diff] [blame] | 19 | 'tests.trychange_unittest', |
nirnimesh@chromium.org | b82e409 | 2009-06-18 14:24:08 +0000 | [diff] [blame] | 20 | 'tests.watchlists_unittest', |
maruel@chromium.org | ce30ef7 | 2009-05-25 15:20:42 +0000 | [diff] [blame] | 21 | ] |
maruel@chromium.org | 3d23524 | 2009-05-15 12:40:48 +0000 | [diff] [blame] | 22 | |
dpranke@chromium.org | 627ea67 | 2011-03-11 23:29:03 +0000 | [diff] [blame] | 23 | |
maruel@chromium.org | e94aedc | 2010-12-13 21:11:30 +0000 | [diff] [blame] | 24 | def CommonChecks(input_api, output_api): |
maruel@chromium.org | 7b305e8 | 2009-05-19 18:24:20 +0000 | [diff] [blame] | 25 | output = [] |
maruel@chromium.org | 5d0dc43 | 2011-01-03 02:40:37 +0000 | [diff] [blame] | 26 | # Verify that LocalPath() is local, e.g.: |
| 27 | # os.path.join(PresubmitLocalPath(), LocalPath()) == AbsoluteLocalPath() |
| 28 | for i in input_api.AffectedFiles(): |
| 29 | if (input_api.os_path.join(input_api.PresubmitLocalPath(), i.LocalPath()) != |
| 30 | i.AbsoluteLocalPath()): |
| 31 | output.append(output_api.PresubmitError('Path inconsistency')) |
| 32 | # Return right away because it needs to be fixed first. |
| 33 | return output |
| 34 | |
dpranke@chromium.org | 8d84041 | 2011-03-17 23:43:45 +0000 | [diff] [blame] | 35 | output.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) |
dpranke@chromium.org | 3ae183f | 2011-03-09 21:40:32 +0000 | [diff] [blame] | 36 | |
maruel@chromium.org | e94aedc | 2010-12-13 21:11:30 +0000 | [diff] [blame] | 37 | output.extend(input_api.canned_checks.RunPythonUnitTests( |
| 38 | input_api, |
| 39 | output_api, |
| 40 | UNIT_TESTS)) |
maruel@chromium.org | e94aedc | 2010-12-13 21:11:30 +0000 | [diff] [blame] | 41 | |
maruel@chromium.org | 5d0dc43 | 2011-01-03 02:40:37 +0000 | [diff] [blame] | 42 | white_list = [r'.*\.py$', r'^git-try$'] |
maruel@chromium.org | bf38a7e | 2010-12-14 18:15:54 +0000 | [diff] [blame] | 43 | black_list = list(input_api.DEFAULT_BLACK_LIST) + [ |
maruel@chromium.org | 5d0dc43 | 2011-01-03 02:40:37 +0000 | [diff] [blame] | 44 | r'^cpplint\.py$', |
dpranke@chromium.org | 97ae58e | 2011-03-18 00:29:20 +0000 | [diff] [blame^] | 45 | r'^git_cl[\/\\]test[\/\\](local_)?rietveld.*', |
| 46 | r'^git_cl[\/\\]upload.*', |
| 47 | ] |
maruel@chromium.org | e94aedc | 2010-12-13 21:11:30 +0000 | [diff] [blame] | 48 | output.extend(input_api.canned_checks.RunPylint( |
| 49 | input_api, |
| 50 | output_api, |
maruel@chromium.org | bf38a7e | 2010-12-14 18:15:54 +0000 | [diff] [blame] | 51 | white_list=white_list, |
| 52 | black_list=black_list)) |
maruel@chromium.org | ce30ef7 | 2009-05-25 15:20:42 +0000 | [diff] [blame] | 53 | return output |
| 54 | |
| 55 | |
maruel@chromium.org | e94aedc | 2010-12-13 21:11:30 +0000 | [diff] [blame] | 56 | def CheckChangeOnUpload(input_api, output_api): |
| 57 | return CommonChecks(input_api, output_api) |
| 58 | |
| 59 | |
maruel@chromium.org | ce30ef7 | 2009-05-25 15:20:42 +0000 | [diff] [blame] | 60 | def CheckChangeOnCommit(input_api, output_api): |
| 61 | output = [] |
maruel@chromium.org | e94aedc | 2010-12-13 21:11:30 +0000 | [diff] [blame] | 62 | output.extend(CommonChecks(input_api, output_api)) |
| 63 | output.extend(input_api.canned_checks.CheckDoNotSubmit( |
| 64 | input_api, |
| 65 | output_api)) |
maruel@chromium.org | 7b305e8 | 2009-05-19 18:24:20 +0000 | [diff] [blame] | 66 | return output |