Index: scripts/slave/unittests/recipe_simulation_test.py |
diff --git a/scripts/slave/unittests/recipe_simulation_test.py b/scripts/slave/unittests/recipe_simulation_test.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..ddec1e4db6ab2118fc4485a4e1e68fb955672f49 |
--- /dev/null |
+++ b/scripts/slave/unittests/recipe_simulation_test.py |
@@ -0,0 +1,58 @@ |
+#!/usr/bin/python |
+# Copyright 2014 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+"""Provides simulator test coverage for individual recipes.""" |
+ |
+import os |
+ |
+import test_env # pylint: disable=unused-import |
Vadim Sh.
2014/04/01 03:00:26
nit: from . import test_env? And same for expect_t
iannucci
2014/04/01 03:45:14
Can't when __name__ == __main__
|
+ |
+from common import annotator |
+from slave import annotated_run |
+from slave import recipe_config_types |
+from slave import recipe_loader |
+from slave import recipe_util |
+ |
+import expect_tests |
+ |
+ |
+def RunRecipe(test_data): |
+ stream = annotator.StructuredAnnotationStream(stream=open(os.devnull, 'w')) |
Vadim Sh.
2014/04/01 03:00:26
Does os.devnull work on windows?
iannucci
2014/04/01 03:45:14
yep. It's NUL
|
+ recipe_config_types.ResetTostringFns() |
+ # TODO(iannucci): Only pass test_data once. |
+ result = annotated_run.run_steps(stream, test_data.properties, |
+ test_data.properties, test_data) |
+ return expect_tests.Result([s.step for s in result.steps_ran.itervalues()]) |
+ |
+ |
+def GenerateTests(): |
+ mods = recipe_loader.load_recipe_modules(recipe_loader.MODULE_DIRS()) |
+ |
+ for recipe_path, recipe_name in recipe_loader.loop_over_recipes(): |
+ recipe = recipe_loader.load_recipe(recipe_name) |
+ test_api = recipe_loader.create_test_api(recipe.DEPS) |
+ for test_data in recipe.GenTests(test_api): |
+ root, name = os.path.split(recipe_path) |
+ name = os.path.splitext(name)[0] |
+ expect_path = os.path.join(root, '%s.expected' % name) |
+ |
+ test_data.properties['recipe'] = recipe_name |
+ yield expect_tests.Test( |
+ '%s.%s' % (recipe_name, test_data.name), |
+ RunRecipe, args=(test_data,), |
+ expectdir=expect_path, |
+ expectbase=test_data.name, |
+ break_funcs=(mods.step.API.__call__, |
+ recipe.GenSteps) |
+ ) |
+ |
+ |
+if __name__ == '__main__': |
+ expect_tests.main(GenerateTests, ( |
+ [os.path.join(x, '*') for x in recipe_util.RECIPE_DIRS()] + |
+ [os.path.join(x, '*', '*api.py') for x in recipe_util.MODULE_DIRS()] |
iannucci
2014/04/01 01:43:53
Note that this should really be '*.py', but that a
|
+ ), ( |
+ [os.path.join(x, '*', '*config.py') for x in recipe_util.MODULE_DIRS()] |
+ )) |