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. |
| 4 | |
| 5 | """Presubmit tests for /tools/vim. |
| 6 | |
| 7 | Runs Python unit tests in /tools/vim/tests on upload. |
| 8 | """ |
| 9 | |
| 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()) |
| 17 | for f in input_api.AbsoluteLocalPaths()] |
| 18 | |
| 19 | # Run the chromium.ycm_extra_conf_unittest test if the YCM config file is |
| 20 | # changed or if any change is affecting the tests directory. This specific |
| 21 | # test requires access to 'ninja' and hasn't been tested on platforms other |
| 22 | # than Linux. |
| 23 | if 'chromium.ycm_extra_conf.py' in affected_files or \ |
lstorset | f7a91ff | 2015-11-25 15:10:58 | [diff] [blame^] | 24 | 'ninja_output.py' in affected_files or \ |
asanka | 167e1ea | 2015-11-21 02:08:03 | [diff] [blame] | 25 | any([input_api.re.match(r'tests(/|\\)',f) for f in affected_files]): |
| 26 | results += input_api.RunTests( |
| 27 | input_api.canned_checks.GetUnitTests( |
| 28 | input_api, output_api, |
| 29 | ['tests/chromium.ycm_extra_conf_unittest.py'])) |
| 30 | |
| 31 | return results |