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

Unified Diff: third_party/recipe_engine/lint_test.py

Issue 1151423002: Move recipe engine to third_party/recipe_engine. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Moved field_composer_test with its buddies Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/recipe_engine/field_composer.py ('k') | third_party/recipe_engine/loader.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/recipe_engine/lint_test.py
diff --git a/scripts/slave/unittests/recipe_lint_test.py b/third_party/recipe_engine/lint_test.py
old mode 100755
new mode 100644
similarity index 65%
copy from scripts/slave/unittests/recipe_lint_test.py
copy to third_party/recipe_engine/lint_test.py
index 5e98dc1223a9283a58c0f6fc807b954383e6a8fc..a737066e487cf1ece36191820afdf4d71c6a129f
--- a/scripts/slave/unittests/recipe_lint_test.py
+++ b/third_party/recipe_engine/lint_test.py
@@ -10,15 +10,15 @@ generally not safe in recipes if they depend on the platform, since
e.g. you can run a recipe simulation for a Windows recipe on Linux.
"""
+# TODO(luqui): Implement lint for recipe modules also.
+
import re
+import os
+import sys
import types
-import test_env # pylint: disable=W0611,W0403
-
-from slave import recipe_loader
-
-MODULES_WHITELIST = map(re.compile, [
+MODULES_WHITELIST = [
r'base64',
r'collections',
r'datetime',
@@ -26,16 +26,7 @@ MODULES_WHITELIST = map(re.compile, [
r'math',
r're',
r'urlparse',
-
- r'slave\.recipe_api',
-
- # TODO(luqui): Move skia modules into recipe resources
- r'common\.skia\..*',
- r'slave\.skia\..*',
-
- # TODO(luqui): Move cros modules into recipe resources
- r'common\.cros_chromite',
-])
+]
class ImportViolationError(Exception):
@@ -46,7 +37,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 +48,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 +57,13 @@ def ImportsTest(recipe_path, recipe_name, universe):
(recipe_path, module_name))
-def MainTest():
- universe = recipe_loader.RecipeUniverse()
+def main(universe, whitelist=[]):
+ whitelist = map(re.compile, MODULES_WHITELIST + 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()
« no previous file with comments | « third_party/recipe_engine/field_composer.py ('k') | third_party/recipe_engine/loader.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698