Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2017 The LUCI Authors. All rights reserved. | 1 # Copyright 2017 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 from __future__ import print_function | 5 from __future__ import print_function |
| 6 | 6 |
| 7 import argparse | 7 import argparse |
| 8 import bdb | 8 import bdb |
| 9 import cStringIO | 9 import cStringIO |
| 10 import contextlib | 10 import contextlib |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 390 # Run recipe loading under coverage context. This ensures we collect | 390 # Run recipe loading under coverage context. This ensures we collect |
| 391 # coverage of all definitions and globals. | 391 # coverage of all definitions and globals. |
| 392 recipe = _UNIVERSE_VIEW.load_recipe(recipe_name) | 392 recipe = _UNIVERSE_VIEW.load_recipe(recipe_name) |
| 393 test_api = loader.create_test_api(recipe.LOADED_DEPS, _UNIVERSE_VIEW) | 393 test_api = loader.create_test_api(recipe.LOADED_DEPS, _UNIVERSE_VIEW) |
| 394 | 394 |
| 395 root, name = os.path.split(recipe_path) | 395 root, name = os.path.split(recipe_path) |
| 396 name = os.path.splitext(name)[0] | 396 name = os.path.splitext(name)[0] |
| 397 # TODO(phajdan.jr): move expectation tree outside of the recipe tree. | 397 # TODO(phajdan.jr): move expectation tree outside of the recipe tree. |
| 398 expect_dir = os.path.join(root, '%s.expected' % name) | 398 expect_dir = os.path.join(root, '%s.expected' % name) |
| 399 | 399 |
| 400 if not recipe.gen_tests: | |
| 401 raise Exception('Missing or misspelled GenTests function.') | |
|
iannucci
2017/04/27 19:28:33
Can you do the same for RunSteps too?
Paweł Hajdan Jr.
2017/05/08 18:03:51
Done.
Turns out it already works, just added a te
| |
| 402 | |
| 400 # Immediately convert to list to force running the generator under | 403 # Immediately convert to list to force running the generator under |
| 401 # coverage context. Otherwise coverage would only report executing | 404 # coverage context. Otherwise coverage would only report executing |
| 402 # the function definition, not GenTests body. | 405 # the function definition, not GenTests body. |
| 403 recipe_tests = list(recipe.gen_tests(test_api)) | 406 recipe_tests = list(recipe.gen_tests(test_api)) |
| 404 coverage_data.update(cov.get_data()) | 407 coverage_data.update(cov.get_data()) |
| 405 | 408 |
| 406 for test_data in recipe_tests: | 409 for test_data in recipe_tests: |
| 407 # Put the test data in shared cache. This way it can only be generated | 410 # Put the test data in shared cache. This way it can only be generated |
| 408 # once. We do this primarily for _correctness_ , for example in case | 411 # once. We do this primarily for _correctness_ , for example in case |
| 409 # a weird recipe generates tests non-deterministically. The recipe | 412 # a weird recipe generates tests non-deterministically. The recipe |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 903 Returns: | 906 Returns: |
| 904 Exit code | 907 Exit code |
| 905 """ | 908 """ |
| 906 global _UNIVERSE_VIEW | 909 global _UNIVERSE_VIEW |
| 907 _UNIVERSE_VIEW = universe_view | 910 _UNIVERSE_VIEW = universe_view |
| 908 global _ENGINE_FLAGS | 911 global _ENGINE_FLAGS |
| 909 _ENGINE_FLAGS = engine_flags | 912 _ENGINE_FLAGS = engine_flags |
| 910 | 913 |
| 911 args = parse_args(raw_args) | 914 args = parse_args(raw_args) |
| 912 return args.func(args) | 915 return args.func(args) |
| OLD | NEW |