0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

SERVER-40801 Fix local resmoke invocation for action="append" arguments.

This commit is contained in:
Max Hirschhorn 2019-04-24 13:59:37 -04:00
parent 3b2fb3741d
commit 98eebc9356
2 changed files with 52 additions and 12 deletions

View File

@ -381,7 +381,7 @@ def _make_parser(): # pylint: disable=too-many-statements
return parser
def to_local_args(args=None): # pylint: disable=too-many-locals
def to_local_args(args=None): # pylint: disable=too-many-branches,too-many-locals
"""
Return a command line invocation for resmoke.py suitable for being run outside of Evergreen.
@ -432,6 +432,14 @@ def to_local_args(args=None): # pylint: disable=too-many-locals
"--tagFile",
])
def format_option(option_name, option_value):
"""
Return <option_name>=<option_value>.
This function assumes that 'option_name' is always "--" prefix and isn't "-" prefixed.
"""
return "%s=%s" % (option_name, option_value)
for option_dest in sorted(vars(options)):
option_value = getattr(options, option_dest)
option = options_by_dest[option_dest]
@ -445,18 +453,20 @@ def to_local_args(args=None): # pylint: disable=too-many-locals
continue
if option.takes_value():
# The following serialization assumes 'option_name' is always "--" prefixed and isn't
# "-" prefixed.
arg = "%s=%s" % (option_name, option_value)
# We track the value for the --suites and --storageEngine command line options
# separately in order to more easily sort them to the front.
if option_dest == "suite_files":
suites_arg = arg
elif option_dest == "storage_engine":
storage_engine_arg = arg
if option.action == "append":
args = [format_option(option_name, elem) for elem in option_value]
other_local_args.extend(args)
else:
other_local_args.append(arg)
arg = format_option(option_name, option_value)
# We track the value for the --suites and --storageEngine command line options
# separately in order to more easily sort them to the front.
if option_dest == "suite_files":
suites_arg = arg
elif option_dest == "storage_engine":
storage_engine_arg = arg
else:
other_local_args.append(arg)
else:
other_local_args.append(option_name)

View File

@ -42,6 +42,36 @@ class TestLocalCommandLine(unittest.TestCase):
"--continueOnFailure",
])
def test_keeps_exclude_with_any_tags_option(self):
cmdline = _parser.to_local_args([
"--suites=my_suite",
"--excludeWithAnyTags=tag1,tag2,tag4",
"--excludeWithAnyTags=tag3,tag5",
"--storageEngine=my_storage_engine",
])
self.assertEqual(cmdline, [
"--suites=my_suite",
"--storageEngine=my_storage_engine",
"--excludeWithAnyTags=tag1,tag2,tag4",
"--excludeWithAnyTags=tag3,tag5",
])
def test_keeps_include_with_any_tags_option(self):
cmdline = _parser.to_local_args([
"--suites=my_suite",
"--includeWithAnyTags=tag1,tag2,tag4",
"--includeWithAnyTags=tag3,tag5",
"--storageEngine=my_storage_engine",
])
self.assertEqual(cmdline, [
"--suites=my_suite",
"--storageEngine=my_storage_engine",
"--includeWithAnyTags=tag1,tag2,tag4",
"--includeWithAnyTags=tag3,tag5",
])
def test_keeps_no_journal_option(self):
cmdline = _parser.to_local_args([
"--suites=my_suite",