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

Add runtime check for valid Python interpreter #7365

Merged
merged 13 commits into from Mar 14, 2019

Improve test variable name

  • Loading branch information...
Eric-Arellano committed Mar 12, 2019
commit f5e468628d2cfbaa0f268849ea2817665e35464b
@@ -26,11 +26,11 @@ def test_invalid_locale(self):

@skip_unless_any_pythons_present(PY_26, PY_34, PY_35)
def test_invalid_interpreter(self):
This conversation was marked as resolved by Eric-Arellano

This comment has been minimized.

Copy link
@Eric-Arellano

Eric-Arellano Mar 12, 2019

Author Contributor

Bummer. I realized this test won't work in CI because we set RUN_PANTS_FROM_PEX=1, so the line self.run_pants(command=['help'], extra_env={'PY': "python{}".format(invalid_versions_present[0])}) will run the PEX with the interpreter being used.

Even if we could figure out how to get the PEX to be ran with Py26, Py34, or Py35, we wouldn't want to because it would start bootstrapping a new venv folder and slow down CI dramatically.

Thoughts on ways around this, or should I kill the test?

This comment has been minimized.

Copy link
@Eric-Arellano

Eric-Arellano Mar 12, 2019

Author Contributor

One potential workaround to this test failing in CI:

  • Patch PantsLoader._is_supported_interpreter() to always return True, meaning the exception will raise no matter which interpreter we're using. This would allow us to verify we do in fact we do in fact fail Pants and print a nice message.
  • We would not be testing PantsLoader._is_supported_interpreter(), though. Will write a unit test for this.

Will submit an update soon - let me know if you can think of a better design.

invalid_versions = [version for version in find_all_pythons_present()
if not PantsLoader._is_supported_interpreter(
*[int(version_component) for version_component in version.split(".")]
)]
pants_run = self.run_pants(command=['help'], extra_env={'PY': "python{}".format(invalid_versions[0])})
invalid_versions_present = [version for version in find_all_pythons_present()
if not PantsLoader._is_supported_interpreter(
*[int(version_component) for version_component in version.split(".")]
)]
pants_run = self.run_pants(command=['help'], extra_env={'PY': "python{}".format(invalid_versions_present[0])})
self.assert_failure(pants_run)
self.assertIn('unsupported Python interpreter', pants_run.stderr_data)

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.