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

Unified Diff: scripts/slave/unittests/expect_tests/util.py

Issue 354913003: Add module discovery and autoloading to expect_tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Fix formatting + comment Created 6 years, 6 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
Index: scripts/slave/unittests/expect_tests/util.py
diff --git a/scripts/slave/unittests/expect_tests/util.py b/scripts/slave/unittests/expect_tests/util.py
index 1061736ec57c74ace76cd931b57e6c78259333de..3f77c9c7b3cb25a3feb3376dea79f33bc995dd37 100644
--- a/scripts/slave/unittests/expect_tests/util.py
+++ b/scripts/slave/unittests/expect_tests/util.py
@@ -5,6 +5,7 @@
import inspect
EXPECT_TESTS_COVER_FUNCTION = 'EXPECT_TESTS_COVER_FUNCTION'
Vadim Sh. 2014/06/30 17:15:46 constant for this seems to be an overkill :) but a
+EXPECT_TESTS_GENERATOR = 'EXPECT_TESTS_GENERATOR'
def covers(coverage_path_function):
"""Allows annotation of a Test generator function with a function that will
@@ -20,8 +21,15 @@ def covers(coverage_path_function):
def get_cover_list(test_gen_function):
"""Given a Test generator, return the list of coverage globs that should
be included while executing the Test generator."""
- if hasattr(test_gen_function, EXPECT_TESTS_COVER_FUNCTION):
- # decorated with expect_tests.covers
- return test_gen_function._covers() # pylint: disable=W0212
- else:
- return [inspect.getabsfile(test_gen_function)]
+ return getattr(test_gen_function, EXPECT_TESTS_COVER_FUNCTION,
+ lambda: [inspect.getabsfile(test_gen_function)])()
+
+
+def test_generator(function):
+ """Marks function as an expect_tests Test generator"""
+ setattr(function, EXPECT_TESTS_GENERATOR, True)
+ return function
+
+
+def is_test_generator(function):
+ return getattr(function, EXPECT_TESTS_GENERATOR, False)
« no previous file with comments | « scripts/slave/unittests/expect_tests/unittest_helper.py ('k') | scripts/slave/unittests/recipe_simulation_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698