-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4585 from ESMCI/fix_model_termination_text
This PR fixes finding termination text in logs. Before this fix an S compset was considered a standalone component and for E3SM would not check for correct termination text. Now the log is checked for all possible termination text. Test suite: pytest CIME/tests/test* Test baseline: n/a Test namelist changes: n/a Test status: n/a Fixes n/a User interface changes?: Update gh-pages html (Y/N)?:
- Loading branch information
Showing
2 changed files
with
53 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import unittest | ||
from unittest import mock | ||
|
||
from CIME.utils import CIMEError | ||
from CIME.case.case_run import TERMINATION_TEXT | ||
from CIME.case.case_run import _post_run_check | ||
|
||
|
||
def _case_post_run_check(): | ||
case = mock.MagicMock() | ||
|
||
# RUNDIR, COMP_INTERFACE, COMP_CPL, COMP_ATM, COMP_OCN, MULTI_DRIVER | ||
case.get_value.side_effect = ("/tmp/run", "mct", "cpl", "satm", "socn", False) | ||
|
||
# COMP_CLASSES | ||
case.get_values.return_value = ("CPL", "ATM", "OCN") | ||
|
||
return case | ||
|
||
|
||
class TestCaseSubmit(unittest.TestCase): | ||
@mock.patch("os.stat") | ||
@mock.patch("os.path.isfile") | ||
def test_post_run_check(self, isfile, stat): | ||
isfile.return_value = True | ||
|
||
stat.return_value.st_size = 1024 | ||
|
||
# no exceptions means success | ||
for x in TERMINATION_TEXT: | ||
case = _case_post_run_check() | ||
|
||
with mock.patch("builtins.open", mock.mock_open(read_data=x)) as mock_file: | ||
_post_run_check(case, "1234") | ||
|
||
@mock.patch("os.stat") | ||
@mock.patch("os.path.isfile") | ||
def test_post_run_check_no_termination(self, isfile, stat): | ||
isfile.return_value = True | ||
|
||
stat.return_value.st_size = 1024 | ||
|
||
case = _case_post_run_check() | ||
|
||
with self.assertRaises(CIMEError): | ||
with mock.patch( | ||
"builtins.open", | ||
mock.mock_open(read_data="I DONT HAVE A TERMINATION MESSAGE"), | ||
) as mock_file: | ||
_post_run_check(case, "1234") |