Changeset 80090 in webkit
- Timestamp:
- Mar 1, 2011 8:44:13 PM (13 years ago)
- Location:
- trunk/Tools
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r80086 r80090 1 2011-02-28 Ojan Vafai <ojan@chromium.org> 2 3 Reviewed by Tony Chang. 4 5 wrap json in a function call to afford cross-domain loading 6 https://bugs.webkit.org/show_bug.cgi?id=55353 7 8 Also delete the code that compacts the JSON. It turns out this 9 breaks the rebaseline tool and is probably a premature optimization anyways. 10 11 * Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py: 12 * Scripts/webkitpy/layout_tests/layout_package/test_runner.py: 13 * Scripts/webkitpy/layout_tests/run_webkit_tests.py: 14 * Scripts/webkitpy/tool/commands/rebaselineserver.py: 15 1 16 2011-03-01 Sheriff Bot <webkit.review.bot@gmail.com> 2 17 -
trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py
r79837 r80090 43 43 _log = logging.getLogger("webkitpy.layout_tests.layout_package.json_results_generator") 44 44 45 _JSON_PREFIX = "ADD_RESULTS(" 46 _JSON_SUFFIX = ");" 47 48 49 def strip_json_wrapper(json_content): 50 return json_content[len(_JSON_PREFIX):len(json_content) - len(_JSON_SUFFIX)] 51 52 53 def load_json(filesystem, file_path): 54 content = filesystem.read_text_file(file_path) 55 content = strip_json_wrapper(content) 56 return simplejson.loads(content) 57 58 59 def write_json(filesystem, json_object, file_path): 60 # Specify separators in order to get compact encoding. 61 json_data = simplejson.dumps(json_object, separators=(',', ':')) 62 json_string = _JSON_PREFIX + json_data + _JSON_SUFFIX 63 filesystem.write_text_file(file_path, json_string) 64 45 65 # FIXME: We already have a TestResult class in test_results.py 46 66 class TestResult(object): … … 81 101 # Min time (seconds) that will be added to the JSON. 82 102 MIN_TIME = 1 83 JSON_PREFIX = "ADD_RESULTS("84 JSON_SUFFIX = ");"85 103 86 104 # Note that in non-chromium tests those chars are used to indicate … … 170 188 json = self.get_json() 171 189 if json: 172 self._generate_json_file(json, self.INCREMENTAL_RESULTS_FILENAME) 190 file_path = self._fs.join(self._results_directory, self.INCREMENTAL_RESULTS_FILENAME) 191 write_json(self._fs, json, file_path) 173 192 174 193 def generate_full_results_file(self): … … 187 206 188 207 results['tests'] = tests 189 self._generate_json_file(results, self.FULL_RESULTS_FILENAME) 208 file_path = self._fs.join(self._results_directory, self.FULL_RESULTS_FILENAME) 209 write_json(self._fs, results, file_path) 190 210 191 211 def get_json(self): … … 262 282 263 283 _log.info("JSON files uploaded.") 264 265 def _generate_json_file(self, json, filename):266 # Specify separators in order to get compact encoding.267 json_data = simplejson.dumps(json, separators=(',', ':'))268 json_string = self.JSON_PREFIX + json_data + self.JSON_SUFFIX269 file_path = self._fs.join(self._results_directory, filename)270 self._fs.write_text_file(file_path, json_string)271 284 272 285 def _get_test_timing(self, test_name): … … 372 385 if old_results: 373 386 # Strip the prefix and suffix so we can get the actual JSON object. 374 old_results = old_results[len(self.JSON_PREFIX): 375 len(old_results) - len(self.JSON_SUFFIX)] 387 old_results = strip_json_wrapper(old_results) 376 388 377 389 try: -
trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/test_runner.py
r79973 r80090 47 47 import time 48 48 49 from result_summary import ResultSummary50 from test_input import TestInput51 52 import dump_render_tree_thread 53 import json_layout_results_generator 54 import message_broker 55 import printing 56 import test_expectations57 import test_failures 58 import test_results 59 import test_results_uploader 49 from webkitpy.layout_tests.layout_package import dump_render_tree_thread 50 from webkitpy.layout_tests.layout_package import json_layout_results_generator 51 from webkitpy.layout_tests.layout_package import json_results_generator 52 from webkitpy.layout_tests.layout_package import message_broker 53 from webkitpy.layout_tests.layout_package import printing 54 from webkitpy.layout_tests.layout_package import test_expectations 55 from webkitpy.layout_tests.layout_package import test_failures 56 from webkitpy.layout_tests.layout_package import test_results 57 from webkitpy.layout_tests.layout_package import test_results_uploader 58 from webkitpy.layout_tests.layout_package.result_summary import ResultSummary 59 from webkitpy.layout_tests.layout_package.test_input import TestInput 60 60 61 61 from webkitpy.thirdparty import simplejson … … 813 813 return json_layout_results_generator.JSONLayoutResultsGenerator.FAILURE_TO_CHAR[result_enum_value] 814 814 815 def _dump_summarized_result(self, filename, results):816 """Compacts the results and dumps them to a file as JSON.817 818 Args:819 filename: filename to dump the JSON to820 results: dict of results as returned by the summarize_results function821 """822 new_results = copy.deepcopy(results)823 824 # Compact the results since we'll be uploading this to the test-results server.825 # This shrinks the file size by ~20%.826 # actual --> a827 # expected --> e828 # time --> t829 # The results are shrunken as per the FAILURE_TO_CHAR map, e.g., "PASS CRASH" --> "PC"830 for test in new_results['tests']:831 result = new_results['tests'][test]832 833 result['a'] = ''.join([self._char_for_result(actual) for actual in result['actual'].split(' ')])834 del(result['actual'])835 836 result['e'] = ''.join([self._char_for_result(expected) for expected in result['expected'].split(' ')])837 del(result['expected'])838 839 if 'time_ms' in result:840 result['t'] = result['time_ms']841 del(result['time_ms'])842 843 unexpected_json_path = self._fs.join(self._options.results_directory, filename)844 with self._fs.open_text_file_for_writing(unexpected_json_path) as file:845 simplejson.dump(new_results, file, sort_keys=True, separators=(',', ':'))846 847 815 def _upload_json_files(self, unexpected_results, summarized_results, result_summary, 848 816 individual_test_timings): … … 866 834 _log.debug("Writing JSON files in %s." % self._options.results_directory) 867 835 868 self._dump_summarized_result("unexpected_results.json", unexpected_results) 869 self._dump_summarized_result("full_results.json", summarized_results) 836 unexpected_json_path = self._fs.join(self._options.results_directory, "unexpected_results.json") 837 json_results_generator.write_json(self._fs, unexpected_results, unexpected_json_path) 838 839 full_results_path = self._fs.join(self._options.results_directory, "full_results.json") 840 json_results_generator.write_json(self._fs, summarized_results, full_results_path) 870 841 871 842 # Write a json file of the test_expectations.txt file for the layout -
trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py
r79847 r80090 38 38 import sys 39 39 40 from layout_package import json_results_generator 40 41 from layout_package import printing 41 42 from layout_package import test_runner … … 172 173 last_unexpected_results = [] 173 174 if options.print_last_failures or options.retest_last_failures: 174 unexpected_results_filename = filesystem.join( 175 options.results_directory, "unexpected_results.json") 175 unexpected_results_filename = filesystem.join(options.results_directory, "unexpected_results.json") 176 176 if filesystem.exists(unexpected_results_filename): 177 content = filesystem.read_text_file(unexpected_results_filename) 178 results = simplejson.loads(content) 177 results = json_results_generator.load_json(filesystem, unexpected_results_filename) 179 178 last_unexpected_results = results['tests'].keys() 180 179 return last_unexpected_results -
trunk/Tools/Scripts/webkitpy/tool/commands/rebaselineserver.py
r73320 r80090 48 48 49 49 from webkitpy.common import system 50 from webkitpy.layout_tests.layout_package import json_results_generator 50 51 from webkitpy.layout_tests.port import factory 51 52 from webkitpy.layout_tests.port.webkit import WebKitPort … … 415 416 416 417 print 'Parsing unexpected_results.json...' 417 results_json_path = filesystem.join( 418 results_directory, 'unexpected_results.json') 419 with codecs.open(results_json_path, "r") as results_json_file: 420 results_json_file = file(results_json_path) 421 results_json = simplejson.load(results_json_file) 418 results_json_path = filesystem.join(results_directory, 'unexpected_results.json') 419 results_json = json_results_generator.load_json(filesystem, results_json_path) 422 420 423 421 port = factory.get()
Note: See TracChangeset
for help on using the changeset viewer.