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

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: License headers 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
« no previous file with comments | « scripts/slave/recipe_modules/json/api.py ('k') | scripts/slave/recipe_modules/json/util.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..542e8fee97da45ddd1dbf67ef0e66b06853e8b38
--- /dev/null
+++ b/scripts/slave/recipe_modules/json/test_api.py
@@ -0,0 +1,32 @@
+import json
+
+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 json.dumps(data), retcode
+
+ @recipe_test_api.placeholder_step_data
+ def test_results(self, test_results, retcode=None):
+ return self.output(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
« no previous file with comments | « scripts/slave/recipe_modules/json/api.py ('k') | scripts/slave/recipe_modules/json/util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698