| OLD | NEW |
| 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Top-level presubmit script for depot tools. | 5 """Top-level presubmit script for depot tools. |
| 6 | 6 |
| 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for |
| 8 details on the presubmit API built into depot_tools. | 8 details on the presubmit API built into depot_tools. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 r'^svn_bin[\/\\].+', | 30 r'^svn_bin[\/\\].+', |
| 31 r'^tests[\/\\]\w+?[\/\\].+'] | 31 r'^tests[\/\\]\w+?[\/\\].+'] |
| 32 results.extend(input_api.canned_checks.RunPylint( | 32 results.extend(input_api.canned_checks.RunPylint( |
| 33 input_api, | 33 input_api, |
| 34 output_api, | 34 output_api, |
| 35 white_list=[r'.*\.py$', r'^git-try$'], | 35 white_list=[r'.*\.py$', r'^git-try$'], |
| 36 black_list=black_list)) | 36 black_list=black_list)) |
| 37 | 37 |
| 38 # TODO(maruel): Make sure at least one file is modified first. | 38 # TODO(maruel): Make sure at least one file is modified first. |
| 39 # TODO(maruel): If only tests are modified, only run them. | 39 # TODO(maruel): If only tests are modified, only run them. |
| 40 verbose = False | |
| 41 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( | 40 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
| 42 input_api, | 41 input_api, |
| 43 output_api, | 42 output_api, |
| 44 'tests', | 43 'tests', |
| 45 whitelist=[r'.*test\.py$'], | 44 whitelist=[r'.*test\.py$'])) |
| 46 verbose=verbose)) | 45 results.extend(RunGitClTests(input_api, output_api)) |
| 47 results.extend(RunGitClTests(input_api, output_api, verbose=verbose)) | |
| 48 return results | 46 return results |
| 49 | 47 |
| 50 | 48 |
| 51 def RunGitClTests(input_api, output_api, verbose): | 49 def RunGitClTests(input_api, output_api): |
| 52 """Run all the shells scripts in the directory test. | 50 """Run all the shells scripts in the directory test. |
| 53 """ | 51 """ |
| 54 if input_api.platform == 'win32': | 52 if input_api.platform == 'win32': |
| 55 # Skip for now as long as the test scripts are bash scripts. | 53 # Skip for now as long as the test scripts are bash scripts. |
| 56 return [] | 54 return [] |
| 57 | 55 |
| 58 # First loads a local Rietveld instance. | 56 # First loads a local Rietveld instance. |
| 59 import sys | 57 import sys |
| 60 old_sys_path = sys.path | 58 old_sys_path = sys.path |
| 61 try: | 59 try: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 74 for test in input_api.os_listdir(test_path): | 72 for test in input_api.os_listdir(test_path): |
| 75 # test-lib.sh is not an actual test so it should not be run. The other | 73 # test-lib.sh is not an actual test so it should not be run. The other |
| 76 # tests are tests known to fail. | 74 # tests are tests known to fail. |
| 77 DISABLED_TESTS = ( | 75 DISABLED_TESTS = ( |
| 78 'owners.sh', 'push-from-logs.sh', 'rename.sh', 'test-lib.sh') | 76 'owners.sh', 'push-from-logs.sh', 'rename.sh', 'test-lib.sh') |
| 79 if test in DISABLED_TESTS or not test.endswith('.sh'): | 77 if test in DISABLED_TESTS or not test.endswith('.sh'): |
| 80 continue | 78 continue |
| 81 | 79 |
| 82 print('Running %s' % test) | 80 print('Running %s' % test) |
| 83 try: | 81 try: |
| 84 if verbose: | 82 if input_api.verbose: |
| 85 input_api.subprocess.check_call( | 83 input_api.subprocess.check_call( |
| 86 [input_api.os_path.join(test_path, test)], cwd=test_path) | 84 [input_api.os_path.join(test_path, test)], cwd=test_path) |
| 87 else: | 85 else: |
| 88 input_api.subprocess.check_output( | 86 input_api.subprocess.check_output( |
| 89 [input_api.os_path.join(test_path, test)], cwd=test_path) | 87 [input_api.os_path.join(test_path, test)], cwd=test_path) |
| 90 except (OSError, input_api.subprocess.CalledProcessError), e: | 88 except (OSError, input_api.subprocess.CalledProcessError), e: |
| 91 results.append(output_api.PresubmitError('%s failed\n%s' % (test, e))) | 89 results.append(output_api.PresubmitError('%s failed\n%s' % (test, e))) |
| 92 except local_rietveld.Failure, e: | 90 except local_rietveld.Failure, e: |
| 93 results.append(output_api.PresubmitError('\n'.join(str(i) for i in e.args))) | 91 results.append(output_api.PresubmitError('\n'.join(str(i) for i in e.args))) |
| 94 finally: | 92 finally: |
| 95 server.stop_server() | 93 server.stop_server() |
| 96 return results | 94 return results |
| 97 | 95 |
| 98 | 96 |
| 99 def CheckChangeOnUpload(input_api, output_api): | 97 def CheckChangeOnUpload(input_api, output_api): |
| 100 return CommonChecks(input_api, output_api) | 98 return CommonChecks(input_api, output_api) |
| 101 | 99 |
| 102 | 100 |
| 103 def CheckChangeOnCommit(input_api, output_api): | 101 def CheckChangeOnCommit(input_api, output_api): |
| 104 output = [] | 102 output = [] |
| 105 output.extend(CommonChecks(input_api, output_api)) | 103 output.extend(CommonChecks(input_api, output_api)) |
| 106 output.extend(input_api.canned_checks.CheckDoNotSubmit( | 104 output.extend(input_api.canned_checks.CheckDoNotSubmit( |
| 107 input_api, | 105 input_api, |
| 108 output_api)) | 106 output_api)) |
| 109 return output | 107 return output |
| OLD | NEW |