Skip to content

Commit cf02be6

Browse files
Qinghao ShiQinghao Shi
authored andcommitted
EXAMPLES: update console output format
1 parent 6876362 commit cf02be6

File tree

2 files changed

+59
-45
lines changed

2 files changed

+59
-45
lines changed

tools/test/examples/examples.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def do_compile(args, config, examples):
157157

158158
def do_update(args, config, examples):
159159
""" Test update the mbed-os to the version specified by the tag """
160-
return lib.update_mbedos_version(config, args.tag, examples)
160+
return lib.update_mbedos_version(config, args.TAG, examples)
161161

162162
def do_list(_, config, examples):
163163
"""List the examples in the config file"""
@@ -170,7 +170,7 @@ def do_list(_, config, examples):
170170
return 0
171171

172172
def do_symlink(args, config, examples):
173-
return lib.symlink_mbedos(config, args.path, examples)
173+
return lib.symlink_mbedos(config, args.PATH, examples)
174174

175175
if __name__ == "__main__":
176176
sys.exit(main())

tools/test/examples/examples_lib.py

Lines changed: 57 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
from os.path import dirname, abspath, basename, join, normpath
2020
import os.path
2121
import sys
22+
import copy
23+
import stat
2224
import subprocess
2325
from shutil import rmtree
2426
import json
@@ -33,48 +35,53 @@
3335
3436
"""
3537

36-
ROOT = abspath(dirname(dirname(dirname(dirname(__file__)))))
37-
sys.path.insert(0, ROOT)
38+
MBED_OS_ROOT = abspath(dirname(dirname(dirname(dirname(__file__)))))
39+
CWD = os.getcwd()
40+
sys.path.insert(0, MBED_OS_ROOT)
3841

3942
from tools.build_api import get_mbed_official_release
4043
from tools.targets import TARGET_MAP
4144
from tools.export import EXPORTERS
4245
from tools.project import EXPORTER_ALIASES
4346
from tools.toolchains import TOOLCHAINS
4447
from tools.utils import write_json_to_file
48+
from prettytable import PrettyTable
4549

4650
SUPPORTED_TOOLCHAINS = list(TOOLCHAINS - set(u'uARM'))
4751
SUPPORTED_IDES = [exp for exp in list(EXPORTERS) + list(EXPORTER_ALIASES)
4852
if exp != "cmsis" and exp != "zip"]
4953

5054

51-
def print_list(lst):
52-
"""Prints to screen the contents of a list
55+
def get_build_summary(results):
56+
"""Prints to screen the results of compiling/exporting combinations of example programs,
57+
targets and compile toolchains/IDEs.
5358
5459
Args:
55-
lst - a list of any type, to be displayed
60+
results - results of the compilation stage. See compile_repos() and export_repos()
61+
for details of the format.
5662
5763
"""
58-
if lst:
59-
for thing in lst:
60-
print("# %s" % thing)
61-
62-
63-
def print_category(results, index, message):
64-
summary = [example for key, summ in list(results.items())
65-
for example in summ[index]]
66-
if all(len(s) == 0 for s in summary):
67-
return
68-
print("#")
69-
print("#" * 80)
70-
print("# %s" % message)
71-
print("#" * 80)
72-
split_summ = [s.rsplit(" ", 1) for s in summary]
73-
74-
print_list(summary)
75-
76-
77-
def print_summary(results, export=False):
64+
pass_table = PrettyTable()
65+
pass_table.field_names = ["EXAMPLE NAME", "TARGET", "TOOLCHAIN", "TEST GEN", "BUILD RESULT"]
66+
pass_table.align["EXAMPLE NAME"] = "l"
67+
fail_table = copy.deepcopy(pass_table)
68+
failure_counter = 0
69+
70+
for exp, status in list(results.items()):
71+
for summary in status[2]:
72+
pass_table.add_row([summary["name"], summary["target"], summary["toolchain"], summary["test"], "PASSED"])
73+
for summary in status[3]:
74+
fail_table.add_row([summary["name"], summary["target"], summary["toolchain"], summary["test"], "FAILED"])
75+
failure_counter+=1
76+
print("\n\nPassed Example Compilation:")
77+
print(pass_table)
78+
if (failure_counter > 0):
79+
print("\n\nFailed Example Compilation:")
80+
print(fail_table)
81+
print("Number of failures = %d" % failure_counter)
82+
return failure_counter
83+
84+
def get_export_summary(results):
7885
"""Prints to screen the results of compiling/exporting combinations of example programs,
7986
targets and compile toolchains/IDEs.
8087
@@ -83,24 +90,31 @@ def print_summary(results, export=False):
8390
for details of the format.
8491
8592
"""
86-
87-
print("#"*80)
88-
print("# Examples compilation summary")
89-
print("#"*80)
90-
91-
print_category(results, 2, "Passed example combinations")
92-
93-
second_result = "Failed example combinations" if not export else \
94-
"Failed export example combinations"
95-
96-
print_category(results, 3, second_result)
97-
98-
if export:
99-
print_category(results, 4, "Failed build combinations")
100-
print_category(results, 5, "Skipped build combinations")
101-
102-
print("#")
103-
print("#"*80)
93+
pass_table = PrettyTable()
94+
pass_table.field_names = ["EXAMPLE NAME", "TARGET", "IDE", "EXPORT RESULT", "BUILD RESULT"]
95+
pass_table.align["EXAMPLE NAME"] = "l"
96+
fail_table = copy.deepcopy(pass_table)
97+
98+
failure_counter = 0
99+
for exp, status in list(results.items()):
100+
for summary in status[2]:
101+
pass_table.add_row([summary["name"], summary["target"], summary["ide"], "PASSED", "PASSED"])
102+
for summary in status[3]:
103+
fail_table.add_row([summary["name"], summary["target"], summary["ide"], "FAILED", ""])
104+
failure_counter+=1
105+
for summary in status[4]:
106+
fail_table.add_row([summary["name"], summary["target"], summary["ide"], "PASSED", "FAILED"])
107+
failure_counter+=1
108+
for summary in status[5]:
109+
pass_table.add_row([summary["name"], summary["target"], summary["ide"], "PASSED", "SKIPPED"])
110+
111+
print("\n\nPassed Example Exporting:")
112+
print(pass_table)
113+
if (failure_counter > 0):
114+
print("\n\nFailed Example Exporting:")
115+
print(fail_table)
116+
print("Number of failures = %d" % failure_counter)
117+
return failure_counter
104118

105119
def valid_choices(allowed_choices, all_choices):
106120
if len(allowed_choices) > 0:

0 commit comments

Comments
 (0)