Skip to content

Commit

Permalink
fixes detection of pfunit_path by making sure it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards4b committed Aug 12, 2024
1 parent fcb9c6e commit 7ad1003
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions CIME/tests/test_sys_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import shutil
import sys
import re

from CIME import utils
from CIME.tests import base
Expand Down Expand Up @@ -40,12 +41,27 @@ def _has_unit_test_support(self):
os.environ.get("HOME"), ".cime", "{}.cmake".format(self._machine)
),
]
env_ref_re = re.compile(r"\$ENV\{(\w+)\}")

for macro_to_check in macros_to_check:
if os.path.exists(macro_to_check):
macro_text = open(macro_to_check, "r").read()
if "PFUNIT_PATH" in macro_text:
return True
with open(macro_to_check, "r") as f:
while True:
line = f.readline().strip()
if not line:
break
if "PFUNIT_PATH" in line:
path = line.split(" ")[1][1:-2]
m = env_ref_re.match(path)
if m:
env_var = m.groups()[0]
env_var_exists = env_var in os.environ
if env_var_exists:
path = path.replace(
"$ENV{" + env_var + "}", os.environ[env_var]
)
if os.path.exists(path):
return True

return False

Expand Down

0 comments on commit 7ad1003

Please sign in to comment.