diff --git a/tools/test/examples/examples_lib.py b/tools/test/examples/examples_lib.py index 30fb0aaff3..d9e0770575 100644 --- a/tools/test/examples/examples_lib.py +++ b/tools/test/examples/examples_lib.py @@ -19,7 +19,8 @@ from tools.targets import TARGET_MAP from tools.export import EXPORTERS SUPPORTED_TOOLCHAINS = ["ARM", "IAR", "GCC_ARM"] -SUPPORTED_IDES = ["iar", "uvision", "make_gcc_arm", "make_iar", "make_armc5"] +SUPPORTED_IDES = [exp for exp in EXPORTERS.keys() if exp != "cmsis" and exp != "zip"] + def print_list(lst): """Prints to screen the contents of a list @@ -32,6 +33,21 @@ def print_list(lst): for thing in lst: print("# %s" % thing) + +def print_category(results, index, message): + summary = [example for key, summ in results.iteritems() + 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, targets and compile toolchains/IDEs. @@ -45,27 +61,17 @@ def print_summary(results, export=False): print("#"*80) print("# Examples compilation summary") print("#"*80) - print("#") - print("# Passed example combinations") - print("#") - for key, val in results.iteritems(): - print_list(val[2]) + + print_category(results, 2, "Passed example combinations") second_result = "Failed example combinations" if not export else \ "Failed export example combinations" - - print("#") - print("# %s"%second_result) - print("#") - for key, val in results.iteritems(): - print_list(val[3]) + + print_category(results, 3, second_result) if export: - print("#") - print("# Failed build example combinations") - print("#") - for key, val in results.iteritems(): - print_list(val[4]) + print_category(results, 4, "Failed build combinations") + print_category(results, 5, "Skipped build combinations") print("#") print("#"*80) @@ -141,6 +147,7 @@ def get_repo_list(example): repos.append(example['github']) return repos + def source_repos(config): """ Clones each of the repos associated with the specific examples name from the 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): subprocess.call(["mbed-cli", "import", repo]) + def get_num_failures(results, export=False): """ Returns the number of failed compilations from the results summary Args: @@ -178,15 +186,36 @@ def get_num_failures(results, export=False): def export_repos(config, ides): - def print_message(message, name): - print(message+ " %s"%name) - sys.stdout.flush() + """Exports and builds combinations of example programs, targets and IDEs. + The results are returned in a [key: value] dictionary format: + Where key = The example name from the json config file + value = a list containing: pass_status, successes, export failures, build_failures, + and build_skips + + where pass_status = The overall pass status for the export of the full + set of example programs comprising the example suite. + (IE they must build and export) + True if all examples pass, false otherwise + successes = list of examples that exported and built (if possible) + If the exporter has no build functionality, then it is a pass + if exported + export_failures = list of examples that failed to export. + build_failures = list of examples that failed to build + build_skips = list of examples that cannot build + + Both successes and failures contain the example name, target and IDE + + Args: + config - the json object imported from the file. + ides - List of IDES to export to + """ results = {} print("\nExporting example repos....\n") for example in config['examples']: export_failures = [] build_failures = [] + build_skips = [] successes = [] exported = True pass_status = True @@ -215,12 +244,16 @@ def export_repos(config, ides): else: status("SUCCESS exporting") status("Building") - if EXPORTERS[ide].build(example_project_name): - status("FAILURE building") - build_failures.append(example_name) - else: - status("SUCCESS building") + try: + if EXPORTERS[ide].build(example_project_name): + status("FAILURE building") + build_failures.append(example_name) + else: + status("SUCCESS building") + successes.append(example_name) + except TypeError: successes.append(example_name) + build_skips.append(example_name) os.chdir("..") if len(build_failures+export_failures) > 0: @@ -228,7 +261,8 @@ def export_repos(config, ides): else: exported = False - results[example['name']] = [exported, pass_status, successes, export_failures, build_failures] + results[example['name']] = [exported, pass_status, successes, + export_failures, build_failures, build_skips] return results