Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Side by Side Diff: scripts/slave/unittests/recipe_simulation_test.py

Issue 220353003: Replace recipes_test.py with a new parallel expectation-based test runner. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/python
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
4 # found in the LICENSE file.
5
6 """Provides simulator test coverage for individual recipes."""
7
8 import os
9
10 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__
11
12 from common import annotator
13 from slave import annotated_run
14 from slave import recipe_config_types
15 from slave import recipe_loader
16 from slave import recipe_util
17
18 import expect_tests
19
20
21 def RunRecipe(test_data):
22 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
23 recipe_config_types.ResetTostringFns()
24 # TODO(iannucci): Only pass test_data once.
25 result = annotated_run.run_steps(stream, test_data.properties,
26 test_data.properties, test_data)
27 return expect_tests.Result([s.step for s in result.steps_ran.itervalues()])
28
29
30 def GenerateTests():
31 mods = recipe_loader.load_recipe_modules(recipe_loader.MODULE_DIRS())
32
33 for recipe_path, recipe_name in recipe_loader.loop_over_recipes():
34 recipe = recipe_loader.load_recipe(recipe_name)
35 test_api = recipe_loader.create_test_api(recipe.DEPS)
36 for test_data in recipe.GenTests(test_api):
37 root, name = os.path.split(recipe_path)
38 name = os.path.splitext(name)[0]
39 expect_path = os.path.join(root, '%s.expected' % name)
40
41 test_data.properties['recipe'] = recipe_name
42 yield expect_tests.Test(
43 '%s.%s' % (recipe_name, test_data.name),
44 RunRecipe, args=(test_data,),
45 expectdir=expect_path,
46 expectbase=test_data.name,
47 break_funcs=(mods.step.API.__call__,
48 recipe.GenSteps)
49 )
50
51
52 if __name__ == '__main__':
53 expect_tests.main(GenerateTests, (
54 [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()]
iannucci 2014/04/01 01:43:53 Note that this should really be '*.py', but that a
56 ), (
57 [os.path.join(x, '*', '*config.py') for x in recipe_util.MODULE_DIRS()]
58 ))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698