Skip to content
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

allow usingamend/try-amend multiple times in an easystack file entry #4667

Merged
merged 4 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions easybuild/tools/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -2002,6 +2002,7 @@ def opts_dict_to_eb_opts(args_dict):
:return: a list of strings representing command-line options for the 'eb' command
"""

allow_multiple_calls = ['amend', 'try-amend']
_log.debug("Converting dictionary %s to argument list" % args_dict)
args = []
for arg in sorted(args_dict):
Expand All @@ -2011,14 +2012,18 @@ def opts_dict_to_eb_opts(args_dict):
prefix = '--'
option = prefix + str(arg)
value = args_dict[arg]
if isinstance(value, (list, tuple)):
value = ','.join(str(x) for x in value)

if value in [True, None]:
if str(arg) in allow_multiple_calls:
if not isinstance(value, (list, tuple)):
value = [value]
args.extend(option + '=' + str(x) for x in value)
elif value in [True, None]:
args.append(option)
elif value is False:
args.append('--disable-' + option[2:])
elif value is not None:
if isinstance(value, (list, tuple)):
value = ','.join(str(x) for x in value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also cover this with an enhanced test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is already covered with

'from-pr': [1234, 2345],

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But i can add a separate test if needed

args.append(option + '=' + str(value))

_log.debug("Converted dictionary %s to argument list %s" % (args_dict, args))
Expand Down
9 changes: 9 additions & 0 deletions test/framework/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -7252,6 +7252,15 @@ def test_opts_dict_to_eb_opts(self):
]
self.assertEqual(opts_dict_to_eb_opts(opts_dict), expected)

# multi-call options
opts_dict = {'try-amend': ['a=1', 'b=2', 'c=3']}
expected = ['--try-amend=a=1', '--try-amend=b=2', '--try-amend=c=3']
self.assertEqual(opts_dict_to_eb_opts(opts_dict), expected)

opts_dict = {'amend': ['a=1', 'b=2', 'c=3']}
expected = ['--amend=a=1', '--amend=b=2', '--amend=c=3']
self.assertEqual(opts_dict_to_eb_opts(opts_dict), expected)


def suite():
""" returns all the testcases in this module """
Expand Down
Loading