Skip to content

Commit c0c757d

Browse files
fabiobaltierikartben
authored andcommitted
twister: use csv to split extra argument arguments for west flags
Use csv instead of a plain split to split extra arguments for extra west flags, this allows correct passing of arguments that are internally escaped in quotes, such as arugments containing commas. Signed-off-by: Fabio Baltieri <[email protected]>
1 parent 524b72c commit c0c757d

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

scripts/pylib/pytest-twister-harness/src/twister_harness/twister_harness_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def create(cls, config: pytest.Config) -> TwisterHarnessConfig:
6161

6262
west_flash_extra_args: list[str] = []
6363
if config.option.west_flash_extra_args:
64-
west_flash_extra_args = [w.strip() for w in config.option.west_flash_extra_args.split(',')]
64+
west_flash_extra_args = [w.strip() for w in next(csv.reader([config.option.west_flash_extra_args]))]
6565
flash_command: list[str] = []
6666
if config.option.flash_command:
6767
flash_command = [w.strip() for w in next(csv.reader([config.option.flash_command]))]

scripts/pylib/twister/twisterlib/handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ def _create_command(self, runner, hardware):
594594
# 3) Multiple values: --west-flash="--board-id=42,--erase"
595595
# This results in options.west_flash == "--board-id=42 --erase"
596596
if self.options.west_flash and self.options.west_flash != []:
597-
command_extra_args.extend(self.options.west_flash.split(','))
597+
command_extra_args.extend(next(csv.reader([self.options.west_flash])))
598598

599599
if runner:
600600
command.append("--runner")

scripts/tests/twister/test_handlers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,12 +1068,12 @@ def mock_availability(handler, instance, no=num_of_failures):
10681068
'--', '--dummy']
10691069
),
10701070
(
1071-
'--dummy1,--dummy2',
1071+
'--dummy1,--dummy2,"--dummy, 3"',
10721072
None,
10731073
None,
10741074
None,
10751075
['west', 'flash', '--skip-rebuild', '-d', '$build_dir',
1076-
'--', '--dummy1', '--dummy2']
1076+
'--', '--dummy1', '--dummy2', '--dummy, 3']
10771077
),
10781078

10791079
(

0 commit comments

Comments
 (0)