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

Conversation

adbridge
Copy link
Contributor

Description

Currently the following commands in examples.py,
do_import()
do_deploy()
do_versionning()
do_clone()

all return a success status (ie 0) irrespective of any errors
originating from their sub-functions.

This PR fixes this. Now these commands will return one of:
0 - success
1 - general failure
x - failure returned by a subprocess.call function

Pull request type

[x] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Currently the following commands in examples.py,
do_import()
do_deploy()
do_versionning()
do_clone()

all return a success status (ie 0) irrespective of any errors
originating from their sub-functions.

This PR fixes this. Now these commands will return one of:
0 - success
1 - general failure
x - failure returned by a subprocess.call function
@ciarmcom ciarmcom requested review from a team October 31, 2018 17:47
@ciarmcom
Copy link
Member

ciarmcom commented Oct 31, 2018

@adbridge, thank you for your changes. @ARMmbed/mbed-os-tools @ARMmbed/mbed-os-maintainers please review.

@adbridge
Copy link
Contributor Author

Fixes #8568

@cmonr cmonr requested a review from a team October 31, 2018 18:26
@OPpuolitaival
Copy link
Contributor

@adbridge Did you test this? I tested a bit suprocess.call() function and seems to work in a way that:

  • subprocess.call("exit 1") => not returning anything, just raising an error
  • subprocess.call("exit 1", shell=True) => return a return code

It seems that you expect the behaviour as shell=True but it is false as default

@OPpuolitaival
Copy link
Contributor

[examples] Running shell script

  • python -u ../mbed-os/tools/test/examples/examples.py clone
    Traceback (most recent call last):
    File "../mbed-os/tools/test/examples/examples.py", line 17, in
    import examples_lib as lib
    File "/builds/ws/ci_PR-8605-QHY26DPOP4ARV3WYD2LBS/mbed-os/tools/test/examples/examples_lib.py", line 421
    return result:
    ^
    SyntaxError: invalid syntax
    script returned exit code 1

@OPpuolitaival
Copy link
Contributor

Now fixed CI so that it also catch examples fetching problems right way.

@cmonr
Copy link
Contributor

cmonr commented Oct 31, 2018

Now fixed CI so that it also catch examples fetching problems right way.

@OPpuolitaival Are you referring to this?
https://github.com/ARMmbed/mbed-os-ci/pull/190/files

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.

@adbridge
Copy link
Contributor Author

adbridge commented Nov 1, 2018

@OPpuolitaival mmmm I just looked at a call that was already in the code:

if subprocess.call([repo_info['type'], "clone", repo_info['repo']]) == 0:

So from what you said that would never have worked either.

@adbridge
Copy link
Contributor Author

adbridge commented Nov 1, 2018

Fixing...

subprocess.call() does not by default return a status value.

Update the commands to add shell=True which forces a return value.
Also convert the commands to a single string rather than a list as
this plays more nicely with both linux and windows.

Also fix a spurious :
@NirSonnenschein
Copy link
Contributor

/morph build

@mbed-ci
Copy link

mbed-ci commented Nov 4, 2018

Build : SUCCESS

Build number : 3541
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/8605/

Triggering tests

/morph test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Nov 4, 2018

@mbed-ci
Copy link

mbed-ci commented Nov 4, 2018

@0xc0170 0xc0170 merged commit 909c11b into ARMmbed:master Nov 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants