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

Unified Diff: scripts/slave/recipe_modules/test_utils/api.py

Issue 313693003: Swarming: conditionally run tests on swarming in chromium_trybot recipe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: rebase 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
« no previous file with comments | « scripts/slave/recipe_modules/swarming/api.py ('k') | scripts/slave/recipes/chromium_trybot.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/slave/recipe_modules/test_utils/api.py
diff --git a/scripts/slave/recipe_modules/test_utils/api.py b/scripts/slave/recipe_modules/test_utils/api.py
index a91b801feb820c1bbfeac33cb411ff90788e3e52..c8c133d276e86c0e80bf72fd9bbbbfe69f93b67d 100644
--- a/scripts/slave/recipe_modules/test_utils/api.py
+++ b/scripts/slave/recipe_modules/test_utils/api.py
@@ -46,10 +46,18 @@ class TestUtilsApi(recipe_api.RecipeApi):
"""Name of the test."""
raise NotImplementedError()
+ def pre_run(self, suffix): # pragma: no cover
+ """Steps to execute before running the test."""
+ return []
+
def run(self, suffix): # pragma: no cover
"""Run the test. suffix is 'with patch' or 'without patch'."""
raise NotImplementedError()
+ def post_run(self, suffix): # pragma: no cover
+ """Steps to execute after running the test."""
+ return []
+
def has_valid_results(self, suffix): # pragma: no cover
"""
Returns True if results (failures) are valid.
@@ -79,6 +87,9 @@ class TestUtilsApi(recipe_api.RecipeApi):
deapply_patch_fn - function that takes a list of failing tests
and undoes any effect of the previously applied patch
"""
+ # Convert iterable to list, since it is enumerated multiple times.
+ tests = list(tests)
+
if self.m.step_history.failed:
yield self.m.python.inline(
'Aborting due to failed build state.',
@@ -86,7 +97,12 @@ class TestUtilsApi(recipe_api.RecipeApi):
always_run=True, abort_on_failure=True)
return # won't actually hit this, but be explicit
- yield (t.run('with patch') for t in tests)
+ def run(prefix, tests):
+ yield (t.pre_run(prefix) for t in tests)
+ yield (t.run(prefix) for t in tests)
+ yield (t.post_run(prefix) for t in tests)
+
+ yield run('with patch', tests)
failing_tests = []
for t in tests:
@@ -106,7 +122,7 @@ class TestUtilsApi(recipe_api.RecipeApi):
yield deapply_patch_fn(failing_tests)
- yield (t.run('without patch') for t in failing_tests)
+ yield run('without patch', failing_tests)
yield (self._summarize_retried_test(t) for t in failing_tests)
def _summarize_retried_test(self, test):
« no previous file with comments | « scripts/slave/recipe_modules/swarming/api.py ('k') | scripts/slave/recipes/chromium_trybot.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698