Skip to content

Commit

Permalink
Adds unit testing for mvk test
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonb5 committed May 16, 2024
1 parent bf19cab commit 9098540
Show file tree
Hide file tree
Showing 4 changed files with 354 additions and 36 deletions.
20 changes: 7 additions & 13 deletions CIME/SystemTests/mvk.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def __init__(self, case, **kwargs):
test_mods_paths = find_test_mods(case.get_value("COMP_INTERFACE"), test_mods)

for test_mods_path in test_mods_paths:
self._config = MVKConfig.load(test_mods_path)
self._config = MVKConfig.load(os.path.join(test_mods_path, "params.py"))

if self._config is None:
self._config = MVKConfig()
Expand All @@ -121,16 +121,12 @@ def __init__(self, case, **kwargs):
if self._config.component == "":
# TODO remove model specific
if self._case.get_value("MODEL") == "e3sm":
self.component = "eam"
self._config.component = "eam"
else:
self.component = "cam"
else:
self.component = self._config.component
self._config.component = "cam"

if len(self._config.components) == 0:
self.components = [self.component]
else:
self.components = self._config.components
self._config.components = [self._config.component]

if (
self._case.get_value("RESUBMIT") == 0
Expand Down Expand Up @@ -162,14 +158,12 @@ def build_phase(self, sharedlib_only=False, model_only=False):
case_setup(self._case, test_mode=False, reset=True)

for iinst in range(1, self._config.ninst + 1):
for component in self.components:
for component in self._config.components:
with open(
"user_nl_{}_{:04d}".format(component, iinst), "w"
) as nml_file:
set_nml_variable = (
lambda x: nml_file.write( # pylint: disable=cell-var-from-loop
f"{x}\n"
)
set_nml_variable = lambda key, value: nml_file.write( # pylint: disable=cell-var-from-loop
f"{key} = {value}\n"
)

self._config.write_inst_nml(
Expand Down
12 changes: 1 addition & 11 deletions CIME/tests/test_unit_case_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from unittest import mock

from CIME.case import case_setup
from CIME.tests.utils import chdir


@contextlib.contextmanager
Expand All @@ -23,17 +24,6 @@ def create_machines_dir():
yield temp_path


@contextlib.contextmanager
def chdir(path):
old_path = os.getcwd()
os.chdir(path)

try:
yield
finally:
os.chdir(old_path)


# pylint: disable=protected-access
class TestCaseSetup(unittest.TestCase):
@mock.patch("CIME.case.case_setup.copy_depends_files")
Expand Down
Loading

0 comments on commit 9098540

Please sign in to comment.