Skip to content

Commit 60dab8c

Browse files
committed
run_sys_tests: Check that FUNITFATES dependencies are available.
1 parent a1dc796 commit 60dab8c

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

python/ctsm/path_utils.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,23 @@ def add_ctsm_systests_to_path(standalone_only=False):
105105
sys.path.insert(1, ctsm_systest_dir)
106106

107107

108+
def add_fates_testing_to_path():
109+
"""Adds the FATES testing dir to the python path, to allow importing Python modules from there
110+
"""
111+
fates_testing_path = os.path.join(
112+
os.path.dirname(__file__),
113+
os.pardir,
114+
os.pardir,
115+
"src",
116+
"fates",
117+
"testing",
118+
)
119+
if not os.path.exists(fates_testing_path):
120+
raise RuntimeError(f"src_path not found: '{fates_testing_path}'")
121+
prepend_to_python_path(fates_testing_path)
122+
sys.path.insert(1, fates_testing_path)
123+
124+
108125
# ========================================================================
109126
# Private functions
110127
# ========================================================================

python/ctsm/run_sys_tests.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
)
2525
from ctsm.machine_defaults import MACHINE_DEFAULTS
2626
from ctsm.os_utils import make_link
27-
from ctsm.path_utils import path_to_ctsm_root
27+
from ctsm.path_utils import path_to_ctsm_root, add_fates_testing_to_path
2828
from ctsm.joblauncher.job_launcher_factory import JOB_LAUNCHER_NOBATCH
2929

3030
logger = logging.getLogger(__name__)
@@ -749,6 +749,14 @@ def _check_py_env(test_attributes):
749749
except ModuleNotFoundError as err:
750750
raise ModuleNotFoundError("modify_fsurdat" + err_msg) from err
751751

752+
# Check requirements for FUNITFATES, if needed
753+
if any("FUNITFATES" in t for t in test_attributes):
754+
add_fates_testing_to_path()
755+
try:
756+
import run_unit_tests
757+
except ModuleNotFoundError as err:
758+
raise ModuleNotFoundError("FATES run_unit_tests" + err_msg) from err
759+
752760
# Check requirements for RXCROPMATURITY, if needed
753761
if any("RXCROPMATURITY" in t for t in test_attributes):
754762
try:

0 commit comments

Comments
 (0)