Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright (C) 2014 Google Inc. All rights reserved. | |
|
Dirk Pranke
2014/07/25 00:42:55
I would leave this as part of generate_results_das
patro
2014/07/25 05:14:34
Done.
| |
| 2 # | |
| 3 # Redistribution and use in source and binary forms, with or without | |
| 4 # modification, are permitted provided that the following conditions are | |
| 5 # met: | |
| 6 # | |
| 7 # * Redistributions of source code must retain the above copyright | |
| 8 # notice, this list of conditions and the following disclaimer. | |
| 9 # * Redistributions in binary form must reproduce the above | |
| 10 # copyright notice, this list of conditions and the following disclaimer | |
| 11 # in the documentation and/or other materials provided with the | |
| 12 # distribution. | |
| 13 # * Neither the name of Google Inc. nor the names of its | |
| 14 # contributors may be used to endorse or promote products derived from | |
| 15 # this software without specific prior written permission. | |
| 16 # | |
| 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 28 | |
| 29 | |
| 30 class ProcessJsonData(object): | |
| 31 | |
| 32 def __init__(self, current_result_json_dict, old_failing_results_list, old_f ull_results_list): | |
| 33 self._current_result_json_dict = current_result_json_dict | |
| 34 self._old_failing_results_list = old_failing_results_list | |
| 35 self._old_full_results_list = old_full_results_list | |
| 36 self._final_result = [] | |
| 37 | |
| 38 def _get_test_result(self, test_result_data): | |
| 39 actual = test_result_data['actual'] | |
| 40 expected = test_result_data['expected'] | |
| 41 if actual == 'SKIP': | |
| 42 return actual | |
| 43 if actual == expected: | |
| 44 return 'HASSTDERR' if test_result_data.get('has_stderr') == 'true' e lse 'PASS' | |
| 45 else: | |
| 46 return actual | |
| 47 | |
| 48 def _recurse_json_object(self, json_object, key_list): | |
| 49 for key in key_list: | |
| 50 try: | |
| 51 json_object = json_object[key] | |
| 52 except KeyError: | |
| 53 return 'NOTFOUND' | |
| 54 return self._get_test_result(json_object) | |
| 55 | |
| 56 def _process_previous_json_results(self, key_list): | |
| 57 row = [] | |
| 58 length = len(self._old_failing_results_list) | |
| 59 for index in range(0, length): | |
| 60 result = self._recurse_json_object(self._old_failing_results_list[in dex]["tests"], key_list) | |
| 61 if result == 'NOTFOUND': | |
| 62 result = self._recurse_json_object(self._old_full_results_list[i ndex]["tests"], key_list) | |
| 63 row.append(result) | |
| 64 return row | |
| 65 | |
| 66 def _add_archived_result(self, json_object, result): | |
| 67 json_object['archived_results'] = result | |
| 68 | |
| 69 def _process_json_object(self, json_object, keyList): | |
| 70 for key, subdict in json_object.iteritems(): | |
| 71 if type(subdict) == dict: | |
| 72 self._process_json_object(subdict, keyList + [key]) | |
| 73 else: | |
| 74 row = [self._get_test_result(json_object)] | |
| 75 row += self._process_previous_json_results(keyList) | |
| 76 json_object.clear() | |
| 77 self._add_archived_result(json_object, row) | |
| 78 return | |
| 79 | |
| 80 def generate_archived_result(self): | |
| 81 for key in self._current_result_json_dict["tests"]: | |
| 82 self._process_json_object(self._current_result_json_dict["tests"][ke y], [key]) | |
| 83 return self._current_result_json_dict | |
| OLD | NEW |