Skip to content

Commit d700144

Browse files
authored
Merge pull request #4667 from Crivella/fix-easystack_multiple_call
Added possibility to call `amend/try-amend` multiple times from easystack
2 parents 7ca20ce + 201aba6 commit d700144

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

easybuild/tools/options.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,6 +2002,7 @@ def opts_dict_to_eb_opts(args_dict):
20022002
:return: a list of strings representing command-line options for the 'eb' command
20032003
"""
20042004

2005+
allow_multiple_calls = ['amend', 'try-amend']
20052006
_log.debug("Converting dictionary %s to argument list" % args_dict)
20062007
args = []
20072008
for arg in sorted(args_dict):
@@ -2011,14 +2012,18 @@ def opts_dict_to_eb_opts(args_dict):
20112012
prefix = '--'
20122013
option = prefix + str(arg)
20132014
value = args_dict[arg]
2014-
if isinstance(value, (list, tuple)):
2015-
value = ','.join(str(x) for x in value)
20162015

2017-
if value in [True, None]:
2016+
if str(arg) in allow_multiple_calls:
2017+
if not isinstance(value, (list, tuple)):
2018+
value = [value]
2019+
args.extend(option + '=' + str(x) for x in value)
2020+
elif value in [True, None]:
20182021
args.append(option)
20192022
elif value is False:
20202023
args.append('--disable-' + option[2:])
20212024
elif value is not None:
2025+
if isinstance(value, (list, tuple)):
2026+
value = ','.join(str(x) for x in value)
20222027
args.append(option + '=' + str(value))
20232028

20242029
_log.debug("Converted dictionary %s to argument list %s" % (args_dict, args))

test/framework/options.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7253,6 +7253,15 @@ def test_opts_dict_to_eb_opts(self):
72537253
]
72547254
self.assertEqual(opts_dict_to_eb_opts(opts_dict), expected)
72557255

7256+
# multi-call options
7257+
opts_dict = {'try-amend': ['a=1', 'b=2', 'c=3']}
7258+
expected = ['--try-amend=a=1', '--try-amend=b=2', '--try-amend=c=3']
7259+
self.assertEqual(opts_dict_to_eb_opts(opts_dict), expected)
7260+
7261+
opts_dict = {'amend': ['a=1', 'b=2', 'c=3']}
7262+
expected = ['--amend=a=1', '--amend=b=2', '--amend=c=3']
7263+
self.assertEqual(opts_dict_to_eb_opts(opts_dict), expected)
7264+
72567265

72577266
def suite():
72587267
""" returns all the testcases in this module """

0 commit comments

Comments
 (0)