-
-
Notifications
You must be signed in to change notification settings - Fork 292
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
pex -c incorrectly alters exit codes #137
Comments
I'm able to repro. This is probably a bug with "-c". If you do "pex pytest -m pytest -o pytest.pex" then it works: mba=2015.07.29.pex137=; pex pytest -m pytest -o pytest.pex
mba=2015.07.29.pex137=; ./pytest.pex test_fail.py
====================================================== test session starts =======================================================
platform darwin -- Python 2.7.9 -- py-1.4.30 -- pytest-2.7.2
rootdir: /Users/wickman/work/2015.07.29.pex137, inifile:
collected 1 items
test_fail.py F
============================================================ FAILURES ============================================================
___________________________________________________________ test_fail ____________________________________________________________
def test_fail():
> assert False
E assert False
test_fail.py:2: AssertionError
==================================================== 1 failed in 0.01 seconds ====================================================
mba=2015.07.29.pex137=; echo $?
1 |
Yup, using |
I looked into this a bit this morning:
According to the setuptools docs:
pex currently just calls the entrypoint function but does nothing with the return value. I would guess returning rather than exiting from the entrypoint is uncommon ( I'm not sure if I'll have time to work on a fix immediately, but hopefully this writeup is helpful for anyone who does. |
Setuptools does not require `console_scripts` entry points to call `sys.exit()` (or similar) to exit non-zero: The functions you specify are called with no arguments, and their return value is passed to `sys.exit()`, so you can return an errorlevel or message to print to stderr This patch updates pex to follow the same behavior. Fixes pex-tool#137.
Setuptools does not require `console_scripts` entry points to call `sys.exit()` (or similar) to exit non-zero: The functions you specify are called with no arguments, and their return value is passed to `sys.exit()`, so you can return an errorlevel or message to print to stderr This patch updates pex to follow the same behavior. Fixes #137.
Running pytest from a pex always exits 0 if there are test failures, but not if there are command line argument processing errors.
For example, given this
test_fail.py
:A pytest pex will exit zero:
But running
py.test
in a virtualenv or similar will exit 1.On the other hand, giving a bad option to
py.test
will exit non-zero, as expected:The text was updated successfully, but these errors were encountered: