Skip to content

Commit e2cf677

Browse files
authored
Merge pull request #4895 from billsacks/allow_allactive_systests
Changes needed for CESM to define an FUNITSHARE system test in the allactive area I'd like to add an FUNITSHARE system test - an extension of the FUNIT test that will run the CESM_share tests on derecho as part of prealpha testing. I needed a couple of small additions in CIME to allow this to work: (1) Allowing new System Test types to be defined in the "allactive" area in addition to the cime_config associated with each component. (2) Allowing extra arguments to the run_tests.py command. See ESCOMP/CESM#362 for the CESM changes that leverage this.
2 parents 2f3f221 + 2d14723 commit e2cf677

File tree

5 files changed

+70
-26
lines changed

5 files changed

+70
-26
lines changed

CIME/SystemTests/funit.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ def get_test_spec_dir(self):
3535
"""
3636
return get_cime_root()
3737

38+
def get_extra_run_tests_args(self):
39+
"""
40+
Override this to return a string containing extra command-line arguments to
41+
run_tests.py
42+
"""
43+
return ""
44+
3845
def run_phase(self):
3946

4047
rundir = self._case.get_value("RUNDIR")
@@ -51,8 +58,9 @@ def run_phase(self):
5158
get_cime_root(), "scripts", "fortran_unit_testing", "run_tests.py"
5259
)
5360
)
54-
args = "--build-dir {} --test-spec-dir {} --machine {}".format(
55-
exeroot, test_spec_dir, mach
61+
extra_args = self.get_extra_run_tests_args()
62+
args = "--build-dir {} --test-spec-dir {} --machine {} {}".format(
63+
exeroot, test_spec_dir, mach, extra_args
5664
)
5765

5866
stat = run_cmd(

CIME/XML/tests.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,20 @@ def __init__(self, infile=None, files=None):
2222
files = Files()
2323
infile = files.get_value("CONFIG_TESTS_FILE")
2424
GenericXML.__init__(self, infile)
25-
# append any component specific config_tests.xml files
25+
26+
# Append any component-specific config_tests.xml files. We take care to only add a
27+
# given file once, since adding a given file multiple times creates a "multiple
28+
# matches" error. (This can happen if multiple CONFIG_TESTS_FILEs resolve to the
29+
# same path.)
30+
files_added = set()
2631
for comp in files.get_components("CONFIG_TESTS_FILE"):
2732
if comp is None:
2833
continue
2934
infile = files.get_value("CONFIG_TESTS_FILE", attribute={"component": comp})
30-
if os.path.isfile(infile):
35+
infile_abspath = os.path.abspath(infile)
36+
if os.path.isfile(infile) and infile_abspath not in files_added:
3137
self.read(infile)
38+
files_added.add(infile_abspath)
3239

3340
def support_single_exe(self, case):
3441
"""Checks if case supports --single-exe.

CIME/data/config/cesm/config_files.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
<values>
113113
<value>$CIMEROOT/CIME/data/config/config_tests.xml</value>
114114
<!-- component specific config_tests files -->
115+
<value component="allactive">$SRCROOT/cime_config/config_tests.xml</value>
115116
<value component="clm">$COMP_ROOT_DIR_LND/cime_config/config_tests.xml</value>
116117
<value component="slim">$COMP_ROOT_DIR_LND/cime_config/config_tests.xml</value>
117118
<value component="cam">$COMP_ROOT_DIR_ATM/cime_config/config_tests.xml</value>
@@ -371,6 +372,7 @@
371372
<type>char</type>
372373
<values>
373374
<value component="any" >$CIMEROOT/CIME/SystemTests</value>
375+
<value component="allactive" >$SRCROOT/cime_config/SystemTests</value>
374376
<value component="clm" >$COMP_ROOT_DIR_LND/cime_config/SystemTests</value>
375377
<value component="cam" >$COMP_ROOT_DIR_ATM/cime_config/SystemTests</value>
376378
<value component="pop" >$COMP_ROOT_DIR_OCN/cime_config/SystemTests</value>

CIME/tests/test_unit_xml_tests.py

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,27 @@ def test_support_single_exe(self, _setup_cases_if_not_yet_done):
3232

3333
case.get_compset_components.return_value = ()
3434

35-
case.get_value.side_effect = (
36-
"SMS",
37-
tdir,
38-
f"{caseroot}",
39-
"SMS.f19_g16.S",
40-
"cpl",
41-
"SMS.f19_g16.S",
42-
f"{caseroot}",
43-
"SMS.f19_g16.S",
44-
)
35+
def fake_get_value(item, attribute=None):
36+
simple_lookup = {
37+
"TESTCASE": "SMS",
38+
"CASEROOT": f"{caseroot}",
39+
"CASEBASEID": "SMS.f19_g16.S",
40+
"COMP_INTERFACE": "cpl",
41+
"DRV_RESTART_POINTER": None,
42+
}
43+
if item in simple_lookup:
44+
return simple_lookup[item]
45+
elif item == "SYSTEM_TESTS_DIR":
46+
if attribute["component"] == "any":
47+
return tdir
48+
else:
49+
return None
50+
51+
raise KeyError(
52+
f"Unmocked call: case.get_value({item}, attribute={attribute})"
53+
)
54+
55+
case.get_value.side_effect = fake_get_value
4556

4657
tests = Tests()
4758

@@ -65,17 +76,28 @@ def test_support_single_exe_error(self, _setup_cases_if_not_yet_done):
6576

6677
case.get_compset_components.return_value = ()
6778

68-
case.get_value.side_effect = (
69-
"ERP",
70-
tdir,
71-
f"{caseroot}",
72-
"ERP.f19_g16.S",
73-
"cpl",
74-
None,
75-
"ERP.f19_g16.S",
76-
f"{caseroot}",
77-
"ERP.f19_g16.S",
78-
)
79+
def fake_get_value(item, attribute=None):
80+
simple_lookup = {
81+
"TESTCASE": "ERP",
82+
"CASEROOT": f"{caseroot}",
83+
"CASEBASEID": "ERP.f19_g16.S",
84+
"CASE": "ERP.f19_g16.S",
85+
"COMP_INTERFACE": "cpl",
86+
"DRV_RESTART_POINTER": None,
87+
}
88+
if item in simple_lookup:
89+
return simple_lookup[item]
90+
elif item == "SYSTEM_TESTS_DIR":
91+
if attribute["component"] == "any":
92+
return tdir
93+
else:
94+
return None
95+
96+
raise KeyError(
97+
f"Unmocked call: case.get_value({item}, attribute={attribute})"
98+
)
99+
100+
case.get_value.side_effect = fake_get_value
79101

80102
tests = Tests()
81103

CIME/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2267,7 +2267,7 @@ def find_system_test(testname, case):
22672267
if testname.startswith("TEST"):
22682268
system_test_path = "CIME.SystemTests.system_tests_common.{}".format(testname)
22692269
else:
2270-
components = ["any"]
2270+
components = ["any", "allactive"]
22712271
components.extend(case.get_compset_components())
22722272
fdir = []
22732273
for component in components:
@@ -2276,6 +2276,11 @@ def find_system_test(testname, case):
22762276
)
22772277
if tdir is not None:
22782278
tdir = os.path.abspath(tdir)
2279+
if tdir in fdir:
2280+
# This can happen if multiple SYSTEM_TESTS_DIRs resolve to the same
2281+
# path; in this case, we just want to handle the first occurrence and
2282+
# skip the rest.
2283+
continue
22792284
system_test_file = os.path.join(tdir, "{}.py".format(testname.lower()))
22802285
if os.path.isfile(system_test_file):
22812286
fdir.append(tdir)

0 commit comments

Comments
 (0)