Skip to content

[Exporter tests] Export only #3205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 7, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 61 additions & 27 deletions tools/test/examples/examples_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
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"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why "cmsis" and "zip" exporters aren't being listed in the supported_ides? Do they lack build steps?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we introspect the class then to see if there's a build function and filter based on that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Further, their generate functions are just bizarre. Zip returns True and CMSIS exports a useless .cpdsc (this one is ust experimental right now).

If we did that, then those others that don't have a build (kds, etc) wouldn't be allowed to do the just exporting part (which is the point of this pr).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. So CMSIS is being excluded now because its experimental, and it sounds like Zip may need to be updated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zip just does weird stuff for the online IDE, I think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, it sounds like these two exporters truly are just strange. In that case the way it's implemented now isn't an issue. 👍



def print_list(lst):
"""Prints to screen the contents of a list
Expand All @@ -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.
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay for docs! 😄

results = {}
print("\nExporting example repos....\n")
for example in config['examples']:
export_failures = []
build_failures = []
build_skips = []
successes = []
exported = True
pass_status = True
Expand Down Expand Up @@ -215,20 +244,25 @@ def status(message):
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:
pass_status= False
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

Expand Down