OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 """Provides test coverage for common recipe configurations. | 6 """Provides test coverage for common recipe configurations. |
7 | 7 |
8 recipe config expectations are located in ../recipe_configs_test/*.expected | 8 recipe config expectations are located in ../recipe_configs_test/*.expected |
9 | 9 |
10 In training mode, this will loop over every config item in ../recipe_configs.py | 10 In training mode, this will loop over every config item in ../recipe_configs.py |
(...skipping 15 matching lines...) Expand all Loading... |
26 from slave import recipe_util | 26 from slave import recipe_util |
27 | 27 |
28 import coverage | 28 import coverage |
29 | 29 |
30 SCRIPT_PATH = os.path.abspath(os.path.dirname(__file__)) | 30 SCRIPT_PATH = os.path.abspath(os.path.dirname(__file__)) |
31 SLAVE_DIR = os.path.abspath(os.path.join(SCRIPT_PATH, os.pardir)) | 31 SLAVE_DIR = os.path.abspath(os.path.join(SCRIPT_PATH, os.pardir)) |
32 | 32 |
33 COVERAGE = (lambda: coverage.coverage( | 33 COVERAGE = (lambda: coverage.coverage( |
34 include=[os.path.join(x, '*', '*config.py') | 34 include=[os.path.join(x, '*', '*config.py') |
35 for x in recipe_util.MODULE_DIRS()], | 35 for x in recipe_util.MODULE_DIRS()], |
36 data_suffix=True))() | 36 data_file='.recipe_configs_test_coverage', data_suffix=True))() |
37 | 37 |
38 def covered(fn, *args, **kwargs): | 38 def covered(fn, *args, **kwargs): |
39 COVERAGE.start() | 39 COVERAGE.start() |
40 try: | 40 try: |
41 return fn(*args, **kwargs) | 41 return fn(*args, **kwargs) |
42 finally: | 42 finally: |
43 COVERAGE.stop() | 43 COVERAGE.stop() |
44 | 44 |
45 RECIPE_MODULES = None | 45 RECIPE_MODULES = None |
46 def init_recipe_modules(): | 46 def init_recipe_modules(): |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 print 'FATAL: Recipes configs are not at 100% coverage.' | 146 print 'FATAL: Recipes configs are not at 100% coverage.' |
147 retcode = 2 | 147 retcode = 2 |
148 | 148 |
149 test_env.print_coverage_warning() | 149 test_env.print_coverage_warning() |
150 | 150 |
151 return retcode | 151 return retcode |
152 | 152 |
153 | 153 |
154 if __name__ == '__main__': | 154 if __name__ == '__main__': |
155 sys.exit(main(sys.argv)) | 155 sys.exit(main(sys.argv)) |
OLD | NEW |