| 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()}}
|
|
|