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

Unified Diff: scripts/slave/recipe_modules/json/test_api.py

Issue 23889036: Refactor the way that TestApi works so that it is actually useful. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: rebase Created 7 years, 3 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/recipe_modules/json/test_api.py
diff --git a/scripts/slave/recipe_modules/json/test_api.py b/scripts/slave/recipe_modules/json/test_api.py
new file mode 100644
index 0000000000000000000000000000000000000000..e8a7f4574d10210e653f2d3739d663a25e6c5b81
--- /dev/null
+++ b/scripts/slave/recipe_modules/json/test_api.py
@@ -0,0 +1,31 @@
+from slave import recipe_test_api
+
+from .util import TestResults
+
+class JsonTestApi(recipe_test_api.RecipeTestApi):
+ @recipe_test_api.placeholder_step_data
+ @staticmethod
+ def output(data, retcode=None):
+ return data, retcode
+
+ @recipe_test_api.placeholder_step_data
+ @staticmethod
+ def test_results(test_results, retcode=None):
+ return test_results.as_jsonish(), retcode
+
+ def canned_test_output(self, good, passes=9001):
+ """Produces a 'json test results' compatible object with some canned tests.
+ Args:
+ good - Determines if this test result is passing or not.
+ passes - The number of (theoretically) passing tests.
+ """
+ bad = lambda fail_val: None if good else fail_val
+ t = TestResults()
+ t.raw['num_passes'] = passes
+ t.add_result('good/totally-awesome.html', 'PASS')
+ t.add_result('flake/totally-flakey.html', 'PASS', bad('TIMEOUT PASS'))
+ t.add_result('tricky/totally-maybe-not-awesome.html', 'PASS', bad('FAIL'))
+ t.add_result('bad/totally-bad-probably.html', 'PASS', bad('FAIL'))
+ ret = self.test_results(t)
+ ret.retcode = 0 if good else 1
+ return ret

Powered by Google App Engine
This is Rietveld 408576698