-
-
Notifications
You must be signed in to change notification settings - Fork 646
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
V2 ./pants test.pytest
selects interpreter based off of compatibility constraints
#7679
Merged
Eric-Arellano
merged 15 commits into
pantsbuild:master
from
Eric-Arellano:pytest-version
May 13, 2019
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5bc6e7f
Step 1 and 2: require PythonSetup and pass interpreter constraints
Eric-Arellano 39b7bc6
Use python_setup.compatibility_or_constraints()
Eric-Arellano 985bd74
Merge branch 'master' of github.com:pantsbuild/pants into pytest-version
Eric-Arellano 122b9c4
Fix interpreters failing to resolve by adding interpreter search path…
Eric-Arellano 52a0c9d
Merge branch 'master' of github.com:pantsbuild/pants into pytest-version
Eric-Arellano 432a171
Refactor to extract out new parse_interpreter_constraints() function
Eric-Arellano e1debe8
Add test skeleton
Eric-Arellano b9a8eb1
Tighten parse_interpreter_constraints() to take TargetAdaptor rather …
Eric-Arellano e924a98
Squashed commit of the following:
Eric-Arellano afaa53a
Use PythonSetup in tests and extract helper assertion function
Eric-Arellano 065cd37
Merge branch 'master' of github.com:pantsbuild/pants into pytest-version
Eric-Arellano 0d8bd15
Remove workaround for python_setup.compatibility_or_constraints()
Eric-Arellano 2242c95
Setup PythonTargetAdaptor
Eric-Arellano 58ef099
Simplify test to test what we actually care about
Eric-Arellano 1b7049b
Merge branch 'master' of github.com:pantsbuild/pants into pytest-version
Eric-Arellano 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 |
---|---|---|
@@ -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" | ||
] | ||
) |
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.
Bikeshed time! In rules files, should we have helper functions like this appear above or below the main
@rule
anddef rules()
?I have no preference and really don't know what's best.
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.
IMO, it should appear nearest to the
@rule
that it is being used by. If there were more rules in this file, they might appear above/below a static function for that reason.But it doesn't really matter.