19
19
from os .path import dirname , abspath , basename , join , normpath
20
20
import os .path
21
21
import sys
22
+ import copy
23
+ import stat
22
24
import subprocess
23
25
from shutil import rmtree
24
26
import json
33
35
34
36
"""
35
37
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 )
38
41
39
42
from tools .build_api import get_mbed_official_release
40
43
from tools .targets import TARGET_MAP
41
44
from tools .export import EXPORTERS
42
45
from tools .project import EXPORTER_ALIASES
43
46
from tools .toolchains import TOOLCHAINS
44
47
from tools .utils import write_json_to_file
48
+ from prettytable import PrettyTable
45
49
46
50
SUPPORTED_TOOLCHAINS = list (TOOLCHAINS - set (u'uARM' ))
47
51
SUPPORTED_IDES = [exp for exp in list (EXPORTERS ) + list (EXPORTER_ALIASES )
48
52
if exp != "cmsis" and exp != "zip" ]
49
53
50
54
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.
53
58
54
59
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.
56
62
57
63
"""
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 \n Passed Example Compilation:" )
77
+ print (pass_table )
78
+ if (failure_counter > 0 ):
79
+ print ("\n \n Failed 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 ):
78
85
"""Prints to screen the results of compiling/exporting combinations of example programs,
79
86
targets and compile toolchains/IDEs.
80
87
@@ -83,24 +90,31 @@ def print_summary(results, export=False):
83
90
for details of the format.
84
91
85
92
"""
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 \n Passed Example Exporting:" )
112
+ print (pass_table )
113
+ if (failure_counter > 0 ):
114
+ print ("\n \n Failed Example Exporting:" )
115
+ print (fail_table )
116
+ print ("Number of failures = %d" % failure_counter )
117
+ return failure_counter
104
118
105
119
def valid_choices (allowed_choices , all_choices ):
106
120
if len (allowed_choices ) > 0 :
0 commit comments