asanka | 234b8d2 | 2015-06-26 22:40:23 | [diff] [blame] | 1 | # Copyright 2015 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. |
asanka | 234b8d2 | 2015-06-26 22:40:23 | [diff] [blame] | 4 | """Presubmit tests for /tools/vim. |
| 5 | |
| 6 | Runs Python unit tests in /tools/vim/tests on upload. |
| 7 | """ |
| 8 | |
asanka | c68cb71 | 2017-03-11 17:53:53 | [diff] [blame] | 9 | |
asanka | 234b8d2 | 2015-06-26 22:40:23 | [diff] [blame] | 10 | def CheckChangeOnUpload(input_api, output_api): |
asanka | 167e1ea | 2015-11-21 02:08:03 | [diff] [blame] | 11 | results = [] |
| 12 | |
| 13 | # affected_files is list of files affected by this change. The paths are |
| 14 | # relative to the directory containing PRESUBMIT.py. |
| 15 | affected_files = [ |
| 16 | input_api.os_path.relpath(f, input_api.PresubmitLocalPath()) |
asanka | c68cb71 | 2017-03-11 17:53:53 | [diff] [blame] | 17 | for f in input_api.AbsoluteLocalPaths() |
| 18 | ] |
asanka | 167e1ea | 2015-11-21 02:08:03 | [diff] [blame] | 19 | |
| 20 | # Run the chromium.ycm_extra_conf_unittest test if the YCM config file is |
| 21 | # changed or if any change is affecting the tests directory. This specific |
| 22 | # test requires access to 'ninja' and hasn't been tested on platforms other |
| 23 | # than Linux. |
| 24 | if 'chromium.ycm_extra_conf.py' in affected_files or \ |
lstorset | f7a91ff | 2015-11-25 15:10:58 | [diff] [blame] | 25 | 'ninja_output.py' in affected_files or \ |
asanka | 167e1ea | 2015-11-21 02:08:03 | [diff] [blame] | 26 | any([input_api.re.match(r'tests(/|\\)',f) for f in affected_files]): |
| 27 | results += input_api.RunTests( |
asanka | c68cb71 | 2017-03-11 17:53:53 | [diff] [blame] | 28 | input_api.canned_checks.GetUnitTests(input_api, output_api, [ |
| 29 | 'tests/chromium.ycm_extra_conf_unittest.py' |
| 30 | ])) |
asanka | 167e1ea | 2015-11-21 02:08:03 | [diff] [blame] | 31 | |
| 32 | return results |