| 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 bdb | 7 import bdb |
| 8 import cStringIO | 8 import cStringIO |
| 9 import contextlib | 9 import contextlib |
| 10 import copy | 10 import copy |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 # Run recipe loading under coverage context. This ensures we collect | 408 # Run recipe loading under coverage context. This ensures we collect |
| 409 # coverage of all definitions and globals. | 409 # coverage of all definitions and globals. |
| 410 recipe = _UNIVERSE_VIEW.load_recipe(recipe_name) | 410 recipe = _UNIVERSE_VIEW.load_recipe(recipe_name) |
| 411 test_api = loader.create_test_api(recipe.LOADED_DEPS, _UNIVERSE_VIEW) | 411 test_api = loader.create_test_api(recipe.LOADED_DEPS, _UNIVERSE_VIEW) |
| 412 | 412 |
| 413 root, name = os.path.split(recipe_path) | 413 root, name = os.path.split(recipe_path) |
| 414 name = os.path.splitext(name)[0] | 414 name = os.path.splitext(name)[0] |
| 415 # TODO(phajdan.jr): move expectation tree outside of the recipe tree. | 415 # TODO(phajdan.jr): move expectation tree outside of the recipe tree. |
| 416 expect_dir = os.path.join(root, '%s.expected' % name) | 416 expect_dir = os.path.join(root, '%s.expected' % name) |
| 417 | 417 |
| 418 if not recipe.gen_tests: |
| 419 raise Exception('Missing or misspelled GenTests function.') |
| 420 |
| 418 # Immediately convert to list to force running the generator under | 421 # Immediately convert to list to force running the generator under |
| 419 # coverage context. Otherwise coverage would only report executing | 422 # coverage context. Otherwise coverage would only report executing |
| 420 # the function definition, not GenTests body. | 423 # the function definition, not GenTests body. |
| 421 recipe_tests = list(recipe.gen_tests(test_api)) | 424 recipe_tests = list(recipe.gen_tests(test_api)) |
| 422 coverage_data.update(cov.get_data()) | 425 coverage_data.update(cov.get_data()) |
| 423 | 426 |
| 424 for test_data in recipe_tests: | 427 for test_data in recipe_tests: |
| 425 # Put the test data in shared cache. This way it can only be generated | 428 # Put the test data in shared cache. This way it can only be generated |
| 426 # once. We do this primarily for _correctness_ , for example in case | 429 # once. We do this primarily for _correctness_ , for example in case |
| 427 # a weird recipe generates tests non-deterministically. The recipe | 430 # a weird recipe generates tests non-deterministically. The recipe |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 | 944 |
| 942 # Prevent flakiness caused by stale pyc files. | 945 # Prevent flakiness caused by stale pyc files. |
| 943 package.cleanup_pyc(package_deps.root_package.recipes_dir) | 946 package.cleanup_pyc(package_deps.root_package.recipes_dir) |
| 944 | 947 |
| 945 global _UNIVERSE_VIEW | 948 global _UNIVERSE_VIEW |
| 946 _UNIVERSE_VIEW = universe_view | 949 _UNIVERSE_VIEW = universe_view |
| 947 global _ENGINE_FLAGS | 950 global _ENGINE_FLAGS |
| 948 _ENGINE_FLAGS = engine_flags | 951 _ENGINE_FLAGS = engine_flags |
| 949 | 952 |
| 950 return args.subfunc(args) | 953 return args.subfunc(args) |
| OLD | NEW |