OLD | NEW |
(Empty) | |
| 1 from slave import recipe_test_api |
| 2 |
| 3 from .util import TestResults |
| 4 |
| 5 class JsonTestApi(recipe_test_api.RecipeTestApi): |
| 6 @recipe_test_api.placeholder_step_data |
| 7 @staticmethod |
| 8 def output(data, retcode=None): |
| 9 return data, retcode |
| 10 |
| 11 @recipe_test_api.placeholder_step_data |
| 12 @staticmethod |
| 13 def test_results(test_results, retcode=None): |
| 14 return test_results.as_jsonish(), retcode |
| 15 |
| 16 def canned_test_output(self, good, passes=9001): |
| 17 """Produces a 'json test results' compatible object with some canned tests. |
| 18 Args: |
| 19 good - Determines if this test result is passing or not. |
| 20 passes - The number of (theoretically) passing tests. |
| 21 """ |
| 22 bad = lambda fail_val: None if good else fail_val |
| 23 t = TestResults() |
| 24 t.raw['num_passes'] = passes |
| 25 t.add_result('good/totally-awesome.html', 'PASS') |
| 26 t.add_result('flake/totally-flakey.html', 'PASS', bad('TIMEOUT PASS')) |
| 27 t.add_result('tricky/totally-maybe-not-awesome.html', 'PASS', bad('FAIL')) |
| 28 t.add_result('bad/totally-bad-probably.html', 'PASS', bad('FAIL')) |
| 29 ret = self.test_results(t) |
| 30 ret.retcode = 0 if good else 1 |
| 31 return ret |
OLD | NEW |