Changeset 89198 in webkit
- Timestamp:
- Jun 18, 2011 12:45:43 PM (13 years ago)
- Location:
- trunk/Tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r89196 r89198 1 2011-06-18 Alice Boxhall <aboxhall@chromium.org> 2 3 Reviewed by Ojan Vafai. 4 5 Convert json_results_generator.py to output version 4 JSON. 6 https://bugs.webkit.org/show_bug.cgi?id=60869 7 8 * Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py: 9 * Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py: 10 * Scripts/webkitpy/layout_tests/layout_package/json_results_generator_unittest.py: 11 1 12 2011-06-18 Berend-Jan Wever <skylined@chromium.org> 2 13 -
trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py
r87080 r89198 131 131 132 132 # override 133 def _convert_json_to_current_version(self, results_json):134 archive_version = None135 if self.VERSION_KEY in results_json:136 archive_version = results_json[self.VERSION_KEY]137 138 super(JSONLayoutResultsGenerator,139 self)._convert_json_to_current_version(results_json)140 141 # version 2->3142 if archive_version == 2:143 for results_for_builder in results_json.itervalues():144 try:145 test_results = results_for_builder[self.TESTS]146 except:147 continue148 149 for test in test_results:150 # Make sure all paths are relative151 test_path = self._get_path_relative_to_layout_test_root(test)152 if test_path != test:153 test_results[test_path] = test_results[test]154 del test_results[test]155 156 # override157 133 def _insert_failure_summaries(self, results_for_builder): 158 134 summary = self._result_summary -
trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py
r87080 r89198 68 68 filesystem.write_text_file(file_path, json_string) 69 69 70 71 def convert_trie_to_flat_paths(trie, prefix=None): 72 """Converts the directory structure in the given trie to flat paths, prepending a prefix to each.""" 73 result = {} 74 for name, data in trie.iteritems(): 75 if prefix: 76 name = prefix + "/" + name 77 78 if not "results" in data: 79 result.update(convert_trie_to_flat_paths(data, name)) 80 else: 81 result[name] = data 82 83 return result 84 85 86 def add_path_to_trie(path, value, trie): 87 """Inserts a single flat directory path and associated value into a directory trie structure.""" 88 if not "/" in path: 89 trie[path] = value 90 return 91 92 directory, slash, rest = path.partition("/") 93 if not directory in trie: 94 trie[directory] = {} 95 add_path_to_trie(rest, value, trie[directory]) 96 70 97 def test_timings_trie(port, individual_test_timings): 71 98 """Breaks a filename into chunks by directory and puts the test time as a value in the lowest part, e.g. … … 89 116 test = test_result.filename 90 117 91 parts = test.split('/') 92 current_map = trie 93 for i, part in enumerate(parts): 94 if i == (len(parts) - 1): 95 current_map[part] = int(1000 * test_result.test_run_time) 96 break 97 98 if part not in current_map: 99 current_map[part] = {} 100 current_map = current_map[part] 118 add_path_to_trie(test, int(1000 * test_result.test_run_time), trie) 119 101 120 return trie 102 121 … … 154 173 TestResult.FLAKY: FLAKY_RESULT} 155 174 156 VERSION = 3175 VERSION = 4 157 176 VERSION_KEY = "version" 158 177 RESULTS = "results" … … 272 291 tests = results_for_builder[self.TESTS] 273 292 all_failing_tests = self._get_failed_test_names() 274 all_failing_tests.update(tests.iterkeys()) 293 all_failing_tests.update(convert_trie_to_flat_paths(tests)) 294 275 295 for test in all_failing_tests: 276 296 self._insert_test_time_and_result(test, tests) … … 513 533 self.TIME) 514 534 535 515 536 def _insert_test_time_and_result(self, test_name, tests): 516 537 """ Insert a test item with its results to the given tests dictionary. … … 523 544 time = self._get_test_timing(test_name) 524 545 525 if test_name not in tests: 526 tests[test_name] = self._create_results_and_times_json() 527 528 thisTest = tests[test_name] 529 if self.RESULTS in thisTest: 530 self._insert_item_run_length_encoded(result, thisTest[self.RESULTS]) 531 else: 532 thisTest[self.RESULTS] = [[1, result]] 533 534 if self.TIMES in thisTest: 535 self._insert_item_run_length_encoded(time, thisTest[self.TIMES]) 536 else: 537 thisTest[self.TIMES] = [[1, time]] 546 this_test = tests 547 for segment in test_name.split("/"): 548 if segment not in this_test: 549 this_test[segment] = {} 550 this_test = this_test[segment] 551 552 if not len(this_test): 553 self._populate_results_and_times_json(this_test) 554 555 if self.RESULTS in this_test: 556 self._insert_item_run_length_encoded(result, this_test[self.RESULTS]) 557 else: 558 this_test[self.RESULTS] = [[1, result]] 559 560 if self.TIMES in this_test: 561 self._insert_item_run_length_encoded(time, this_test[self.TIMES]) 562 else: 563 this_test[self.TIMES] = [[1, time]] 538 564 539 565 def _convert_json_to_current_version(self, results_json): … … 541 567 current version and adds in the new version number. 542 568 """ 543 if (self.VERSION_KEY in results_json and 544 results_json[self.VERSION_KEY] == self.VERSION): 569 if self.VERSION_KEY in results_json: 570 archive_version = results_json[self.VERSION_KEY] 571 if archive_version == self.VERSION: 572 return 573 else: 574 archive_version = 3 575 576 # version 3->4 577 if archive_version == 3: 578 num_results = len(results_json.values()) 579 for builder, results in results_json.iteritems(): 580 self._convert_tests_to_trie(results) 581 582 results_json[self.VERSION_KEY] = self.VERSION 583 584 def _convert_tests_to_trie(self, results): 585 if not self.TESTS in results: 545 586 return 546 587 547 results_json[self.VERSION_KEY] = self.VERSION 548 549 def _create_results_and_times_json(self): 550 results_and_times = {} 588 test_results = results[self.TESTS] 589 test_results_trie = {} 590 for test in test_results.iterkeys(): 591 test_path = self._get_path_relative_to_layout_test_root(test) 592 single_test_result = test_results[test] 593 add_path_to_trie(test_path, single_test_result, test_results_trie) 594 595 results[self.TESTS] = test_results_trie 596 597 def _populate_results_and_times_json(self, results_and_times): 551 598 results_and_times[self.RESULTS] = [] 552 599 results_and_times[self.TIMES] = [] -
trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator_unittest.py
r87080 r89198 157 157 tests = buildinfo[JRG.TESTS] 158 158 for test_name in failed_count_map.iterkeys(): 159 self.assertTrue(test_name in tests) 160 test = tests[test_name] 159 test = self._find_test_in_trie(test_name, tests) 161 160 162 161 failed = 0 … … 174 173 if fixable_count: 175 174 self.assertEqual(sum(buildinfo[JRG.FIXABLE_COUNT]), fixable_count) 175 176 def _find_test_in_trie(self, path, trie): 177 nodes = path.split("/") 178 sub_trie = trie 179 for node in nodes: 180 self.assertTrue(node in sub_trie) 181 sub_trie = sub_trie[node] 182 return sub_trie 176 183 177 184 def test_json_generation(self): … … 197 204 ['FLAKY_B', 'DISABLED_C', 'FAILS_D'], 198 205 ['A', 'FLAKY_E']) 206 207 def test_hierarchical_json_generation(self): 208 # FIXME: Re-work tests to be more comprehensible and comprehensive. 209 self._test_json_generation(['foo/A'], ['foo/B', 'bar/C']) 199 210 200 211 def test_test_timings_trie(self):
Note: See TracChangeset
for help on using the changeset viewer.