Skip to content

Commit ab76f10

Browse files
authored
Merge pull request #3205 from sarahmarshy/export-build-only-export
[Exporter tests] Export only
2 parents 30e63a2 + 76554fa commit ab76f10

File tree

1 file changed

+61
-27
lines changed

1 file changed

+61
-27
lines changed

tools/test/examples/examples_lib.py

Lines changed: 61 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
from tools.export import EXPORTERS
2020

2121
SUPPORTED_TOOLCHAINS = ["ARM", "IAR", "GCC_ARM"]
22-
SUPPORTED_IDES = ["iar", "uvision", "make_gcc_arm", "make_iar", "make_armc5"]
22+
SUPPORTED_IDES = [exp for exp in EXPORTERS.keys() if exp != "cmsis" and exp != "zip"]
23+
2324

2425
def print_list(lst):
2526
"""Prints to screen the contents of a list
@@ -32,6 +33,21 @@ def print_list(lst):
3233
for thing in lst:
3334
print("# %s" % thing)
3435

36+
37+
def print_category(results, index, message):
38+
summary = [example for key, summ in results.iteritems()
39+
for example in summ[index]]
40+
if all(len(s) == 0 for s in summary):
41+
return
42+
print("#")
43+
print("#" * 80)
44+
print("# %s" % message)
45+
print("#" * 80)
46+
split_summ = [s.rsplit(" ", 1) for s in summary]
47+
48+
print_list(summary)
49+
50+
3551
def print_summary(results, export=False):
3652
"""Prints to screen the results of compiling/exporting combinations of example programs,
3753
targets and compile toolchains/IDEs.
@@ -45,27 +61,17 @@ def print_summary(results, export=False):
4561
print("#"*80)
4662
print("# Examples compilation summary")
4763
print("#"*80)
48-
print("#")
49-
print("# Passed example combinations")
50-
print("#")
51-
for key, val in results.iteritems():
52-
print_list(val[2])
64+
65+
print_category(results, 2, "Passed example combinations")
5366

5467
second_result = "Failed example combinations" if not export else \
5568
"Failed export example combinations"
56-
57-
print("#")
58-
print("# %s"%second_result)
59-
print("#")
60-
for key, val in results.iteritems():
61-
print_list(val[3])
69+
70+
print_category(results, 3, second_result)
6271

6372
if export:
64-
print("#")
65-
print("# Failed build example combinations")
66-
print("#")
67-
for key, val in results.iteritems():
68-
print_list(val[4])
73+
print_category(results, 4, "Failed build combinations")
74+
print_category(results, 5, "Skipped build combinations")
6975

7076
print("#")
7177
print("#"*80)
@@ -141,6 +147,7 @@ def get_repo_list(example):
141147
repos.append(example['github'])
142148
return repos
143149

150+
144151
def source_repos(config):
145152
""" Clones each of the repos associated with the specific examples name from the
146153
json config file. Note if there is already a clone of the repo then it will first
@@ -159,6 +166,7 @@ def source_repos(config):
159166

160167
subprocess.call(["mbed-cli", "import", repo])
161168

169+
162170
def get_num_failures(results, export=False):
163171
""" Returns the number of failed compilations from the results summary
164172
Args:
@@ -178,15 +186,36 @@ def get_num_failures(results, export=False):
178186

179187

180188
def export_repos(config, ides):
181-
def print_message(message, name):
182-
print(message+ " %s"%name)
183-
sys.stdout.flush()
184-
189+
"""Exports and builds combinations of example programs, targets and IDEs.
190+
191+
The results are returned in a [key: value] dictionary format:
192+
Where key = The example name from the json config file
193+
value = a list containing: pass_status, successes, export failures, build_failures,
194+
and build_skips
195+
196+
where pass_status = The overall pass status for the export of the full
197+
set of example programs comprising the example suite.
198+
(IE they must build and export)
199+
True if all examples pass, false otherwise
200+
successes = list of examples that exported and built (if possible)
201+
If the exporter has no build functionality, then it is a pass
202+
if exported
203+
export_failures = list of examples that failed to export.
204+
build_failures = list of examples that failed to build
205+
build_skips = list of examples that cannot build
206+
207+
Both successes and failures contain the example name, target and IDE
208+
209+
Args:
210+
config - the json object imported from the file.
211+
ides - List of IDES to export to
212+
"""
185213
results = {}
186214
print("\nExporting example repos....\n")
187215
for example in config['examples']:
188216
export_failures = []
189217
build_failures = []
218+
build_skips = []
190219
successes = []
191220
exported = True
192221
pass_status = True
@@ -215,20 +244,25 @@ def status(message):
215244
else:
216245
status("SUCCESS exporting")
217246
status("Building")
218-
if EXPORTERS[ide].build(example_project_name):
219-
status("FAILURE building")
220-
build_failures.append(example_name)
221-
else:
222-
status("SUCCESS building")
247+
try:
248+
if EXPORTERS[ide].build(example_project_name):
249+
status("FAILURE building")
250+
build_failures.append(example_name)
251+
else:
252+
status("SUCCESS building")
253+
successes.append(example_name)
254+
except TypeError:
223255
successes.append(example_name)
256+
build_skips.append(example_name)
224257
os.chdir("..")
225258

226259
if len(build_failures+export_failures) > 0:
227260
pass_status= False
228261
else:
229262
exported = False
230263

231-
results[example['name']] = [exported, pass_status, successes, export_failures, build_failures]
264+
results[example['name']] = [exported, pass_status, successes,
265+
export_failures, build_failures, build_skips]
232266

233267
return results
234268

0 commit comments

Comments
 (0)