diff options
author | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2019-04-24 13:59:37 -0400 |
---|---|---|
committer | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2019-04-24 13:59:37 -0400 |
commit | 98eebc9356f85fa7611d6bc876eaa631cfe75009 (patch) | |
tree | 3794b37f96f1644e4d7cecee8d66a4dc664d19a6 /buildscripts | |
parent | 3b2fb3741dc4df0a6578ba6485584bf6cc3fb586 (diff) | |
download | mongo-98eebc9356f85fa7611d6bc876eaa631cfe75009.tar.gz |
SERVER-40801 Fix local resmoke invocation for action="append" arguments.
Diffstat (limited to 'buildscripts')
-rw-r--r-- | buildscripts/resmokelib/parser.py | 34 | ||||
-rw-r--r-- | buildscripts/tests/resmokelib/test_parser.py | 30 |
2 files changed, 52 insertions, 12 deletions
diff --git a/buildscripts/resmokelib/parser.py b/buildscripts/resmokelib/parser.py index 80e3b36e516..d03c7704a81 100644 --- a/buildscripts/resmokelib/parser.py +++ b/buildscripts/resmokelib/parser.py @@ -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) diff --git a/buildscripts/tests/resmokelib/test_parser.py b/buildscripts/tests/resmokelib/test_parser.py index 3c071fec91a..712e1aef3f2 100644 --- a/buildscripts/tests/resmokelib/test_parser.py +++ b/buildscripts/tests/resmokelib/test_parser.py @@ -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", |