From 3415bbe65137fdad85795a521efd9abb1a549adf Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Tue, 7 Feb 2023 10:55:55 +0000 Subject: [PATCH] Fix a bug preventing `cylc vip --workflow-name=foo` from working. `--workflow-name foo` was fine. Caused by removal of unwanted sys.argv for Cylc VIP not removing items not exactly matching items in the Command line options arguments. --- cylc/flow/option_parsers.py | 3 +++ tests/unit/test_option_parsers.py | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/cylc/flow/option_parsers.py b/cylc/flow/option_parsers.py index e9145010b75..19705672209 100644 --- a/cylc/flow/option_parsers.py +++ b/cylc/flow/option_parsers.py @@ -831,6 +831,9 @@ def cleanup_sysargv( not in ['store_true', 'store_false'] ): sys.argv.pop(index) + elif arg in [i.split('=')[0] for i in sys.argv]: + index = [i.split('=')[0] for i in sys.argv].index(arg) + sys.argv.pop(index) # replace compound script name: sys.argv[1] = script_name diff --git a/tests/unit/test_option_parsers.py b/tests/unit/test_option_parsers.py index 332851d34c4..e3831a1daea 100644 --- a/tests/unit/test_option_parsers.py +++ b/tests/unit/test_option_parsers.py @@ -397,6 +397,19 @@ def test_combine_options(inputs, expect): 'play --foo something myworkflow'.split(), id='no path given' ), + param( + 'vip --bar=something'.split(), + { + 'script_name': 'play', + 'workflow_id': 'myworkflow', + 'compound_script_opts': [ + OptionSettings(['--bar', '-b'])], + 'script_opts': [], + 'source': './myworkflow', + }, + 'play myworkflow'.split(), + id='removes --key=value' + ), ] ) def test_cleanup_sysargv(monkeypatch, argv_before, kwargs, expect):