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

Reworked app.run exit code #73

Merged
merged 5 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ represented by the pull requests that fixed them.
Versions in parentheses coincide with what is available on [pypi](https://pypi.org/project/scif/).

## [xxx](https://github.com/vsoch/scif/tree/master) (master)
- (re)add exit code to app.run (0.0.84)
- revert exit code to app.run until further notice (0.0.83)
- add exit code to app.run (0.0.82)
- install return value non zero should stop build (0.0.81)
Expand Down
3 changes: 3 additions & 0 deletions docs/hello-world.scif
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@
fi
echo "Argument supplied, exiting with ${1}"
exit ${1}
%apprun hello-world-exit-code
echo "Exiting with code 155"
exit 155
6 changes: 5 additions & 1 deletion scif/main/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,15 @@ def _exec(self, app=None, interactive=False, exit=False):
os.system("".join(cmd))

else:
for line in os.popen(cmd):
f = os.popen(cmd)
for line in f.readlines():
try:
print(line.rstrip())
except:
print(line.rstrip().encode(loc))
status = f.close()
if status:
sys.exit(os.waitstatus_to_exitcode(status))


def execute(self, app, cmd=None, args=None):
Expand Down
1 change: 1 addition & 0 deletions scif/tests/test_exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ echo "Testing exec of commands:"
docker run -it "${CONTAINER_NAME}" exec hello-world-echo echo "Hello World!"
docker run -it "${CONTAINER_NAME}" exec hello-world-script ls /
docker run -it "${CONTAINER_NAME}" exec hello-world-env env
docker run -it "${CONTAINER_NAME}" exec hello-world-env echo [e]OMG
Copy link

Choose a reason for hiding this comment

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

I'm not familiar with the test suite here, but does somewhere check that we get the expected TACOS from this command... or is it just ensuring the command runs and exits with success?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I only followed the same pattern that existed, but had the same question. It is currently, I believe, just exiting with success (and i verified the output with my eyeballs). I will see if I can add a better check to that. I was in the process of trying to make my tests better and similar to those in test_tests.sh, but I'm not sure those are working properly as it is.

@vsoch how do you/CI run these tests?

2 changes: 2 additions & 0 deletions scif/tests/test_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ docker run -it "${CONTAINER_NAME}" run hello-world-echo
docker run -it "${CONTAINER_NAME}" run hello-world-script
docker run -it "${CONTAINER_NAME}" run hello-world-custom "Meatball"
docker run -it "${CONTAINER_NAME}" run hello-world-env | echo "Success"
docker run -it "${CONTAINER_NAME}" run hello-world-exit-code ; echo "Exit code: $? [should be 155]"
docker run -it "${CONTAINER_NAME}" run hello-world-echo; echo "Exit code: $? [should be 0]"
2 changes: 1 addition & 1 deletion scif/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

"""

__version__ = "0.0.83"
__version__ = "0.0.84"
AUTHOR = "Vanessa Sochat"
AUTHOR_EMAIL = "[email protected]"
NAME = "scif"
Expand Down