"""
Interface to the testspec.xml file. This class inherits from generic_xml.py
"""
from CIME.XML.standard_module_setup import *
from CIME.XML.generic_xml import GenericXML
logger = logging.getLogger(__name__)
[docs]class TestSpec(GenericXML):
def __init__(self, infile):
"""
initialize an object
"""
GenericXML.__init__(self, infile)
self._testnodes = {}
self._testlist_node = None
if os.path.isfile(infile):
testnodes = self.get_children('test')
for node in testnodes:
self._testnodes[self.get(node, "name")] = node
[docs] def add_test(self, compiler, mpilib, testname):
expect(testname not in self._testnodes, "Test {} already in testlist".format(testname))
telem = self.make_child("test", attributes={"name":testname}, root=self._testlist_node)
for name, text in [ ("compiler", compiler), ("mpilib", mpilib) ]:
self.make_child(name, root=telem, text=text)
self._testnodes[testname] = telem
[docs] def update_test_status(self, testname, phase, status):
expect(testname in self._testnodes, "Test {} not defined in testlist".format(testname))
root = self._testnodes[testname]
pnode = self.get_optional_child("section", {"name":phase}, root=root)
if pnode is not None:
self.set(pnode, "status", status)
else:
self.make_child("section", {"name":phase, "status":status}, root=root)