Skip to content
Merged
25 changes: 15 additions & 10 deletions schema/suite_v2_0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="fortran_id_type_unique">
<xs:restriction base="xs:ID">
<xs:pattern value="[A-Za-z][A-Za-z0-9_]{0,63}"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="subcycle_type">
<xs:restriction base="xs:string">
<xs:pattern value="[a-z][a-z0-9_]*"/>
Expand All @@ -32,17 +38,17 @@

<xs:complexType name="scheme_type">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="version" type="xs:string" use="optional"/>
<xs:extension base="fortran_id_type">
<xs:attribute name="version" type="version_type" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<xs:complexType name="nested_suite_group_type">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="group" type="xs:string" use="required"/>
<xs:attribute name="name" type="fortran_id_type" use="required"/>
<xs:attribute name="group" type="fortran_id_type" use="required"/>
<xs:attribute name="file" type="xs:string" use="required"/>
</xs:extension>
</xs:simpleContent>
Expand All @@ -51,8 +57,8 @@
<xs:complexType name="nested_suite_type">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="group" type="xs:string" use="optional"/>
<xs:attribute name="name" type="fortran_id_type" use="required"/>
<xs:attribute name="group" type="fortran_id_type" use="optional"/>
<xs:attribute name="file" type="xs:string" use="required"/>
</xs:extension>
</xs:simpleContent>
Expand Down Expand Up @@ -94,7 +100,6 @@
<xs:element name="scheme" type="scheme_type"/>
</xs:choice>
<xs:attribute name="loop" type="subcycle_type" use="optional"/>
<xs:attribute name="name" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>

Expand Down Expand Up @@ -122,7 +127,7 @@
<xs:element name="scheme" type="scheme_type"/>
<xs:element name="nested_suite" type="nested_suite_group_type"/>
</xs:choice>
<xs:attribute name="name" type="xs:ID" use="required"/>
<xs:attribute name="name" type="fortran_id_type_unique" use="required"/>
</xs:complexType>
</xs:element>

Expand All @@ -142,8 +147,8 @@
<xs:element name="finalize" type="scheme_type"/>
</xs:choice>
</xs:sequence>
<xs:attribute name="name" type="xs:ID" use="required"/>
<xs:attribute name="version" type="version_type" use="required"/>
<xs:attribute name="name" type="fortran_id_type_unique" use="required"/>
<xs:attribute name="version" type="version_type" use="required"/>
</xs:complexType>
</xs:element>

Expand Down
Comment thread
gold2718 marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>

<suite name="ver_test_suite" version="2.0">
<group name="group-1">
<scheme>scheme1</scheme>
<scheme>scheme2</scheme>
</group>
</suite>
Comment thread
gold2718 marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>

<suite name="ver_test_suite" version="2.0">
<group name="group1">
<scheme>scheme-1</scheme>
<scheme>scheme2</scheme>
</group>
</suite>
Comment thread
gold2718 marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>

<suite name="ver-test-suite" version="2.0">
<group name="group1">
<scheme>scheme1</scheme>
<scheme>scheme2</scheme>
</group>
</suite>
35 changes: 34 additions & 1 deletion test/unit_tests/test_sdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def test_bad_v2_suite_duplicate_group1(self):
_ = validate_xml_file(compare, 'suite', schema_version, logger)
# end with
emsg = "Schemas validity error : Element 'group', attribute 'name': " + \
"'group1' is not a valid value of the atomic type 'xs:ID'"
"'group1' is not a valid value of the atomic type 'fortran_id_type_unique'"
fmsg = str(context.exception)
self.assertTrue(emsg in fmsg, msg=fmsg)
if not emsg in fmsg:
Expand Down Expand Up @@ -534,3 +534,36 @@ def test_missing_schema_version(self):
# Check exception for expected error messages
self.assertTrue("version attribute required" in str(context.exception),
msg=f"Bad exception for missing suite version")

def test_invalid_fortran_id(self):
"""Test that verification system recognizes a bad Fortran ID entry"""
num_tests = 3
header = "Test trapping of invalid Fortran ID"
tests = [
"suite_invalid_scheme_fortran_id",
"suite_invalid_group_fortran_id",
"suite_invalid_suite_fortran_id",
]
exc_strings = [
"The value 'scheme-1' is not accepted by the pattern '[A-Za-z][A-Za-z0-9_]{0,63}",
"The value 'group-1' is not accepted by the pattern '[A-Za-z][A-Za-z0-9_]{0,63}",
"The value 'ver-test-suite' is not accepted by the pattern '[A-Za-z][A-Za-z0-9_]{0,63}",
]
for test_num in range(num_tests):
# Setup
testname = tests[test_num]
source = os.path.join(_SAMPLE_FILES_DIR, f"{testname}.xml")
logger = self.get_logger()
_, xml_root = read_xml_file(source, logger)
schema_version = find_schema_version(xml_root)
self.assertEqual(schema_version[0], 2)
self.assertEqual(schema_version[1], 0)
# Exercise
with self.assertRaises(Exception) as context:
res = validate_xml_file(source, 'suite', schema_version, logger)
# end with
# Check exception for expected error messages
exp_str = str(context.exception)
self.assertTrue(exc_strings[test_num] in exp_str,
Comment thread
gold2718 marked this conversation as resolved.
msg=f"Bad exception in test {test_num + 1}, '{exp_str}'")
# end for
Loading