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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 import json
2
3 from slave import recipe_test_api
4
5 from .util import TestResults
6
7 class JsonTestApi(recipe_test_api.RecipeTestApi):
8 @recipe_test_api.placeholder_step_data
9 @staticmethod
10 def output(data, retcode=None):
11 return json.dumps(data), retcode
12
13 @recipe_test_api.placeholder_step_data
14 def test_results(self, test_results, retcode=None):
15 return self.output(test_results.as_jsonish(), retcode)
16
17 def canned_test_output(self, good, passes=9001):
18 """Produces a 'json test results' compatible object with some canned tests.
19 Args:
20 good - Determines if this test result is passing or not.
21 passes - The number of (theoretically) passing tests.
22 """
23 bad = lambda fail_val: None if good else fail_val
24 t = TestResults()
25 t.raw['num_passes'] = passes
26 t.add_result('good/totally-awesome.html', 'PASS')
27 t.add_result('flake/totally-flakey.html', 'PASS', bad('TIMEOUT PASS'))
28 t.add_result('tricky/totally-maybe-not-awesome.html', 'PASS', bad('FAIL'))
29 t.add_result('bad/totally-bad-probably.html', 'PASS', bad('FAIL'))
30 ret = self.test_results(t)
31 ret.retcode = 0 if good else 1
32 return ret
OLDNEW
« 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