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

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: Move gclient test_api to got_revisions cl 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..7549bdcfc868bce215307f3dd9b280002ffd4796
--- /dev/null
+++ b/scripts/slave/recipe_modules/json/test_api.py
@@ -0,0 +1,27 @@
+from slave import recipe_api
+
+from .util import TestResults
+
+class JsonTestApi(recipe_api.RecipeTestApi):
+ @staticmethod
+ def output(data):
+ return {'json': {'output': data}}
+
+ @staticmethod
+ def test_output_object():
+ return TestResults()
+
+ 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 = self.test_output_object()
+ 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'))
+ return {'json': {'test_results': t.as_jsonish()}}

Powered by Google App Engine
This is Rietveld 408576698