""" mbed SDK Copyright (c) 2011-2014 ARM Limited Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Author: Przemyslaw Wirkus """ from workspace_tools.utils import construct_enum ResultExporterType = construct_enum(JSON='Json_Exporter', TEXT='Text_Exporter', HTML='Html_Exporter') def exporter_factory(result_exporter_type): pass def exporter_html(test_result_ext): """ Parameter 'test_result_ext' format: u'uARM': { u'LPC1768': { 'MBED_2': { 0: { 'copy_method': 'shutils.copy()', 'duration': 20, 'elapsed_time': 1.7929999828338623, 'single_test_output': 'Host test instrumentation on ...\r\n', 'single_test_result': 'OK', 'target_name': u'LPC1768', 'test_description': 'stdio', 'test_id': u'MBED_2', 'toolchain_name': u'uARM'}}, """ CSS_STYLE = """ """ JAVASCRIPT = """ """ def get_tooltip_name(toolchain, target, test_id, loop_no): return "target_test_%s_%s_%s_%d"% (toolchain.lower(), target.lower(), test_id.lower(), loop_no) def get_result_div_sections(test, test_no): RESULT_COLORS = {'OK' : 'LimeGreen', 'FAIL' : 'Orange', 'ERROR' : 'LightCoral', } tooltip_name = get_tooltip_name(test['toolchain_name'], test['target_name'], test['test_id'], test_no) background_color = RESULT_COLORS[test['single_test_result'] if test['single_test_result'] in RESULT_COLORS else 'ERROR'] result_div_style = "background-color: %s"% background_color result = """
%s
%s in %.2f sec

%s
"""% (result_div_style, tooltip_name, tooltip_name, test['single_test_result'], tooltip_name, test['test_description'], test['elapsed_time'], test['single_test_output'].replace('\n', '
')) return result def get_result_tree(test_results): result = '' test_ids = sorted(test_results.keys()) for test_no in test_ids: test = test_results[test_no] result += """"""% get_result_div_sections(test, test_no) result += '
%s
' return result def get_all_unique_test_ids(test_result_ext): result = [] toolchains = test_result_ext.keys() for toolchain in toolchains: targets = test_result_ext[toolchain].keys() for target in targets: tests = test_result_ext[toolchain][target].keys() result.extend(tests) return sorted(list(set(result))) result = """ mbed SDK test suite test result report %s %s """% (CSS_STYLE, JAVASCRIPT) unique_test_ids = get_all_unique_test_ids(test_result_ext) toolchains = sorted(test_result_ext.keys()) for toolchain in toolchains: result += '

%s

'% toolchain targets = sorted(test_result_ext[toolchain].keys()) result += '' for target in targets: result += ''% (target) tests = sorted(test_result_ext[toolchain][target].keys()) for test in unique_test_ids: result += """"""% test result += """ """ for test in unique_test_ids: test_result = get_result_tree(test_result_ext[toolchain][target][test]) if test in tests else '' result += ''% (test_result) result += '' result += '
%s%s
%s
' result += '' return result