| Index: Tools/Scripts/webkitpy/layout_tests/generate_results_dashboard.py
|
| diff --git a/Tools/Scripts/webkitpy/layout_tests/generate_results_dashboard.py b/Tools/Scripts/webkitpy/layout_tests/generate_results_dashboard.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..02eb9fec3dfb0fa48e3eada60d0d6fb3536da3cf
|
| --- /dev/null
|
| +++ b/Tools/Scripts/webkitpy/layout_tests/generate_results_dashboard.py
|
| @@ -0,0 +1,92 @@
|
| +# Copyright (C) 2014 Google Inc. All rights reserved.
|
| +#
|
| +# Redistribution and use in source and binary forms, with or without
|
| +# modification, are permitted provided that the following conditions are
|
| +# met:
|
| +#
|
| +# * Redistributions of source code must retain the above copyright
|
| +# notice, this list of conditions and the following disclaimer.
|
| +# * Redistributions in binary form must reproduce the above
|
| +# copyright notice, this list of conditions and the following disclaimer
|
| +# in the documentation and/or other materials provided with the
|
| +# distribution.
|
| +# * Neither the name of Google Inc. nor the names of its
|
| +# contributors may be used to endorse or promote products derived from
|
| +# this software without specific prior written permission.
|
| +#
|
| +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| +
|
| +import json
|
| +
|
| +from webkitpy.layout_tests.process_json_data import ProcessJsonData
|
| +
|
| +
|
| +class GenerateDashBoard(object):
|
| +
|
| + def __init__(self, port):
|
| + self._port = port
|
| + self._filesystem = port.host.filesystem
|
| + self._results_directory = self._port.results_directory()
|
| + self._release_directory = self._filesystem.dirname(self._results_directory)
|
| + self._current_result_json_dict = {}
|
| + self._old_failing_results_list = []
|
| + self._old_full_results_list = []
|
| + self._final_result = []
|
| +
|
| + def _add_individual_result_links(self, results_directories):
|
| + archived_results_file_list = [(file + '/results.html') for file in results_directories]
|
| + self._current_result_json_dict['result_links'] = archived_results_file_list
|
| +
|
| + def _copy_dashboard_html(self):
|
| + dashboard_file = self._filesystem.join(self._results_directory, 'dashboard.html')
|
| + dashboard_html_file_path = self._filesystem.join(self._port.layout_tests_dir(), 'fast/harness/dashboard.html')
|
| + if not self._filesystem.exists(dashboard_file):
|
| + if self._filesystem.exists(dashboard_html_file_path):
|
| + self._filesystem.copyfile(dashboard_html_file_path, dashboard_file)
|
| +
|
| + def _initialize(self):
|
| + file_list = self._filesystem.listdir(self._release_directory)
|
| + results_directories = []
|
| + for dir in file_list:
|
| + if self._filesystem.isdir(self._filesystem.join(self._release_directory, dir)):
|
| + results_directories.append(self._filesystem.join(self._release_directory, dir))
|
| + results_directories.sort(reverse=True, key=lambda x: self._filesystem.mtime(x))
|
| + with open(self._filesystem.join(results_directories[0], 'failing_results.json'), "r") as file:
|
| + input_json_string = file.readline()
|
| + input_json_string = input_json_string[12:-2] # Remove preceeding string ADD_RESULTS( and ); at the end
|
| + self._current_result_json_dict['tests'] = json.loads(input_json_string)['tests']
|
| +
|
| + # To add hyperlink to individual results.html
|
| + self._add_individual_result_links(results_directories)
|
| + results_directories = results_directories[1:]
|
| +
|
| + # Load the remaining stale layout test results Json's to create the dashboard
|
| + for json_file in results_directories:
|
| + with open(self._filesystem.join(json_file, 'failing_results.json'), "r") as file:
|
| + json_string = file.readline()
|
| + json_string = json_string[12:-2] # Remove preceeding string ADD_RESULTS( and ); at the end
|
| + self._old_failing_results_list.append(json.loads(json_string))
|
| +
|
| + with open(self._filesystem.join(json_file, 'full_results.json'), "r") as full_file:
|
| + json_string_full_result = full_file.readline()
|
| + self._old_full_results_list.append(json.loads(json_string_full_result))
|
| + self._copy_dashboard_html()
|
| +
|
| + def generate(self):
|
| + self._initialize()
|
| + process_json_data = ProcessJsonData(self._current_result_json_dict, self._old_failing_results_list, self._old_full_results_list)
|
| + self._final_result = process_json_data.generate_archived_result()
|
| + final_json = json.dumps(self._final_result)
|
| + final_json = 'ADD_RESULTS(' + final_json + ');'
|
| + with open(self._filesystem.join(self._results_directory, 'archived_results.json'), "w") as file:
|
| + file.write(final_json)
|
|
|