EXAMPLES: update console output format

pull/11710/head
Qinghao Shi 2019-10-16 18:13:01 +01:00 committed by Qinghao Shi
parent 6876362689
commit cf02be63ff
2 changed files with 59 additions and 45 deletions

View File

@ -157,7 +157,7 @@ def do_compile(args, config, examples):
def do_update(args, config, examples): def do_update(args, config, examples):
""" Test update the mbed-os to the version specified by the tag """ """ Test update the mbed-os to the version specified by the tag """
return lib.update_mbedos_version(config, args.tag, examples) return lib.update_mbedos_version(config, args.TAG, examples)
def do_list(_, config, examples): def do_list(_, config, examples):
"""List the examples in the config file""" """List the examples in the config file"""
@ -170,7 +170,7 @@ def do_list(_, config, examples):
return 0 return 0
def do_symlink(args, config, examples): def do_symlink(args, config, examples):
return lib.symlink_mbedos(config, args.path, examples) return lib.symlink_mbedos(config, args.PATH, examples)
if __name__ == "__main__": if __name__ == "__main__":
sys.exit(main()) sys.exit(main())

View File

@ -19,6 +19,8 @@ import os
from os.path import dirname, abspath, basename, join, normpath from os.path import dirname, abspath, basename, join, normpath
import os.path import os.path
import sys import sys
import copy
import stat
import subprocess import subprocess
from shutil import rmtree from shutil import rmtree
import json import json
@ -33,8 +35,9 @@ logging.basicConfig(level=logging.DEBUG, format='[EXAMPLES]> %(levelname)-8s %(m
""" """
ROOT = abspath(dirname(dirname(dirname(dirname(__file__))))) MBED_OS_ROOT = abspath(dirname(dirname(dirname(dirname(__file__)))))
sys.path.insert(0, ROOT) CWD = os.getcwd()
sys.path.insert(0, MBED_OS_ROOT)
from tools.build_api import get_mbed_official_release from tools.build_api import get_mbed_official_release
from tools.targets import TARGET_MAP from tools.targets import TARGET_MAP
@ -42,39 +45,14 @@ from tools.export import EXPORTERS
from tools.project import EXPORTER_ALIASES from tools.project import EXPORTER_ALIASES
from tools.toolchains import TOOLCHAINS from tools.toolchains import TOOLCHAINS
from tools.utils import write_json_to_file from tools.utils import write_json_to_file
from prettytable import PrettyTable
SUPPORTED_TOOLCHAINS = list(TOOLCHAINS - set(u'uARM')) SUPPORTED_TOOLCHAINS = list(TOOLCHAINS - set(u'uARM'))
SUPPORTED_IDES = [exp for exp in list(EXPORTERS) + list(EXPORTER_ALIASES) SUPPORTED_IDES = [exp for exp in list(EXPORTERS) + list(EXPORTER_ALIASES)
if exp != "cmsis" and exp != "zip"] if exp != "cmsis" and exp != "zip"]
def print_list(lst): def get_build_summary(results):
"""Prints to screen the contents of a list
Args:
lst - a list of any type, to be displayed
"""
if lst:
for thing in lst:
print("# %s" % thing)
def print_category(results, index, message):
summary = [example for key, summ in list(results.items())
for example in summ[index]]
if all(len(s) == 0 for s in summary):
return
print("#")
print("#" * 80)
print("# %s" % message)
print("#" * 80)
split_summ = [s.rsplit(" ", 1) for s in summary]
print_list(summary)
def print_summary(results, export=False):
"""Prints to screen the results of compiling/exporting combinations of example programs, """Prints to screen the results of compiling/exporting combinations of example programs,
targets and compile toolchains/IDEs. targets and compile toolchains/IDEs.
@ -83,24 +61,60 @@ def print_summary(results, export=False):
for details of the format. for details of the format.
""" """
pass_table = PrettyTable()
pass_table.field_names = ["EXAMPLE NAME", "TARGET", "TOOLCHAIN", "TEST GEN", "BUILD RESULT"]
pass_table.align["EXAMPLE NAME"] = "l"
fail_table = copy.deepcopy(pass_table)
failure_counter = 0
print("#"*80) for exp, status in list(results.items()):
print("# Examples compilation summary") for summary in status[2]:
print("#"*80) pass_table.add_row([summary["name"], summary["target"], summary["toolchain"], summary["test"], "PASSED"])
for summary in status[3]:
fail_table.add_row([summary["name"], summary["target"], summary["toolchain"], summary["test"], "FAILED"])
failure_counter+=1
print("\n\nPassed Example Compilation:")
print(pass_table)
if (failure_counter > 0):
print("\n\nFailed Example Compilation:")
print(fail_table)
print("Number of failures = %d" % failure_counter)
return failure_counter
print_category(results, 2, "Passed example combinations") def get_export_summary(results):
"""Prints to screen the results of compiling/exporting combinations of example programs,
targets and compile toolchains/IDEs.
second_result = "Failed example combinations" if not export else \ Args:
"Failed export example combinations" results - results of the compilation stage. See compile_repos() and export_repos()
for details of the format.
print_category(results, 3, second_result) """
pass_table = PrettyTable()
if export: pass_table.field_names = ["EXAMPLE NAME", "TARGET", "IDE", "EXPORT RESULT", "BUILD RESULT"]
print_category(results, 4, "Failed build combinations") pass_table.align["EXAMPLE NAME"] = "l"
print_category(results, 5, "Skipped build combinations") fail_table = copy.deepcopy(pass_table)
print("#") failure_counter = 0
print("#"*80) for exp, status in list(results.items()):
for summary in status[2]:
pass_table.add_row([summary["name"], summary["target"], summary["ide"], "PASSED", "PASSED"])
for summary in status[3]:
fail_table.add_row([summary["name"], summary["target"], summary["ide"], "FAILED", ""])
failure_counter+=1
for summary in status[4]:
fail_table.add_row([summary["name"], summary["target"], summary["ide"], "PASSED", "FAILED"])
failure_counter+=1
for summary in status[5]:
pass_table.add_row([summary["name"], summary["target"], summary["ide"], "PASSED", "SKIPPED"])
print("\n\nPassed Example Exporting:")
print(pass_table)
if (failure_counter > 0):
print("\n\nFailed Example Exporting:")
print(fail_table)
print("Number of failures = %d" % failure_counter)
return failure_counter
def valid_choices(allowed_choices, all_choices): def valid_choices(allowed_choices, all_choices):
if len(allowed_choices) > 0: if len(allowed_choices) > 0: