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

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

Issue 355143002: Set coverage path globs on a per-Test basis instead of in main(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: fix _covers Created 6 years, 5 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
« no previous file with comments | « scripts/slave/unittests/expect_tests/util.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 logging 8 import logging
9 import os 9 import os
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 break 48 break
49 ret.append({ 49 ret.append({
50 'name': '$final_result', 50 'name': '$final_result',
51 'status_code': result.status_code, 51 'status_code': result.status_code,
52 'reason': reason 52 'reason': reason
53 }) 53 })
54 54
55 return expect_tests.Result(ret) 55 return expect_tests.Result(ret)
56 56
57 57
58 def test_gen_coverage():
59 return (
60 [os.path.join(x, '*') for x in recipe_util.RECIPE_DIRS()] +
61 [os.path.join(x, '*', 'example.py') for x in recipe_util.MODULE_DIRS()] +
62 [os.path.join(x, '*', 'test_api.py') for x in recipe_util.MODULE_DIRS()]
63 )
64
65 @expect_tests.covers(test_gen_coverage)
58 def GenerateTests(): 66 def GenerateTests():
67 cover_mods = []
68 for mod_dir_base in recipe_util.MODULE_DIRS():
69 if os.path.isdir(mod_dir_base):
70 cover_mods.append(os.path.join(mod_dir_base, '*', '*api.py'))
71
59 for recipe_path, recipe_name in recipe_loader.loop_over_recipes(): 72 for recipe_path, recipe_name in recipe_loader.loop_over_recipes():
60 recipe = recipe_loader.load_recipe(recipe_name) 73 recipe = recipe_loader.load_recipe(recipe_name)
61 test_api = recipe_loader.create_test_api(recipe.DEPS) 74 test_api = recipe_loader.create_test_api(recipe.DEPS)
75
76 covers = cover_mods + [recipe_path]
77
62 for test_data in recipe.GenTests(test_api): 78 for test_data in recipe.GenTests(test_api):
63 root, name = os.path.split(recipe_path) 79 root, name = os.path.split(recipe_path)
64 name = os.path.splitext(name)[0] 80 name = os.path.splitext(name)[0]
65 expect_path = os.path.join(root, '%s.expected' % name) 81 expect_path = os.path.join(root, '%s.expected' % name)
66 82
67 test_data.properties['recipe'] = recipe_name.replace('\\', '/') 83 test_data.properties['recipe'] = recipe_name.replace('\\', '/')
68 yield expect_tests.Test( 84 yield expect_tests.Test(
69 '%s.%s' % (recipe_name, test_data.name), 85 '%s.%s' % (recipe_name, test_data.name),
70 expect_tests.FuncCall(RunRecipe, test_data), 86 expect_tests.FuncCall(RunRecipe, test_data),
71 expect_dir=expect_path, 87 expect_dir=expect_path,
72 expect_base=test_data.name, 88 expect_base=test_data.name,
89 covers=covers,
73 break_funcs=(recipe.GenSteps,) 90 break_funcs=(recipe.GenSteps,)
74 ) 91 )
75 92
76 93
77 if __name__ == '__main__': 94 if __name__ == '__main__':
78 # annotated_run.py has different behavior when these environment variables 95 # annotated_run.py has different behavior when these environment variables
79 # are set, so unset to make simulation tests environment-invariant. 96 # are set, so unset to make simulation tests environment-invariant.
80 for env_var in ['TESTING_MASTER_HOST', 97 for env_var in ['TESTING_MASTER_HOST',
81 'TESTING_MASTER', 98 'TESTING_MASTER',
82 'TESTING_SLAVENAME']: 99 'TESTING_SLAVENAME']:
83 if env_var in os.environ: 100 if env_var in os.environ:
84 logging.warn("Ignoring %s environment variable." % env_var) 101 logging.warn("Ignoring %s environment variable." % env_var)
85 os.environ.pop(env_var) 102 os.environ.pop(env_var)
86 103
87 expect_tests.main('recipe_simulation_test', GenerateTests, ( 104 expect_tests.main('recipe_simulation_test', GenerateTests)
88 [os.path.join(x, '*') for x in recipe_util.RECIPE_DIRS()] +
89 [os.path.join(x, '*', '*api.py') for x in recipe_util.MODULE_DIRS()]
90 ), (
91 [os.path.join(x, '*', '*config.py') for x in recipe_util.MODULE_DIRS()]
92 ))
OLDNEW
« no previous file with comments | « scripts/slave/unittests/expect_tests/util.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698