OLD | NEW |
1 # Copyright 2014 Google Inc. All rights reserved. | 1 # Copyright 2014 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
4 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
5 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
6 # | 6 # |
7 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
8 # | 8 # |
9 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
10 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 full_results['num_failures_by_type'] = OrderedDict() | 85 full_results['num_failures_by_type'] = OrderedDict() |
86 full_results['num_failures_by_type']['FAIL'] = len(failed_tests) | 86 full_results['num_failures_by_type']['FAIL'] = len(failed_tests) |
87 full_results['num_failures_by_type']['PASS'] = len(passing_tests) | 87 full_results['num_failures_by_type']['PASS'] = len(passing_tests) |
88 full_results['num_failures_by_type']['SKIP'] = len(skipped_tests) | 88 full_results['num_failures_by_type']['SKIP'] = len(skipped_tests) |
89 | 89 |
90 full_results['tests'] = OrderedDict() | 90 full_results['tests'] = OrderedDict() |
91 | 91 |
92 for test_name in all_test_names: | 92 for test_name in all_test_names: |
93 value = OrderedDict() | 93 value = OrderedDict() |
| 94 value['actual'] = _actual_results_for_test(test_name, results) |
94 if test_name in skipped_tests: | 95 if test_name in skipped_tests: |
95 value['expected'] = 'SKIP' | 96 value['expected'] = 'SKIP' |
96 value['actual'] = 'SKIP' | |
97 else: | 97 else: |
98 value['expected'] = 'PASS' | 98 value['expected'] = 'PASS' |
99 value['actual'] = _actual_results_for_test(test_name, results) | |
100 if value['actual'].endswith('FAIL'): | 99 if value['actual'].endswith('FAIL'): |
101 value['is_unexpected'] = True | 100 value['is_unexpected'] = True |
102 _add_path_to_trie(full_results['tests'], test_name, value) | 101 _add_path_to_trie(full_results['tests'], test_name, value) |
103 | 102 |
104 return full_results | 103 return full_results |
105 | 104 |
106 | 105 |
107 def make_upload_request(test_results_server, builder, master, testtype, | 106 def make_upload_request(test_results_server, builder, master, testtype, |
108 full_results): | 107 full_results): |
109 url = 'http://%s/testfile/upload' % test_results_server | 108 url = 'http://%s/testfile/upload' % test_results_server |
(...skipping 10 matching lines...) Expand all Loading... |
120 | 119 |
121 def num_failures(full_results): | 120 def num_failures(full_results): |
122 return full_results['num_failures_by_type']['FAIL'] | 121 return full_results['num_failures_by_type']['FAIL'] |
123 | 122 |
124 | 123 |
125 def failed_test_names(results): | 124 def failed_test_names(results): |
126 names = set() | 125 names = set() |
127 for r in results.results: | 126 for r in results.results: |
128 if r.actual == ResultType.Failure: | 127 if r.actual == ResultType.Failure: |
129 names.add(r.name) | 128 names.add(r.name) |
130 elif r.actual == ResultType.Pass and r.name in names: | 129 elif ((r.actual == ResultType.Pass or r.actual == ResultType.Skip) |
| 130 and r.name in names): |
| 131 # This check indicates that a test failed, and then either passed |
| 132 # or was skipped on a retry. It is somewhat counterintuitive |
| 133 # that a test that failed and then skipped wouldn't be considered |
| 134 # failed, but that's at least consistent with a test that is |
| 135 # skipped every time. |
131 names.remove(r.name) | 136 names.remove(r.name) |
132 return names | 137 return names |
133 | 138 |
134 | 139 |
135 def _passing_test_names(results): | 140 def _passing_test_names(results): |
136 return set(r.name for r in results.results if r.actual == ResultType.Pass) | 141 return set(r.name for r in results.results if r.actual == ResultType.Pass) |
137 | 142 |
138 | 143 |
139 def _actual_results_for_test(test_name, results): | 144 def _actual_results_for_test(test_name, results): |
140 actuals = [] | 145 actuals = [] |
141 for r in results.results: | 146 for r in results.results: |
142 if r.name == test_name: | 147 if r.name == test_name: |
143 if r.actual == ResultType.Failure: | 148 if r.actual == ResultType.Failure: |
144 actuals.append('FAIL') | 149 actuals.append('FAIL') |
145 elif r.actual == ResultType.Pass: | 150 elif r.actual == ResultType.Pass: |
146 actuals.append('PASS') | 151 actuals.append('PASS') |
147 | 152 elif r.actual == ResultType.Skip: |
148 assert actuals, 'We did not find any result data for %s.' % test_name | 153 actuals.append('SKIP') |
| 154 if not actuals: |
| 155 actuals.append('SKIP') |
149 return ' '.join(actuals) | 156 return ' '.join(actuals) |
150 | 157 |
151 | 158 |
152 def _add_path_to_trie(trie, path, value): | 159 def _add_path_to_trie(trie, path, value): |
153 if TEST_SEPARATOR not in path: | 160 if TEST_SEPARATOR not in path: |
154 trie[path] = value | 161 trie[path] = value |
155 return | 162 return |
156 directory, rest = path.split(TEST_SEPARATOR, 1) | 163 directory, rest = path.split(TEST_SEPARATOR, 1) |
157 if directory not in trie: | 164 if directory not in trie: |
158 trie[directory] = {} | 165 trie[directory] = {} |
(...skipping 17 matching lines...) Expand all Loading... |
176 'filename="full_results.json"') | 183 'filename="full_results.json"') |
177 lines.append('Content-Type: application/json') | 184 lines.append('Content-Type: application/json') |
178 lines.append('') | 185 lines.append('') |
179 lines.append(json.dumps(test_results)) | 186 lines.append(json.dumps(test_results)) |
180 | 187 |
181 lines.append('--' + BOUNDARY + '--') | 188 lines.append('--' + BOUNDARY + '--') |
182 lines.append('') | 189 lines.append('') |
183 body = CRLF.join(lines) | 190 body = CRLF.join(lines) |
184 content_type = 'multipart/form-data; boundary=%s' % BOUNDARY | 191 content_type = 'multipart/form-data; boundary=%s' % BOUNDARY |
185 return content_type, body | 192 return content_type, body |
OLD | NEW |