diff --git a/easybuild/tools/options.py b/easybuild/tools/options.py index fd22e384e5..cb65498a81 100644 --- a/easybuild/tools/options.py +++ b/easybuild/tools/options.py @@ -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): @@ -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) args.append(option + '=' + str(value)) _log.debug("Converted dictionary %s to argument list %s" % (args_dict, args)) diff --git a/test/framework/options.py b/test/framework/options.py index 2208465db0..0b5f285464 100644 --- a/test/framework/options.py +++ b/test/framework/options.py @@ -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 """