forked from twitter/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
V2
./pants test.pytest
selects interpreter based off of compatibili…
…ty constraints (pantsbuild#7679) Currently the V2 task will always use the current interpreter to run Pytest, even if the targets have different requirements. Instead, we must support choosing the interpreter for the subprocess based on the targets' compatibility (which falls back to global compatibility if missing). Note that we let Pex do the intepreter resolution for us to simplify the Pants code. All we have to do is pass the interpreter constraints to PEX, along with exposing the `--python-setup-interpreter-search-paths`, and then Pex will handle the resolution for us.
- Loading branch information
1 parent
55529b0
commit 6f42467
Showing
3 changed files
with
70 additions
and
7 deletions.
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
python_tests( | ||
name='python_test_runner', | ||
sources=['test_python_test_runner.py'], | ||
dependencies=[ | ||
'src/python/pants/backend/python/rules', | ||
'src/python/pants/backend/python/subsystems', | ||
'src/python/pants/engine/legacy:structs', | ||
'tests/python/pants_test/subsystem:subsystem_utils', | ||
] | ||
) |
31 changes: 31 additions & 0 deletions
31
tests/python/pants_test/backend/python/rules/test_python_test_runner.py
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# coding=utf-8 | ||
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from __future__ import absolute_import, division, print_function, unicode_literals | ||
|
||
from unittest import TestCase | ||
|
||
from pants.backend.python.rules.python_test_runner import parse_interpreter_constraints | ||
from pants.backend.python.subsystems.python_setup import PythonSetup | ||
from pants.engine.legacy.structs import PythonTargetAdaptor | ||
from pants_test.subsystem.subsystem_util import global_subsystem_instance | ||
|
||
|
||
class TestPythonTestRunner(TestCase): | ||
|
||
def test_interpreter_constraints_parsing(self): | ||
python_setup = global_subsystem_instance(PythonSetup) | ||
target_adaptors = [ | ||
# NB: This target will use the global --python-setup-interpreter-constraints. | ||
PythonTargetAdaptor(compatibility=None), | ||
PythonTargetAdaptor(compatibility=["CPython>=400"]), | ||
] | ||
self.assertEqual( | ||
parse_interpreter_constraints(python_setup, target_adaptors), | ||
[ | ||
"--interpreter-constraint", "CPython>=2.7,<3", | ||
"--interpreter-constraint", "CPython>=3.6,<4", | ||
"--interpreter-constraint", "CPython>=400" | ||
] | ||
) |