Chromium Code Reviews| Index: third_party/recipe_engine/recipe_lint_test.py |
| diff --git a/scripts/slave/unittests/recipe_lint_test.py b/third_party/recipe_engine/recipe_lint_test.py |
| old mode 100755 |
| new mode 100644 |
| similarity index 76% |
| copy from scripts/slave/unittests/recipe_lint_test.py |
| copy to third_party/recipe_engine/recipe_lint_test.py |
| index 5e98dc1223a9283a58c0f6fc807b954383e6a8fc..432d55398cdec75f391bc5a3805a6bc5f75b131b |
| --- a/scripts/slave/unittests/recipe_lint_test.py |
| +++ b/third_party/recipe_engine/recipe_lint_test.py |
| @@ -11,14 +11,14 @@ e.g. you can run a recipe simulation for a Windows recipe on Linux. |
| """ |
| import re |
| +import os |
| +import sys |
| import types |
| -import test_env # pylint: disable=W0611,W0403 |
| +from . import recipe_loader |
| -from slave import recipe_loader |
| - |
| -MODULES_WHITELIST = map(re.compile, [ |
| +MODULES_WHITELIST = [ |
| r'base64', |
| r'collections', |
| r'datetime', |
| @@ -35,7 +35,7 @@ MODULES_WHITELIST = map(re.compile, [ |
| # TODO(luqui): Move cros modules into recipe resources |
| r'common\.cros_chromite', |
|
iannucci
2015/05/27 02:03:27
added more modules and they got rebased away or so
luqui
2015/05/28 21:47:38
Done.
|
| -]) |
| +] |
| class ImportViolationError(Exception): |
| @@ -46,7 +46,7 @@ class TestFailure(Exception): |
| pass |
| -def ImportsTest(recipe_path, recipe_name, universe): |
| +def ImportsTest(recipe_path, recipe_name, whitelist, universe): |
| """Tests that recipe_name only uses allowed imports. |
| Returns a list of errors, or an empty list if there are no errors (duh). |
| @@ -57,7 +57,7 @@ def ImportsTest(recipe_path, recipe_name, universe): |
| val = getattr(recipe, attr) |
| if isinstance(val, types.ModuleType): |
| module_name = val.__name__ |
| - for pattern in MODULES_WHITELIST: |
| + for pattern in whitelist: |
| if pattern.match(val.__name__): |
| break |
| else: |
| @@ -66,16 +66,13 @@ def ImportsTest(recipe_path, recipe_name, universe): |
| (recipe_path, module_name)) |
| -def MainTest(): |
| - universe = recipe_loader.RecipeUniverse() |
| +def main(universe, whitelist=MODULES_WHITELIST): |
|
iannucci
2015/05/27 02:03:27
y u do whitelist?
luqui
2015/05/28 21:47:38
It was because e.g. common.skia didn't belong in h
|
| + whitelist = map(re.compile, whitelist) |
| errors = [] |
| - for recipe_path, recipe_name in recipe_loader.loop_over_recipes(): |
| - errors.extend(ImportsTest(recipe_path, recipe_name, universe)) |
| + for recipe_path, recipe_name in universe.loop_over_recipes(): |
| + errors.extend(ImportsTest(recipe_path, recipe_name, whitelist, universe)) |
| if errors: |
| raise TestFailure('\n'.join(map(str, errors))) |
| - |
| -if __name__ == '__main__': |
| - MainTest() |