-
-
Notifications
You must be signed in to change notification settings - Fork 289
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
Mock PATH for problematic interpreter selection test in CI #474
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
f79ccc5
Delete path setting from .travis.yml and mock environment var
383d462
Remove pytest skip
51e8b1c
mock os.getenv instead of os.environ
db562e7
try/except for mock import
598024d
reverse mock import order
190d3e0
Add mock to .travis.yml
895ff48
Print mock for debugging
cc6be84
add mock to tox.ini base layer
424ed02
Ensure a python 3 interpreter for mocked path
aa58660
Reset tox.ini
f729487
Fix lint errors
2d8c3a2
Fix isort
49ecfd7
Skip failing test on pypy due to buffer overflow
5bdebe5
fix lint
ac4c3d7
remove pytest skip
049c994
Experiment with trusty for buffer overflow error solution
6d9556d
Use environment_as
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -343,17 +343,18 @@ def test_interpreter_constraints_to_pex_info_py2(): | |
assert set(['>=2.7', '<3']) == set(pex_info.interpreter_constraints) | ||
|
||
|
||
@pytest.mark.skip('https://github.com/pantsbuild/pex/issues/470') | ||
def test_interpreter_constraints_to_pex_info_py3(): | ||
with temporary_dir() as output_dir: | ||
# target python 3 | ||
pex_out_path = os.path.join(output_dir, 'pex_py3.pex') | ||
res = run_pex_command(['--disable-cache', | ||
'--interpreter-constraint=>3', | ||
'-o', pex_out_path]) | ||
res.assert_success() | ||
pex_info = get_pex_info(pex_out_path) | ||
assert ['>3'] == pex_info.interpreter_constraints | ||
py3_interpreter = ensure_python_interpreter('3.6.3') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rather than mocking out |
||
with environment_as(PATH=os.path.dirname(py3_interpreter)): | ||
with temporary_dir() as output_dir: | ||
# target python 3 | ||
pex_out_path = os.path.join(output_dir, 'pex_py3.pex') | ||
res = run_pex_command(['--disable-cache', | ||
'--interpreter-constraint=>3', | ||
'-o', pex_out_path]) | ||
res.assert_success() | ||
pex_info = get_pex_info(pex_out_path) | ||
assert ['>3'] == pex_info.interpreter_constraints | ||
|
||
|
||
def test_interpreter_resolution_with_constraint_option(): | ||
|
@@ -497,61 +498,64 @@ def test_pex_exec_with_pex_python_path_and_pex_python_but_no_constraints(): | |
assert str(pex_python_path.split(':')[0]).encode() in stdout | ||
|
||
|
||
@pytest.mark.skip('https://github.com/pantsbuild/pex/issues/470') | ||
def test_pex_python(): | ||
with temporary_dir() as td: | ||
pexrc_path = os.path.join(td, '.pexrc') | ||
with open(pexrc_path, 'w') as pexrc: | ||
pex_python = ensure_python_interpreter('3.6.3') | ||
pexrc.write("PEX_PYTHON=%s" % pex_python) | ||
|
||
# test PEX_PYTHON with valid constraints | ||
pex_out_path = os.path.join(td, 'pex.pex') | ||
res = run_pex_command(['--disable-cache', | ||
'--rcfile=%s' % pexrc_path, | ||
'--interpreter-constraint=>3', | ||
'--interpreter-constraint=<3.8', | ||
'-o', pex_out_path]) | ||
res.assert_success() | ||
|
||
stdin_payload = b'import sys; print(sys.executable); sys.exit(0)' | ||
stdout, rc = run_simple_pex(pex_out_path, stdin=stdin_payload) | ||
assert rc == 0 | ||
correct_interpreter_path = pex_python.encode() | ||
assert correct_interpreter_path in stdout | ||
|
||
# test PEX_PYTHON with incompatible constraints | ||
pexrc_path = os.path.join(td, '.pexrc') | ||
with open(pexrc_path, 'w') as pexrc: | ||
pex_python = ensure_python_interpreter('2.7.10') | ||
pexrc.write("PEX_PYTHON=%s" % pex_python) | ||
|
||
pex_out_path = os.path.join(td, 'pex2.pex') | ||
res = run_pex_command(['--disable-cache', | ||
'--rcfile=%s' % pexrc_path, | ||
'--interpreter-constraint=>3', | ||
'--interpreter-constraint=<3.8', | ||
'-o', pex_out_path]) | ||
res.assert_success() | ||
|
||
stdin_payload = b'import sys; print(sys.executable); sys.exit(0)' | ||
stdout, rc = run_simple_pex(pex_out_path, stdin=stdin_payload) | ||
assert rc == 1 | ||
fail_str = 'not compatible with specified interpreter constraints'.encode() | ||
assert fail_str in stdout | ||
|
||
# test PEX_PYTHON with no constraints | ||
pex_out_path = os.path.join(td, 'pex3.pex') | ||
res = run_pex_command(['--disable-cache', | ||
'--rcfile=%s' % pexrc_path, | ||
'-o', pex_out_path]) | ||
res.assert_success() | ||
py2_path_interpreter = ensure_python_interpreter('2.7.10') | ||
py3_path_interpreter = ensure_python_interpreter('3.6.3') | ||
path = ':'.join([os.path.dirname(py2_path_interpreter), os.path.dirname(py3_path_interpreter)]) | ||
with environment_as(PATH=path): | ||
with temporary_dir() as td: | ||
pexrc_path = os.path.join(td, '.pexrc') | ||
with open(pexrc_path, 'w') as pexrc: | ||
pex_python = ensure_python_interpreter('3.6.3') | ||
pexrc.write("PEX_PYTHON=%s" % pex_python) | ||
|
||
# test PEX_PYTHON with valid constraints | ||
pex_out_path = os.path.join(td, 'pex.pex') | ||
res = run_pex_command(['--disable-cache', | ||
'--rcfile=%s' % pexrc_path, | ||
'--interpreter-constraint=>3', | ||
'--interpreter-constraint=<3.8', | ||
'-o', pex_out_path]) | ||
res.assert_success() | ||
|
||
stdin_payload = b'import sys; print(sys.executable); sys.exit(0)' | ||
stdout, rc = run_simple_pex(pex_out_path, stdin=stdin_payload) | ||
assert rc == 0 | ||
correct_interpreter_path = pex_python.encode() | ||
assert correct_interpreter_path in stdout | ||
|
||
stdin_payload = b'import sys; print(sys.executable); sys.exit(0)' | ||
stdout, rc = run_simple_pex(pex_out_path, stdin=stdin_payload) | ||
assert rc == 0 | ||
correct_interpreter_path = pex_python.encode() | ||
assert correct_interpreter_path in stdout | ||
# test PEX_PYTHON with incompatible constraints | ||
pexrc_path = os.path.join(td, '.pexrc') | ||
with open(pexrc_path, 'w') as pexrc: | ||
pex_python = ensure_python_interpreter('2.7.10') | ||
pexrc.write("PEX_PYTHON=%s" % pex_python) | ||
|
||
pex_out_path = os.path.join(td, 'pex2.pex') | ||
res = run_pex_command(['--disable-cache', | ||
'--rcfile=%s' % pexrc_path, | ||
'--interpreter-constraint=>3', | ||
'--interpreter-constraint=<3.8', | ||
'-o', pex_out_path]) | ||
res.assert_success() | ||
|
||
stdin_payload = b'import sys; print(sys.executable); sys.exit(0)' | ||
stdout, rc = run_simple_pex(pex_out_path, stdin=stdin_payload) | ||
assert rc == 1 | ||
fail_str = 'not compatible with specified interpreter constraints'.encode() | ||
assert fail_str in stdout | ||
|
||
# test PEX_PYTHON with no constraints | ||
pex_out_path = os.path.join(td, 'pex3.pex') | ||
res = run_pex_command(['--disable-cache', | ||
'--rcfile=%s' % pexrc_path, | ||
'-o', pex_out_path]) | ||
res.assert_success() | ||
|
||
stdin_payload = b'import sys; print(sys.executable); sys.exit(0)' | ||
stdout, rc = run_simple_pex(pex_out_path, stdin=stdin_payload) | ||
assert rc == 0 | ||
correct_interpreter_path = pex_python.encode() | ||
assert correct_interpreter_path in stdout | ||
|
||
|
||
def test_entry_point_targeting(): | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_pex_python
intest_integration.py
needs the same treatment as this test - both were disabled.