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 all commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
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
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
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
8 changes: 8 additions & 0 deletions scif/tests/test_exec.sh
Expand Up @@ -6,3 +6,11 @@ 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

OUT=$(docker run -it "${CONTAINER_NAME}" --quiet exec hello-world-env echo [e]OMG | tr -d '\n\t\r ')
if [ "$OUT" == "TACOS" ]; then
echo "Variable Substitution Success: $OUT"
else
echo "Variable subsitution for e[OMG] failed"
exit 1
fi
2 changes: 2 additions & 0 deletions scif/tests/test_run.sh
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
Expand Up @@ -10,7 +10,7 @@

"""

__version__ = "0.0.83"
__version__ = "0.0.84"
AUTHOR = "Vanessa Sochat"
AUTHOR_EMAIL = "vsochat@stanford.edu"
NAME = "scif"
Expand Down