Skip to content
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

Make examples commands return a failure #8605

Merged
merged 2 commits into from Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 4 additions & 8 deletions tools/test/examples/examples.py
Expand Up @@ -97,20 +97,17 @@ def do_export(args, config, examples):

def do_import(_, config, examples):
"""Do the import step of this process"""
lib.source_repos(config, examples)
return 0
return lib.source_repos(config, examples)


def do_clone(_, config, examples):
"""Do the clone step of this process"""
lib.clone_repos(config, examples)
return 0
return lib.clone_repos(config, examples)


def do_deploy(_, config, examples):
"""Do the deploy step of this process"""
lib.deploy_repos(config, examples)
return 0
return lib.deploy_repos(config, examples)


def do_compile(args, config, examples):
Expand All @@ -125,8 +122,7 @@ def do_compile(args, config, examples):

def do_versionning(args, config, examples):
""" Test update the mbed-os to the version specified by the tag """
lib.update_mbedos_version(config, args.tag, examples)
return 0
return lib.update_mbedos_version(config, args.tag, examples)


if __name__ == "__main__":
Expand Down
23 changes: 19 additions & 4 deletions tools/test/examples/examples_lib.py
Expand Up @@ -169,7 +169,11 @@ def source_repos(config, examples):
print("'%s' example directory already exists. Deleting..." % name)
rmtree(name)

subprocess.call(["mbed-cli", "import", repo_info['repo']])
result = subprocess.call(["mbed-cli", "import", repo_info['repo']])
if result:
return result

return 0

def clone_repos(config, examples , retry = 3):
""" Clones each of the repos associated with the specific examples name from the
Expand All @@ -192,6 +196,8 @@ def clone_repos(config, examples , retry = 3):
break
else:
print("ERROR : unable to clone the repo {}".format(name))
return 1
return 0

def deploy_repos(config, examples):
""" If the example directory exists as provided by the json config file,
Expand All @@ -207,11 +213,15 @@ def deploy_repos(config, examples):
if name in examples:
if os.path.exists(name):
os.chdir(name)
subprocess.call(["mbed-cli", "deploy"])
result = subprocess.call(["mbed-cli", "deploy"])
os.chdir("..")
if result:
print("mbed-cli deploy command failed for '%s'" % name)
return result
else:
print("'%s' example directory doesn't exist. Skipping..." % name)

return 1
return 0

def get_num_failures(results, export=False):
""" Returns the number of failed compilations from the results summary
Expand Down Expand Up @@ -405,5 +415,10 @@ def update_mbedos_version(config, tag, examples):
update_dir = basename(repo_info['repo']) + "/mbed-os"
print("\nChanging dir to %s\n" % update_dir)
os.chdir(update_dir)
subprocess.call(["mbed-cli", "update", tag, "--clean"])
result = subprocess.call(["mbed-cli", "update", tag, "--clean"])
os.chdir("../..")
if result:
return result:
Copy link
Contributor

Choose a reason for hiding this comment

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

@OPpuolitaival found this, but the correct thing here would be:

Suggested change
return result:
return result

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup copy paste there me thinks.


return 0