OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Top-level presubmit script for depot tools. | 6 """Top-level presubmit script for depot tools. |
7 | 7 |
8 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for | 8 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for |
9 details on the presubmit API built into gcl. | 9 details on the presubmit API built into gcl. |
10 """ | 10 """ |
11 | 11 |
12 | 12 |
13 def CheckChangeOnUpload(input_api, output_api): | 13 def CheckChangeOnUpload(input_api, output_api): |
14 return RunUnitTests(input_api, output_api) | 14 return RunUnitTests(input_api, output_api) |
15 | 15 |
16 | 16 |
17 def CheckChangeOnCommit(input_api, output_api): | 17 def CheckChangeOnCommit(input_api, output_api): |
18 return (RunUnitTests(input_api, output_api) + | 18 unit_tests = [ |
19 input_api.canned_checks.CheckDoNotSubmit(input_api, output_api)) | 19 'tests.gcl_unittest', |
20 | 20 'tests.gclient_test', |
21 | 21 'tests.presubmit_unittest', |
22 def RunUnitTests(input_api, output_api): | 22 'tests.revert_unittest', |
23 import unittest | 23 'tests.trychange_unittest', |
24 tests_suite = [] | 24 ] |
25 test_loader = unittest.TestLoader() | 25 output = [] |
26 def LoadTests(module_name): | 26 output.extend(input_api.canned_checks.RunPythonUnitTests(input_api, |
27 module = __import__(module_name) | 27 output_api, |
28 for part in module_name.split('.')[1:]: | 28 unit_tests)) |
29 module = getattr(module, part) | 29 output.extend(input_api.canned_checks.CheckDoNotSubmit(input_api, |
30 tests_suite.extend(test_loader.loadTestsFromModule(module)._tests) | 30 output_api)) |
31 # List all the test modules to test here: | 31 return output |
32 LoadTests('tests.gcl_unittest') | |
33 LoadTests('tests.gclient_test') | |
34 LoadTests('tests.presubmit_unittest') | |
35 LoadTests('tests.trychange_unittest') | |
36 unittest.TextTestRunner(verbosity=0).run(unittest.TestSuite(tests_suite)) | |
37 # TODO(maruel): Find a way to block the check-in. | |
38 return [] | |
OLD | NEW |