From 382bc69a2b02ce74a3fcf733adde7abefb6a9278 Mon Sep 17 00:00:00 2001 From: Adam Yoblick Date: Mon, 22 Jul 2024 17:54:01 -0500 Subject: [PATCH] save work --- src/debugpy/server/cli.py | 17 +++++++++++++---- tests/debugpy/server/test_cli.py | 15 ++++++++++----- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/debugpy/server/cli.py b/src/debugpy/server/cli.py index 57ece638..e9547ecb 100644 --- a/src/debugpy/server/cli.py +++ b/src/debugpy/server/cli.py @@ -158,8 +158,12 @@ def set_target(kind: str, parser=(lambda x: x), positional=False): import locale target = target.decode(locale.getpreferredencoding(False)) + options.target = target + log.debug("kind: " + kind) + log.debug("target: " + target) + return do @@ -199,7 +203,7 @@ def consume_argv(): # Consume all the args from a given list def consume_args(args: list): - if (args == sys.argv): + if (args is sys.argv): return consume_argv() while len(args) >= 1: @@ -217,8 +221,8 @@ def parse_args(): parse_args_from_command_line(seen) #parse_args_from_environment(seen) - #print("options:", file=sys.stderr) - #print(options.__dict__, file=sys.stderr) + log.debug("options:") + log.debug(options.__dict__) if options.target is None: raise ValueError("missing target: " + TARGET) @@ -253,7 +257,12 @@ def parse_args_from_environment(seenFromCommandLine: set): def parse_args_helper(args: list, seenFromCommandLine: set, seenFromEnvironment: set = None, isFromEnvironment=False): iterator = consume_args(args) - for arg in iterator: + while True: + try: + arg = next(iterator) + except StopIteration: + break + switch = arg if not switch.startswith("-"): switch = "" diff --git a/tests/debugpy/server/test_cli.py b/tests/debugpy/server/test_cli.py index 26cad791..c081de50 100644 --- a/tests/debugpy/server/test_cli.py +++ b/tests/debugpy/server/test_cli.py @@ -73,11 +73,16 @@ def cli(pyfile): # Test a combination of command line switches -@pytest.mark.parametrize("target_kind", ["file", "module", "code"]) -@pytest.mark.parametrize("mode", ["listen", "connect"]) -@pytest.mark.parametrize("address", ["8888", "localhost:8888"]) -@pytest.mark.parametrize("wait_for_client", ["", "wait_for_client"]) -@pytest.mark.parametrize("script_args", ["", "script_args"]) +#@pytest.mark.parametrize("target_kind", ["file", "module", "code"]) +#@pytest.mark.parametrize("mode", ["listen", "connect"]) +#@pytest.mark.parametrize("address", ["8888", "localhost:8888"]) +#@pytest.mark.parametrize("wait_for_client", ["", "wait_for_client"]) +#@pytest.mark.parametrize("script_args", ["", "script_args"]) +@pytest.mark.parametrize("target_kind", ["file"]) +@pytest.mark.parametrize("mode", ["listen"]) +@pytest.mark.parametrize("address", ["8888"]) +@pytest.mark.parametrize("wait_for_client", ["wait_for_client"]) +@pytest.mark.parametrize("script_args", ["script_args"]) def test_targets(cli, target_kind, mode, address, wait_for_client, script_args): expected_options = { "mode": mode,