File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change 3
3
import os
4
4
import shutil
5
5
import sys
6
+ import re
6
7
7
8
from CIME import utils
8
9
from CIME .tests import base
@@ -46,12 +47,27 @@ def _has_unit_test_support(self):
46
47
),
47
48
os .path .join (cmake_machine_macros_dir , "{}.cmake" .format (self ._machine )),
48
49
]
50
+ env_ref_re = re .compile (r"\$ENV\{(\w+)\}" )
49
51
50
52
for macro_to_check in macros_to_check :
51
53
if os .path .exists (macro_to_check ):
52
- macro_text = open (macro_to_check , "r" ).read ()
53
- if "PFUNIT_PATH" in macro_text :
54
- return True
54
+ with open (macro_to_check , "r" ) as f :
55
+ while True :
56
+ line = f .readline ().strip ()
57
+ if not line :
58
+ break
59
+ if "PFUNIT_PATH" in line :
60
+ path = line .split (" " )[1 ][1 :- 2 ]
61
+ m = env_ref_re .match (path )
62
+ if m :
63
+ env_var = m .groups ()[0 ]
64
+ env_var_exists = env_var in os .environ
65
+ if env_var_exists :
66
+ path = path .replace (
67
+ "$ENV{" + env_var + "}" , os .environ [env_var ]
68
+ )
69
+ if os .path .exists (path ):
70
+ return True
55
71
56
72
return False
57
73
You can’t perform that action at this time.
0 commit comments