Skip to content

Commit 30d4efd

Browse files
authored
Merge pull request #4969 from ESMCI/copilot/fix-mail-type-args-perlmutter
Fix --mail-type args to use comma-separated values instead of repeated flags
2 parents 51cfec5 + d570653 commit 30d4efd

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

CIME/XML/env_batch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ def _submit_single_job(
11191119
else:
11201120
submitargs += " {} {}".format(
11211121
mail_type_flag,
1122-
" {} ".format(mail_type_flag).join(mail_type_args),
1122+
",".join(mail_type_args),
11231123
)
11241124
batchsubmit = self.get_value("batch_submit", subgroup=None)
11251125
expect(

CIME/tests/test_unit_xml_env_batch.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,42 @@ def get_value(*args, **kwargs):
10911091
"JOB_WALLCLOCK_TIME", "12:00:00", subgroup="case.run"
10921092
)
10931093

1094+
@mock.patch("CIME.XML.env_batch.get_batch_script_for_job")
1095+
@mock.patch("CIME.XML.env_batch.get_cime_config")
1096+
def test_submit_single_job_mail_type_comma_separated(
1097+
self, get_cime_config, get_batch_script_for_job
1098+
):
1099+
"""Test that multiple mail types are joined with commas, not repeated flags."""
1100+
with ExitStack() as stack:
1101+
file1 = _open_temp_file(stack, XML_BASE)
1102+
batch = EnvBatch(infile=file1.name)
1103+
1104+
case = mock.MagicMock()
1105+
case.get_value.side_effect = lambda *args, **kwargs: {
1106+
"BATCH_COMMAND_FLAGS": "",
1107+
"PROJECT": "test_project",
1108+
}.get(args[0], None)
1109+
case.get_resolved_value.side_effect = lambda x, **kwargs: x
1110+
1111+
cime_config = mock.MagicMock()
1112+
cime_config.has_option.return_value = False
1113+
get_cime_config.return_value = cime_config
1114+
1115+
get_batch_script_for_job.return_value = "case.run"
1116+
batch._env_workflow = mock.MagicMock()
1117+
batch._env_workflow.hidden_job.return_value = False
1118+
1119+
with mock.patch.object(batch, "_build_run_args_str", return_value=""):
1120+
submitcmd = batch._submit_single_job(
1121+
case,
1122+
"case.run",
1123+
mail_type=["end", "fail"],
1124+
dry_run=True,
1125+
)
1126+
1127+
assert "--mail-type end,fail" in submitcmd
1128+
assert "--mail-type end --mail-type fail" not in submitcmd
1129+
10941130
def test_get_job_overrides_mpi_serial_single_task(self):
10951131
"""Test that get_job_overrides gives expected results for an mpi-serial case with a single task"""
10961132
task_count = 1

0 commit comments

Comments
 (0)