Skip to content

Commit 2d14723

Browse files
committed
Don't error if multiple CONFIG_TESTS_FILEs resolve to the same path
Or if multiple SYSTEM_TESTS_DIRs resolve to the same path.... This happened when I introduced an entry for allactive: in a standalone checkout of CTSM, COMP_ROOT_DIR_LND is the same as SRCROOT, so the allactive and clm CONFIG_TESTS_FILEs and SYSTEM_TESTS_DIRs pointed to the same path, causing an error.
1 parent a5ec807 commit 2d14723

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

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/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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)