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 --debug-adapter
flag to test
goal
#15799
Conversation
# Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
src/python/pants/core/goals/test.py
Outdated
@@ -311,6 +318,21 @@ def activated(cls, union_membership: UnionMembership) -> bool: | |||
""" | |||
), | |||
) | |||
debug_adaptor = BoolOption( | |||
"--debug-adaptor", |
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.
We should decide this, as we'll share it with run
.
The interactive process used will be immediately blocked waiting for a client before | ||
continuing. |
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.
We'll want to make sure this is true for other adaptors. WDYT?
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.
I think so too.
src/python/pants/core/goals/test.py
Outdated
for debug_request, field_set in zip(debug_requests, targets_to_valid_field_sets.field_sets): | ||
if debug_request.process is None: | ||
if test_subsystem.debug_adaptor: | ||
logger.info(f"Pants doesnt have an adaptor for {field_set.address}. Skipping test.") |
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.
Warn?
prepend_argv=( | ||
"--listen", | ||
f"{debugpy.host}:{debugpy.port}", | ||
"--wait-for-client", |
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.
Alternatively, we could not have the enforcement all implementations want this, and instead make the user specify --debugpy-args=...
but this is much nicer to the user.
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.
lgtm, but would prefer consistent use of the adapter
word. :)
--debug-adaptor
flag to test
goal--debug-adapter
flag to test
goal
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.
Nice.
The interactive process used will be immediately blocked waiting for a client before | ||
continuing. |
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.
I think so too.
Heh, sorry @thejcannon but I just took a quick grep through the Pants code base, and here |
Actually, I went forward with adapter because it is consistent with the protocol name 😉 |
I prefer adapter as well... was just when I raised my gaze and found more adaptors/adapters, that I at least wanted to point it out.
|
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.
Thanks!
register_interpreter_constraints = True | ||
default_interpreter_constraints = ["CPython>=3.7,<3.11"] |
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.
This is slightly odd, because this needs to safely mix with the interpreter for pytest
and your code. Ideally this would inherit the exact same constraints as pytest
(i.e. they need to be in the "same resolve"), but I can't picture how to do that via our existing subsystem infrastructure.
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.
At a minimum, should this be set to Pytest.default_interpreter_constraints
?
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.
Well this isn't test specific: #15829
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.
Thanks!
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.
Cool!
register_interpreter_constraints = True | ||
default_interpreter_constraints = ["CPython>=3.7,<3.11"] |
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.
At a minimum, should this be set to Pytest.default_interpreter_constraints
?
Comment from #15799 (comment)
@thejcannon This is a great feature which I would like to test. Can you share a VScode task and launch configuration to try this out? |
The vanilla |
run's counterpart to pantsbuild#15799. Support is added for pex_binary (which will be spiritually lifted to the python_source with pantsbuild#15849) [ci skip-rust] [ci skip-build-wheels]
run's counterpart to pantsbuild#15799. Support is added for pex_binary (which will be spiritually lifted to the python_source with pantsbuild#15849) [ci skip-rust] [ci skip-build-wheels]
Currently I'm only adding this for Python (using
debugpy
): others can follow suit.This allows clients to launch their test (
run
coming later) with--debug-adapter
which launches the DAP server before loading any Python code. The result is the user can then connect using VS Code (or any other compliant editor) and debug their tests![ci skip-rust]
[ci skip-build-wheels]