OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 simulator test coverage for individual recipes.""" | 6 """Provides simulator test coverage for individual recipes.""" |
7 | 7 |
8 import os | 8 import os |
9 | 9 |
10 # Importing for side effects on sys.path? Yes... yes we are :( | 10 # Importing for side effects on sys.path? Yes... yes we are :( |
(...skipping 11 matching lines...) Expand all Loading... |
22 def RunRecipe(test_data): | 22 def RunRecipe(test_data): |
23 stream = annotator.StructuredAnnotationStream(stream=open(os.devnull, 'w')) | 23 stream = annotator.StructuredAnnotationStream(stream=open(os.devnull, 'w')) |
24 recipe_config_types.ResetTostringFns() | 24 recipe_config_types.ResetTostringFns() |
25 # TODO(iannucci): Only pass test_data once. | 25 # TODO(iannucci): Only pass test_data once. |
26 result = annotated_run.run_steps(stream, test_data.properties, | 26 result = annotated_run.run_steps(stream, test_data.properties, |
27 test_data.properties, test_data) | 27 test_data.properties, test_data) |
28 return expect_tests.Result([s.step for s in result.steps_ran.itervalues()]) | 28 return expect_tests.Result([s.step for s in result.steps_ran.itervalues()]) |
29 | 29 |
30 | 30 |
31 def GenerateTests(): | 31 def GenerateTests(): |
32 mods = recipe_loader.load_recipe_modules(recipe_loader.MODULE_DIRS()) | |
33 | |
34 for recipe_path, recipe_name in recipe_loader.loop_over_recipes(): | 32 for recipe_path, recipe_name in recipe_loader.loop_over_recipes(): |
35 recipe = recipe_loader.load_recipe(recipe_name) | 33 recipe = recipe_loader.load_recipe(recipe_name) |
36 test_api = recipe_loader.create_test_api(recipe.DEPS) | 34 test_api = recipe_loader.create_test_api(recipe.DEPS) |
37 for test_data in recipe.GenTests(test_api): | 35 for test_data in recipe.GenTests(test_api): |
38 root, name = os.path.split(recipe_path) | 36 root, name = os.path.split(recipe_path) |
39 name = os.path.splitext(name)[0] | 37 name = os.path.splitext(name)[0] |
40 expect_path = os.path.join(root, '%s.expected' % name) | 38 expect_path = os.path.join(root, '%s.expected' % name) |
41 | 39 |
42 test_data.properties['recipe'] = recipe_name.replace('\\', '/') | 40 test_data.properties['recipe'] = recipe_name.replace('\\', '/') |
43 yield expect_tests.Test( | 41 yield expect_tests.Test( |
44 '%s.%s' % (recipe_name, test_data.name), | 42 '%s.%s' % (recipe_name, test_data.name), |
45 RunRecipe, args=(test_data,), | 43 RunRecipe, args=(test_data,), |
46 expect_dir=expect_path, | 44 expect_dir=expect_path, |
47 expect_base=test_data.name, | 45 expect_base=test_data.name, |
48 break_funcs=(mods.step.API.__call__, recipe.GenSteps) | 46 break_funcs=(recipe.GenSteps,) |
49 ) | 47 ) |
50 | 48 |
51 | 49 |
52 if __name__ == '__main__': | 50 if __name__ == '__main__': |
53 expect_tests.main('recipe_simulation_test', GenerateTests, ( | 51 expect_tests.main('recipe_simulation_test', GenerateTests, ( |
54 [os.path.join(x, '*') for x in recipe_util.RECIPE_DIRS()] + | 52 [os.path.join(x, '*') for x in recipe_util.RECIPE_DIRS()] + |
55 [os.path.join(x, '*', '*api.py') for x in recipe_util.MODULE_DIRS()] | 53 [os.path.join(x, '*', '*api.py') for x in recipe_util.MODULE_DIRS()] |
56 ), ( | 54 ), ( |
57 [os.path.join(x, '*', '*config.py') for x in recipe_util.MODULE_DIRS()] | 55 [os.path.join(x, '*', '*config.py') for x in recipe_util.MODULE_DIRS()] |
58 )) | 56 )) |
OLD | NEW |