| OLD | NEW |
| 1 import json | 1 import json |
| 2 | 2 |
| 3 from recipe_engine import recipe_test_api | 3 from recipe_engine import recipe_test_api |
| 4 | 4 |
| 5 from .util import GTestResults, TestResults | 5 from .util import GTestResults, TestResults |
| 6 | 6 |
| 7 class TestUtilsTestApi(recipe_test_api.RecipeTestApi): | 7 class TestUtilsTestApi(recipe_test_api.RecipeTestApi): |
| 8 @recipe_test_api.placeholder_step_data | 8 @recipe_test_api.placeholder_step_data |
| 9 def test_results(self, test_results, retcode=None): | 9 def test_results(self, test_results, retcode=None): |
| 10 return self.m.json.output(test_results.as_jsonish(), retcode) | 10 return self.m.json.output(test_results.as_jsonish(), retcode) |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 105 |
| 106 retcode = None if passing else 1 | 106 retcode = None if passing else 1 |
| 107 return self.raw_gtest_output(canned_jsonish, retcode) | 107 return self.raw_gtest_output(canned_jsonish, retcode) |
| 108 | 108 |
| 109 def raw_gtest_output(self, jsonish, retcode): | 109 def raw_gtest_output(self, jsonish, retcode): |
| 110 t = GTestResults(jsonish) | 110 t = GTestResults(jsonish) |
| 111 ret = self.gtest_results(t) | 111 ret = self.gtest_results(t) |
| 112 ret.retcode = retcode | 112 ret.retcode = retcode |
| 113 return ret | 113 return ret |
| 114 | 114 |
| 115 def canned_telemetry_gpu_output(self, passing, is_win, swarming=False, | |
| 116 empty_per_page_values=False): | |
| 117 """Produces a 'json test results' compatible object for telemetry tests.""" | |
| 118 if empty_per_page_values: | |
| 119 jsonish_results = { | |
| 120 'per_page_values': [], | |
| 121 'pages': { }, | |
| 122 } | |
| 123 else: | |
| 124 jsonish_results = { | |
| 125 'per_page_values': [{'type': 'success' if passing else 'failure', | |
| 126 'page_id': 0}, | |
| 127 {'type': 'success', | |
| 128 'page_id': 1}], | |
| 129 'pages': {'0': {'name': 'Test.Test1'}, | |
| 130 '1': {'name': 'Test.Test2'}}, | |
| 131 } | |
| 132 | |
| 133 jsonish_summary = { | |
| 134 'shards': [ | |
| 135 { | |
| 136 'failure': not passing, | |
| 137 'internal_failure': False | |
| 138 } | |
| 139 ] | |
| 140 } | |
| 141 | |
| 142 swarming_path = '0\\results.json' if is_win else '0/results.json' | |
| 143 results_path = swarming_path if swarming else 'results.json' | |
| 144 files_dict = { | |
| 145 results_path: json.dumps(jsonish_results), | |
| 146 'summary.json': json.dumps(jsonish_summary) | |
| 147 } | |
| 148 return self.m.raw_io.output_dir(files_dict) | |
| 149 | |
| 150 def canned_isolated_script_output(self, passing, is_win, swarming=False, | 115 def canned_isolated_script_output(self, passing, is_win, swarming=False, |
| 151 swarming_internal_failure=False, | 116 swarming_internal_failure=False, |
| 152 isolated_script_passing=True, valid=True): | 117 isolated_script_passing=True, valid=True): |
| 153 """Produces a test results' compatible json for isolated script tests. """ | 118 """Produces a test results' compatible json for isolated script tests. """ |
| 154 jsonish_results = {} | 119 jsonish_results = {} |
| 155 jsonish_results['valid'] = valid | 120 jsonish_results['valid'] = valid |
| 156 if isolated_script_passing: | 121 if isolated_script_passing: |
| 157 jsonish_results['failures'] = [] | 122 jsonish_results['failures'] = [] |
| 158 else: | 123 else: |
| 159 jsonish_results['failures'] = ['test1.Test1', 'test2.Test2'] | 124 jsonish_results['failures'] = ['test1.Test1', 'test2.Test2'] |
| 160 | 125 |
| 161 jsonish_summary = { | 126 jsonish_summary = { |
| 162 'shards': [ | 127 'shards': [ |
| 163 { | 128 { |
| 164 'failure': not passing, | 129 'failure': not passing, |
| 165 'internal_failure': swarming_internal_failure | 130 'internal_failure': swarming_internal_failure |
| 166 } | 131 } |
| 167 ] | 132 ] |
| 168 } | 133 } |
| 169 | 134 |
| 170 if swarming: | 135 if swarming: |
| 171 swarming_path = '0\\output.json' if is_win else '0/output.json' | 136 swarming_path = '0\\output.json' if is_win else '0/output.json' |
| 172 files_dict = { | 137 files_dict = { |
| 173 swarming_path: json.dumps(jsonish_results), | 138 swarming_path: json.dumps(jsonish_results), |
| 174 'summary.json': json.dumps(jsonish_summary) | 139 'summary.json': json.dumps(jsonish_summary) |
| 175 } | 140 } |
| 176 return self.m.raw_io.output_dir(files_dict) | 141 return self.m.raw_io.output_dir(files_dict) |
| 177 else: | 142 else: |
| 178 return self.m.json.output(jsonish_results) | 143 return self.m.json.output(jsonish_results) |
| OLD | NEW |