From 2274651892cbb638d18be1fc4531d9c0741d703d Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 15 Oct 2014 13:38:20 +0100 Subject: [PATCH] Refactoring of report exporter to support HTML and JUNIT. Added unicode encoding for strings coming from serial console --- workspace_tools/test_api.py | 20 ++++++++++---------- workspace_tools/test_exporters.py | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/workspace_tools/test_api.py b/workspace_tools/test_api.py index df872d1cef..52b667c55b 100644 --- a/workspace_tools/test_api.py +++ b/workspace_tools/test_api.py @@ -1274,16 +1274,6 @@ def singletest_in_cli_mode(single_test): test_summary, shuffle_seed, test_summary_ext, test_suite_properties_ext = single_test.execute() elapsed_time = time() - start - if single_test.opts_report_html_file_name: - # Export results in form of HTML report to separate file - report_exporter = ReportExporter(ResultExporterType.HTML) - report_exporter.report_to_file(test_summary_ext, single_test.opts_report_html_file_name, test_suite_properties=test_suite_properties_ext) - - if single_test.opts_report_junit_file_name: - # Export results in form of HTML report to separate file - report_exporter = ReportExporter(ResultExporterType.JUNIT) - report_exporter.report_to_file(test_summary_ext, single_test.opts_report_junit_file_name, test_suite_properties=test_suite_properties_ext) - # Human readable summary if not single_test.opts_suppress_summary: # prints well-formed summary with results (SQL table like) @@ -1294,6 +1284,16 @@ def singletest_in_cli_mode(single_test): print single_test.generate_test_summary_by_target(test_summary, shuffle_seed) print "Completed in %.2f sec"% (elapsed_time) + # Store extra reports in files + if single_test.opts_report_html_file_name: + # Export results in form of HTML report to separate file + report_exporter = ReportExporter(ResultExporterType.HTML) + report_exporter.report_to_file(test_summary_ext, single_test.opts_report_html_file_name, test_suite_properties=test_suite_properties_ext) + if single_test.opts_report_junit_file_name: + # Export results in form of HTML report to separate file + report_exporter = ReportExporter(ResultExporterType.JUNIT) + report_exporter.report_to_file(test_summary_ext, single_test.opts_report_junit_file_name, test_suite_properties=test_suite_properties_ext) + def mps2_set_board_image_file(disk, images_cfg_path, image0file_path, image_name='images.txt'): """ This function will alter image cfg file. diff --git a/workspace_tools/test_exporters.py b/workspace_tools/test_exporters.py index 48bb7b8bbb..04718d94c9 100644 --- a/workspace_tools/test_exporters.py +++ b/workspace_tools/test_exporters.py @@ -121,7 +121,7 @@ class ReportExporter(): tooltip_name, test['test_description'], test['elapsed_time'], - test['single_test_output'].encode('ascii', 'ignore').replace('\n', '
')) + unicode(test['single_test_output'], errors='ignore').replace('\n', '
')) return result def get_result_tree(self, test_results): @@ -216,7 +216,7 @@ class ReportExporter(): name = test_result['test_description'] classname = 'test.%s.%s.%s'% (target, toolchain, test_result['test_id']) elapsed_sec = test_result['elapsed_time'] - _stdout = test_result['single_test_output'].encode('ascii', 'ignore') + _stdout = unicode(test_result['single_test_output'], errors='ignore') _stderr = '' tc = TestCase(name, classname, elapsed_sec, _stdout, _stderr)